NightBlood Posted July 19, 2019 Posted July 19, 2019 (edited) Hey, Im kinda new to forge modding and I was wondering which is the best way to implement a timer within a HarvestDropsEvent and a RightClickItem Events Ive been using a java.util.TimerTask but it has had ticks sync issues. I know this might be something simple but I havent been able to figure that out, thanks in advance. Edit: Code added. I just need the EntityFallingBlock to spawn every X seconds without using a java.util.TimerTask the way a Bukkit.getScheduler().sheduleSyncRepeatingTask for Spigot does. Error: Description: Exception in server tick loop java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextNode(HashMap.java:1442) at java.util.HashMap$KeyIterator.next(HashMap.java:1466) at net.minecraft.entity.EntityTracker.tick(EntityTracker.java:295) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:854) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Thread.java:748) Code: int i2 = 0; int max = 5; timer.schedule(new TimerTask() { @Override public void run() { if (i2 >= max) this.cancel(); if (i2 >= max) return; i2++; EntityFallingBlock tnt = new EntityFallingBlock(world, pos.getX()+0.5, pos.getY()+10, pos.getZ()+0.5, Blocks.TNT.getDefaultState()); tnt.fallTime = 1; world.spawnEntity(tnt); } }, 0, 500); Edited July 19, 2019 by NightBlood Information added Quote
Draco18s Posted July 19, 2019 Posted July 19, 2019 Don't modify a collection that you are itterating over. Also. Post your code. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Draco18s Posted July 20, 2019 Posted July 20, 2019 Don't use timer tasks. Use an event handler, subscribe to the world tick event, and count ticks. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.