|
1 | 1 | package net.infstudio.goki.common.handlers; |
2 | 2 |
|
3 | 3 | import net.infstudio.goki.api.stat.Stats; |
| 4 | +import net.infstudio.goki.common.config.GokiConfig; |
| 5 | +import net.infstudio.goki.common.network.GokiPacketHandler; |
| 6 | +import net.infstudio.goki.common.network.message.S2CSyncAll; |
4 | 7 | import net.infstudio.goki.common.utils.DataHelper; |
5 | 8 | import net.minecraft.entity.EntityLivingBase; |
6 | 9 | import net.minecraft.entity.MoverType; |
7 | 10 | import net.minecraft.entity.SharedMonsterAttributes; |
8 | 11 | import net.minecraft.entity.ai.attributes.AttributeModifier; |
9 | 12 | import net.minecraft.entity.ai.attributes.IAttributeInstance; |
10 | 13 | import net.minecraft.entity.player.EntityPlayer; |
| 14 | +import net.minecraft.entity.player.EntityPlayerMP; |
11 | 15 | import net.minecraft.tileentity.TileEntity; |
12 | 16 | import net.minecraft.tileentity.TileEntityFurnace; |
13 | 17 | import net.minecraft.util.math.BlockPos; |
14 | 18 | import net.minecraft.util.math.MathHelper; |
| 19 | +import net.minecraftforge.fml.common.FMLCommonHandler; |
15 | 20 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; |
16 | 21 | import net.minecraftforge.fml.common.gameevent.TickEvent; |
| 22 | +import net.minecraftforge.fml.relauncher.Side; |
| 23 | +import net.minecraftforge.fml.relauncher.SideOnly; |
17 | 24 |
|
18 | 25 | import java.lang.reflect.Field; |
19 | 26 | import java.util.ArrayList; |
20 | 27 | import java.util.UUID; |
| 28 | +import java.util.concurrent.atomic.AtomicInteger; |
21 | 29 |
|
22 | 30 | public class TickHandler { |
23 | 31 | public static final UUID knockbackResistanceID = UUID.randomUUID(); |
24 | 32 | public static final UUID stealthSpeedID = UUID.randomUUID(); |
25 | 33 | public static final UUID swimSpeedID = UUID.randomUUID(); |
26 | 34 |
|
| 35 | + public static AtomicInteger tickTimer = new AtomicInteger(); |
| 36 | + |
27 | 37 | @SubscribeEvent |
28 | 38 | public void playerTick(TickEvent.PlayerTickEvent event) { |
29 | 39 | if (event.phase == TickEvent.Phase.START) { // Due to issue #32 |
@@ -55,6 +65,21 @@ public void playerTick(TickEvent.PlayerTickEvent event) { |
55 | 65 | } |
56 | 66 | } |
57 | 67 |
|
| 68 | + @SubscribeEvent |
| 69 | + @SideOnly(Side.SERVER) |
| 70 | + public void serverTick(TickEvent.ServerTickEvent event) { |
| 71 | + if (event.phase == TickEvent.Phase.END) { |
| 72 | + if (tickTimer.get() == GokiConfig.syncTicks) { |
| 73 | + tickTimer.lazySet(0); |
| 74 | + for (EntityPlayerMP player : FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayers()) { |
| 75 | + GokiPacketHandler.CHANNEL.sendTo(new S2CSyncAll(player), player); |
| 76 | + } |
| 77 | + } else { |
| 78 | + tickTimer.getAndIncrement(); |
| 79 | + } |
| 80 | + } |
| 81 | + } |
| 82 | + |
58 | 83 | public static boolean isJumping(EntityLivingBase livingBase) { |
59 | 84 | Field field = null; |
60 | 85 | try { |
|
0 commit comments