mirror of
https://github.com/GTNewHorizons/Avaritia.git
synced 2026-11-21 12:42:13 +00:00
Speed up forge event registration (#56)
This commit is contained in:
1 parent
08d3da2268
commit
8e510cd0fa
1 file changed
+16
-14
@@ -45,7 +45,7 @@ public class ItemAxeInfinity extends ItemAxe {
|
||||
setUnlocalizedName("infinity_axe");
|
||||
setTextureName("avaritia:infinity_axe");
|
||||
setCreativeTab(Avaritia.tab);
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
FMLCommonHandler.instance().bus().register(new EventHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -128,19 +128,6 @@ public class ItemAxeInfinity extends ItemAxe {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTickEnd(TickEvent.WorldTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
int dim = event.world.provider.dimensionId;
|
||||
if (blockSwappers.containsKey(dim)) {
|
||||
List<BlockSwapper> swappers = blockSwappers.get(dim);
|
||||
List<BlockSwapper> swappersSafe = new ArrayList<>(swappers);
|
||||
swappers.clear();
|
||||
for (BlockSwapper s : swappersSafe) if (s != null) s.tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static BlockSwapper addBlockSwapper(World world, EntityPlayer player, ItemStack stack,
|
||||
ChunkCoordinates origCoords, ChunkCoordinates coords, int steps, boolean leaves, boolean force,
|
||||
List<String> posChecked) {
|
||||
@@ -234,4 +221,19 @@ public class ItemAxeInfinity extends ItemAxe {
|
||||
}
|
||||
}
|
||||
|
||||
public static class EventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTickEnd(TickEvent.WorldTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
int dim = event.world.provider.dimensionId;
|
||||
if (blockSwappers.containsKey(dim)) {
|
||||
List<BlockSwapper> swappers = blockSwappers.get(dim);
|
||||
List<BlockSwapper> swappersSafe = new ArrayList<>(swappers);
|
||||
swappers.clear();
|
||||
for (BlockSwapper s : swappersSafe) if (s != null) s.tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user