Доброго времени суток. Значит проблема такова - есть класс пакета, который регистрируется в Main классе.
Код пакета:
public class SanityHurtMessageHandler implements IMessage, IMessageHandler {
public void toBytes(ByteBuf buf) {}
public void fromBytes(ByteBuf buf) {}
public IMessage onMessage(SanityHurtMessageHandler message, MessageContext ctx) {
if(Minecraft.getMinecraft().thePlayer != null && TickHandler.sanity > 1) {
TickHandler.sanity -= 5;
}
return null;
}
}
И вот код регистрации пакета в Main классе:
public static SimpleNetworkWrapper snw;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
SanityPotion = (new SanityPotion()).setUnlocalizedName("SanityPotion");
snw = NetworkRegistry.INSTANCE.newSimpleChannel("AMS");
snw.registerMessage(SanityHurtMessageHandler.class, SanityHurtMessageHandler.class, 1, Side.CLIENT);
FMLCommonHandler.instance().bus().register(new FMLEventHandler());
MinecraftForge.EVENT_BUS.register(new MCFEventHandler());
proxy.initMod();
}
В конечном итоге я получаю ошибку навроде "Calss must be declared or abstract or implement onMessage..." в классе пакета. Как это решить?
Код пакета:
public class SanityHurtMessageHandler implements IMessage, IMessageHandler {
public void toBytes(ByteBuf buf) {}
public void fromBytes(ByteBuf buf) {}
public IMessage onMessage(SanityHurtMessageHandler message, MessageContext ctx) {
if(Minecraft.getMinecraft().thePlayer != null && TickHandler.sanity > 1) {
TickHandler.sanity -= 5;
}
return null;
}
}
И вот код регистрации пакета в Main классе:
public static SimpleNetworkWrapper snw;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
SanityPotion = (new SanityPotion()).setUnlocalizedName("SanityPotion");
snw = NetworkRegistry.INSTANCE.newSimpleChannel("AMS");
snw.registerMessage(SanityHurtMessageHandler.class, SanityHurtMessageHandler.class, 1, Side.CLIENT);
FMLCommonHandler.instance().bus().register(new FMLEventHandler());
MinecraftForge.EVENT_BUS.register(new MCFEventHandler());
proxy.initMod();
}
В конечном итоге я получаю ошибку навроде "Calss must be declared or abstract or implement onMessage..." в классе пакета. Как это решить?