Posted December 7, 20204 yr I want to detect when a player left clicks on a block, but onBlockClicked does nothing... Here's my current code: package com.nulldev.extremeskyblock.blocks; import com.nulldev.extremeskyblock.util.RegistryHandler; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.client.particle.ParticleManager; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; public class CompactStoneBlock extends Block { public CompactStoneBlock(Material material, Float hardness, Float resistance, SoundType soundType, int harvestLevel, ToolType toolType) { super(Properties.create(material) .hardnessAndResistance(hardness, resistance) .sound(soundType) .harvestLevel(harvestLevel) .harvestTool(toolType)); } @Override public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { ItemEntity stonePebble = new ItemEntity(worldIn, pos.getX(), pos.getY() + 2, pos.getZ(), new ItemStack(RegistryHandler.STONE_PEBBLE.get(), 1)); } } But placing the block and clicking on it does nothing, and Intellij says that its deprecated but I cannot find anywhere what to use instead.
December 7, 20204 yr 1 hour ago, NullDev said: Intellij says that its deprecated You can override it. 1 hour ago, NullDev said: But placing the block and clicking on it does nothing You are creating the ItemEntity but aren't spawning it. Edited December 7, 20204 yr by Danebi
December 12, 20204 yr Author On 12/7/2020 at 4:10 PM, Danebi said: You can override it. You are creating the ItemEntity but aren't spawning it. Thanks that worked!
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.