lightningdragonx5 Posted January 17, 2019 Share Posted January 17, 2019 (edited) So basically I'm trying to make a leaf block with fruit on it that, when right clicked: 1. gives the player the fruit item, or drops it at their feet if their inventory is full. Not exactly sure how to do that nicely. Directly adding it to the player inventory (player.inventory.add) resulted in some really weird stuff going on. Something tells me that's not a method I should be using. Spawning it as an EntityItem in the world spawns it as a ghost item that can't be picked up even if I stand on it, or drop other normal versions of the item right next to the ghost items. It also isn't destroyed by lava. 2. changes the leaf block into the version that doesn't have fruit (note that said version is a different block altogether). For this I tried using worldIn.setBlockState but that doesn't actually do anything - the block blinks with the texture of the fruit-less version for a split second and then immediately turns back into the fruit version, which can be right-clicked once again for the same result. How would I go about doing these? Edited January 17, 2019 by lightningdragonx5 Quote Link to comment Share on other sites More sharing options...
Toma™ Posted January 17, 2019 Share Posted January 17, 2019 About the ghost item - Are you spawning it on server? This applies for the other methods you have tried too Quote Link to comment Share on other sites More sharing options...
MichaelVitrio Posted January 17, 2019 Share Posted January 17, 2019 4 hours ago, lightningdragonx5 said: Spawning it as an EntityItem in the world spawns it as a ghost item that can't be picked up even if I stand on it Make sure you call World#isRemote to check whether you're working with a client "dummy" world. Normally you would do this kind of stuff on the server world, i.e. something like if(!world.isRemote()) . Quote Link to comment Share on other sites More sharing options...
lightningdragonx5 Posted January 17, 2019 Author Share Posted January 17, 2019 (edited) 15 hours ago, MichaelVitrio said: Make sure you call World#isRemote to check whether you're working with a client "dummy" world. Normally you would do this kind of stuff on the server world, i.e. something like if(!world.isRemote()) . I did. Below is my current code, what could I be doing wrong? @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { return false; } System.out.println(this.fruit); EntityItem droppedFruit = new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(this.fruit, 1)); worldIn.spawnEntity(droppedFruit); worldIn.setBlockState(pos, this.baseLeaves.getDefaultState()); return true; } Edited January 17, 2019 by lightningdragonx5 Quote Link to comment Share on other sites More sharing options...
MichaelVitrio Posted January 18, 2019 Share Posted January 18, 2019 4 hours ago, lightningdragonx5 said: I did. Below is my current code, what could I be doing wrong? Your code goes inside the if block since worldIn.isRemote() returns true if it's a client world. Quote Link to comment Share on other sites More sharing options...
lightningdragonx5 Posted January 18, 2019 Author Share Posted January 18, 2019 thanks, fixed Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.