Posted August 12, 20196 yr I just want to spawn an Item on my mod when I right click with empty hand on a log, I make this : package fr.ayfri.testmod.init; import net.minecraft.entity.item.ItemEntity; import net.minecraft.item.ItemStack; import net.minecraft.tags.BlockTags; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class BlockEventHandler { public static final BlockEventHandler INSTANCE = new BlockEventHandler(); @SubscribeEvent public void OnRightClickBlock(PlayerInteractEvent.RightClickBlock e) { if(e.getWorld().getBlockState(e.getPos()).getBlock().isIn(BlockTags.LOGS) && e.getEntityPlayer().getHeldItemMainhand().isEmpty()) { System.out.println("wood log touched"); ItemEntity wood_piece = new ItemEntity(e.getWorld(), e.getPos().getX(), e.getPos().getY(), e.getPos().getZ(), new ItemStack(ModItems.wood_piece)); e.getWorld().addEntity(wood_piece); } return; } } But when I right click on a log, it says "wood log touched" but it doesn't spawn any Item, can you help me to figure out why ? Edited August 12, 20196 yr by Ayfri println text in French
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.