Jump to content

My listener for subscribe events is don't work.


Recommended Posts

Hello everyone! I'm a begineer developer in forge, the reason i'm here is because my listener to events is don't work!

This is simple, i ever register the listener in MinecraftForge.EVENT_BUS and FMLCommonHandler in EventHandlers.

But, in game my debug not is calle


My forge version is 1.7.10, and I know that the doubts about this version are gone.


	private void onInit(FMLInitializationEvent event) {
		GuardListener listener = new GuardListener();


My listener is:

	private final CuboidRepository cuboidRepository = CuboidRepository.getInstance();
	private void onJoin(PlayerEvent.PlayerLoggedInEvent event) {
	@SubscribeEvent(priority = EventPriority.HIGHEST)
	private void onDamage(LivingAttackEvent event) {
		if(!(event.entityLiving instanceof EntityPlayer)) return;
		Cuboid cuboid = cuboidRepository.has(event.entityLiving.worldObj, event.entityLiving.chunkCoordX, event.entityLiving.chunkCoordY, event.entityLiving.chunkCoordZ);
		if(cuboid == null) return; 
		event.setCanceled(true); TextMessage.of().apply("The pvp is disabled in your region!").color(EnumChatFormatting.RED).build((EntityPlayer) event.entityLiving);
	@SubscribeEvent(priority = EventPriority.HIGHEST)
	private void onDamaged(AttackEntityEvent event) {
		if(!(event.target instanceof EntityPlayer)) return;
		Cuboid cuboid = cuboidRepository.has(event.entityPlayer.worldObj, event.entityPlayer.playerLocation.posX, event.entityPlayer.playerLocation.posY, event.entityPlayer.playerLocation.posZ);
		if(cuboid == null) return;
		event.setCanceled(true); TextMessage.of().apply("The pvp is disabled in your region!").color(EnumChatFormatting.RED).build(event.entityPlayer);


There will be some errors in the code or maybe even crazy, but it's simple, because I just want to see if I get messages from the events ...

EDIT: This mod is server-side!

Edited by WizardBR
Link to comment
Share on other sites

This topic is now closed to further replies.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.