Posted September 17, 20187 yr I have a custom block that I want to spawn an arrow projectile on its front face every time a player right clicks said block while holding cobblestone. I've been digging around google and most people who wanted to achieve a similar effect seemed to have used the worldIn.spawnEntityInWorld(). I cannot, however, find said method in the world class, and judging from how the forum posts I've referenced are all 2yrs+ old, I'm guessing this method has been removed. Any ideas how I can achieve this in minecraft 1.12? This is the code for my custom block if it helps: public class TrebuchetBlock extends BlockBase{ public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public TrebuchetBlock(String name, Material material) { super(name, material); setSoundType(SoundType.STONE); setHardness(18.0F); setResistance(18.0F); setHarvestLevel("pickaxe",3); setCreativeTab(CreativeTabs.REDSTONE); } public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float side, float hitX, float hitY){ if(worldIn.isRemote) { if(playerIn.getHeldItemMainhand().getItem().equals(Item.getItemFromBlock(Blocks.COBBLESTONE))) { //Insert solution here return true; }else{ return true; } }else{ return false; } } protected BlockStateContainer createBlockState(){ return new BlockStateContainer(this, new IProperty[] {FACING}); } public IBlockState withRotation(IBlockState state, Rotation rot){ return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); } public IBlockState withMirror(IBlockState state, Mirror mirrorIn){ return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); } public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){ return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } public int getMetaFromState(IBlockState state){ int i = 0; i = i | ((EnumFacing)state.getValue(FACING)).getHorizontalIndex(); return i; } public IBlockState getStateFromMeta(int meta){ return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)); } }
September 17, 20187 yr 9 minutes ago, Lumby said: worldIn.spawnEntityInWorld() Its changed from that to World#spawnEntity VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
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.