Posted July 14, 20205 yr Hi everyone, I'm having issues using this event. All I did was add a simple logger to it, and it does not log when I change difficulty through commands in game (/difficulty peaceful), while other events do log properly. Here is the code: package com.eon.sharkmod.events; import com.eon.sharkmod.SharkMod; import net.minecraft.world.Difficulty; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.event.DifficultyChangeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; @Mod.EventBusSubscriber(modid = SharkMod.MOD_ID, bus = Bus.FORGE) public class DifficultyChangeEventHandler { @SubscribeEvent public static void difficultyChangeEvent(DifficultyChangeEvent event) { SharkMod.LOGGER.info("testing"); Difficulty newDiff = event.getDifficulty(); SharkMod.LOGGER.info("Hey! New dif: " + newDiff + ", old dif: " + event.getOldDifficulty()); } } Neither of these logs print. Can anyone point me in the right direction? I've tried changing the bus to MOD, even tho I knew it was dumb (it didn't work). I was also maybe thinking that this event only fires if the difficulty is changed through actual java code (instead of commands), so I tried this: this.entity.world.getWorldInfo().setDifficulty(Difficulty.HARD); First, this did change the difficulty but did not fire the event. I also put this line in the tick() method, and then launched my game and tried changing difficulty with commands all while difficulty was changing with the every tick, but nothing logged. What am I doing wrong? Is there some other way of knowing when the difficulty changes? I'd like to adjust my shark's ai goals and stats Thank you!
July 14, 20205 yr My IDE says onDifficultyChange(Difficulty difficulty, Difficulty oldDifficulty) in ForgeHooks is never called in all places, not sure why is this happening
July 14, 20205 yr Author Can this potentially be a forge bug? EDIT: I was also trying to figure out how/where in the code, zombies despawn when changing to peaceful. Couldn't find it tho Edited July 14, 20205 yr by BadBichShaquonda
July 14, 20205 yr setAllowedSpawnTypes(boolean hostile, boolean peaceful) in World and public void checkDespawn() in MobEntity
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.