Posted June 24, 201411 yr I have made a block that upon right click drops an item. I wish to implement functionality so that the block can only drop the item once per day. in my block class that extends my custom block class which then extends Minecraft's Block class I wrote the code below to implement the item dropping when the block is right clicked. It works as intended however I am now wishing to add a timed item drop aspect. I was thinking of somehow getting the world time at the time of the right click and equating it to a variable maybe called timeOfBlockClicked and having while or if statements that would forbid the item to drop if the block is right clicked until the World time was again greater than or equal to the timeOfBlockClicked at which point the timeOfBlockClicked variable would be reset to 0 and a new timeOfBlockClicked would be set again and a new item could drop. I am unsure how to get the world time though and how to save the time. @Override @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) { { if(world.isRemote == false)//world.isRemote == false - has to be false otherwise you do it twice once for server and once for client { ItemStack myItemStack = new ItemStack(MyMod.customItem, 1); EntityItem entityitem = new EntityItem(world, x, y, z, myItemStack); entityitem.delayBeforeCanPickup = 10; world.spawnEntityInWorld(entityitem); } return false; } }
June 24, 201411 yr Use a tile entity and store the last day it was clicked in nbt. Then if day != last day clicked then spawn your item. also, instead of world.isRemote == false use !world.isRemote. And finally, I would recommend making a method to spawn items into the world, for organization.
June 24, 201411 yr Author How would I implement the storing of the last day that it was clicked this is the part I am unsure about
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.