Have you tested that the method actually runs, e.g. by inserting a print statement? You need to annotate your class with @EventBusSubscriber, if you have not done that.
I tried adding @EventBusSubscriber(modid = MyMod.MOD_ID, bus = Bus.MOD) before the EventHandler class, but I couldnt figure out how to register it in my main mod class, so it wasn't able to launch without a crash report.
I tried changing the Subscribe Event to just play the strip sound when clicked in general, didn't work
@SubscribeEvent
public static void onBlockClicked(PlayerInteractEvent.RightClickBlock event) {
World world = event.getWorld();
BlockPos blockpos = event.getPos();
PlayerEntity playerentity = event.getPlayer();
world.playSound(playerentity, blockpos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
}
Yes; my BlockInit uses the MOD bus. The EventHandler class uses the FORGE bus. Even if I use the MOD bus in the EventHandler, it is still unable to launch.
I just can't seem to get this to work. I just want this to act as the vanilla logs do, any help is appreciated!
What exactly is the problem?
My logs just aren't stripping. I even tried making an AxeItem in my libraries that extends Minecraft's AxeItem.
Here's that:
¯\_(ツ)_/¯
Have you tested that the method actually runs, e.g. by inserting a print statement? You need to annotate your class with @EventBusSubscriber, if you have not done that.
I tried adding @EventBusSubscriber(modid = MyMod.MOD_ID, bus = Bus.MOD) before the EventHandler class, but I couldnt figure out how to register it in my main mod class, so it wasn't able to launch without a crash report.
I tried changing the Subscribe Event to just play the strip sound when clicked in general, didn't work
That is the wrong bus, it should be Bus.FORGE.
Doing this gives a crash report saying "Registry Object not present: mymod:mossy_log"
I have this in my BlockInit:
You still have to register stuff (like blocks) on the MOD bus.
Yes; my BlockInit uses the MOD bus. The EventHandler class uses the FORGE bus. Even if I use the MOD bus in the EventHandler, it is still unable to launch.
Then I don't know. Do you mind uploading your code to a git repo so I can take a look?
I was actually able to come up with a solution using Reflection!
Also, I changed mossy to Afolia.
EventHandler:
Then I added this to my ClientEventBusSubscriber class:
And it just worked
Thanks for your help nonetheless <3
Great, I am glad you were able to solve it!