Posted December 9, 201311 yr I have an Block that extends BlockCrops. Is it very hard to check the dimension, say "world.provider.getDimensionID" and if it's not in, say, the nether, make it drop as if it was killed by the player? Could someone help me with this? “Since when did you start modding?” “Last night"
December 9, 201311 yr Hi It's not difficult. BlockLeaves does something similar if the leaves are unsupported. in updateTick: if (!par1World.isRemote) --> this.removeLeaves this.removeLeaves: this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0); par1World.setBlockToAir(par2, par3, par4); And also need to set this.setTickRandomly(true); in the constructor, so that updateTick gets called occasionally. -TGG
December 9, 201311 yr Author I’m fairly new to modding, could you please explain to me more thoroughly? I have a basic tick handler, but I do not know what to do from there. “Since when did you start modding?” “Last night"
December 10, 201311 yr You dont need a tickhandler. Look here for the code that TGG suggested: http://pastebin.com/p4naGZA0 Though Im unsure why you need to make sure you are calling it on the server, since we also need the visual update? I am fairly new to Java and modding, so my answers are not always 100% correct. Sorry for that!
December 10, 201311 yr Hi Thanks EP :-) // Im not quite sure why you only would want this to get done on the server side // Since we need the visual as well? I think the vanilla code does that because changing the block and dropping the item on the server automatically syncs with the clients, so it's not necessary to do it on the client as well. Sometimes it is important to do something on the server only, otherwise you get "ghost" items on the client, but in this case I think the setBlock and Drop methods check for that. So I reckon it would probably work fine either way. -TGG
December 14, 201311 yr Author It works. Thanks, I now know how to do this stuff. This is also how minecraft Grass spreads, right? On random tick? “Since when did you start modding?” “Last night"
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.