mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Resync hourglass whenever it flips, hopefully helps with desyncs
This commit is contained in:
2 files changed
+22
-8
No files matched your search
@@ -10,24 +10,37 @@
|
||||
*/
|
||||
package vazkii.botania.api.internal;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.server.management.PlayerManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class VanillaPacketDispatcher {
|
||||
|
||||
public static void dispatchTEToNearbyPlayers(TileEntity tile) {
|
||||
World world = tile.getWorld();
|
||||
List players = world.playerEntities;
|
||||
for(Object player : players)
|
||||
if(player instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP mp = (EntityPlayerMP) player;
|
||||
if(pointDistancePlane(mp.posX, mp.posZ, tile.getPos().getX() + 0.5, tile.getPos().getZ() + 0.5) < 64)
|
||||
((EntityPlayerMP) player).playerNetServerHandler.sendPacket(tile.getDescriptionPacket());
|
||||
if(tile.getWorld() instanceof WorldServer) {
|
||||
WorldServer ws = ((WorldServer) tile.getWorld());
|
||||
PlayerManager.PlayerInstance chunk = ws.getPlayerChunkMap().getEntry(tile.getPos().getX() >> 4, tile.getPos().getZ() >> 4);
|
||||
|
||||
if(chunk == null)
|
||||
return;
|
||||
|
||||
for (EntityPlayer player : ws.playerEntities) {
|
||||
EntityPlayerMP playerMP = ((EntityPlayerMP) player);
|
||||
|
||||
if (playerMP.getDistanceSq(tile.getPos()) < 64 * 64
|
||||
&& chunk.containsPlayer(playerMP)) {
|
||||
playerMP.playerNetServerHandler.sendPacket(tile.getDescriptionPacket());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void dispatchTEToNearbyPlayers(World world, BlockPos pos) {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class TileHourglass extends TileSimpleInventory {
|
||||
private static final String TAG_LOCK = "lock";
|
||||
private static final String TAG_MOVE = "move";
|
||||
|
||||
int time = 0;
|
||||
private int time = 0;
|
||||
public float timeFraction = 0F;
|
||||
public boolean flip = false;
|
||||
public int flipTicks = 0;
|
||||
@@ -51,6 +51,7 @@ public class TileHourglass extends TileSimpleInventory {
|
||||
flipTicks = 4;
|
||||
if (!worldObj.isRemote) {
|
||||
worldObj.setBlockState(getPos(), worldObj.getBlockState(getPos()).withProperty(BotaniaStateProps.POWERED, true), 1 | 2);
|
||||
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
|
||||
worldObj.scheduleUpdate(pos, getBlockType(), getBlockType().tickRate(worldObj));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user