Hi. I'm making a mod with a block that pretty much acts as TNT without the entity. I have it working how I want explosion wise, but I can't figure out how to add a 40 tick delay like normal TNT has. I'm not very experienced in JS or modding in 1.14 so please explain this to me simply.
I don't have any experience with newer versions or Forge (I mod 1.6.4 since that is what I play on) but you have to schedule a block update; for example, the following code makes water and lava flow after being placed (the last parameter is the number of ticks, which in your case can just be 40); in your case you'd schedule an update in onBlockActivated, with the updateTick method deleting the block and creating the explosion (FWIW, you should set the block to air before creating the explosion, as otherwise it will block some of its effect):
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
super.onBlockAdded(par1World, par2, par3, par4);
if (par1World.getBlockId(par2, par3, par4) == this.blockID)
{
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
}
}
Note that you do not want your block to receive random ticks, as it will otherwise randomly explode (by default this is set to false so updateTick will only be called if a block update is scheduled)
I think you definitely put me on the right track. I was able to make it work ticking randomly, however I cannot get a manual tick. It seems to skip right over the tick function as the durability on flint and steel still goes down. Does anything seem wrong with this code? (some function names differ from yours, but i'm 95% sure they do the same thing)
You want to use "World.getPendingBlockTicks().scheduleTick()" (from here) to schedule a block update; "notifyBlockUpdate" only tells neighboring blocks that the block in question has triggered an update (this appears to be what used to be called "notifyBlocksOfNeighborChange").
Hi. I'm making a mod with a block that pretty much acts as TNT without the entity. I have it working how I want explosion wise, but I can't figure out how to add a 40 tick delay like normal TNT has. I'm not very experienced in JS or modding in 1.14 so please explain this to me simply.
full class code:
I don't have any experience with newer versions or Forge (I mod 1.6.4 since that is what I play on) but you have to schedule a block update; for example, the following code makes water and lava flow after being placed (the last parameter is the number of ticks, which in your case can just be 40); in your case you'd schedule an update in onBlockActivated, with the updateTick method deleting the block and creating the explosion (FWIW, you should set the block to air before creating the explosion, as otherwise it will block some of its effect):
Note that you do not want your block to receive random ticks, as it will otherwise randomly explode (by default this is set to false so updateTick will only be called if a block update is scheduled)
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
I think you definitely put me on the right track. I was able to make it work ticking randomly, however I cannot get a manual tick. It seems to skip right over the tick function as the durability on flint and steel still goes down. Does anything seem wrong with this code? (some function names differ from yours, but i'm 95% sure they do the same thing)
You want to use "World.getPendingBlockTicks().scheduleTick()" (from here) to schedule a block update; "notifyBlockUpdate" only tells neighboring blocks that the block in question has triggered an update (this appears to be what used to be called "notifyBlocksOfNeighborChange").
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?
Oh wow, thank you so much. It's working wonderfully now.