mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Fix #779 Village apiaries are inactive, lose inventory after reload
This commit is contained in:
1 parent
3a5ccd87cd
commit
63ba9903ea
6 files changed
+29
-20
No files matched your search
@@ -147,13 +147,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
}
|
||||
this.active = active;
|
||||
|
||||
if (!housing.getWorld().isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketBeekeepingLogicActive(housing), housing.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
syncToClient();
|
||||
}
|
||||
|
||||
/* UPDATING */
|
||||
@@ -418,6 +412,14 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
|
||||
/* CLIENT */
|
||||
|
||||
@Override
|
||||
public void syncToClient() {
|
||||
World world = housing.getWorld();
|
||||
if (world != null && !world.isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketBeekeepingLogicActive(housing), world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBeeProgressPercent() {
|
||||
if (beeProgressMax == 0) {
|
||||
|
||||
@@ -31,6 +31,11 @@ public class FakeBeekeepingLogic implements IBeekeepingLogic {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncToClient() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBeeProgressPercent() {
|
||||
return 0;
|
||||
|
||||
@@ -13,6 +13,7 @@ package forestry.apiculture.gadgets;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@@ -59,6 +60,12 @@ public abstract class TileBeeHousing extends TileBase implements IBeeHousing, IC
|
||||
beeLogic.readFromNBT(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
beeLogic.syncToClient();
|
||||
return super.getDescriptionPacket();
|
||||
}
|
||||
|
||||
/* ICLIMATISED */
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
|
||||
@@ -338,6 +338,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
@Override
|
||||
public void formatDescriptionPacket(NBTTagCompound data) {
|
||||
writeToNBT(data);
|
||||
beekeepingLogic.syncToClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ package forestry.core.proxy;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.management.PlayerManager;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
@@ -27,31 +28,24 @@ public class ProxyNetwork {
|
||||
if (packet == null || !(world instanceof WorldServer)) {
|
||||
return;
|
||||
}
|
||||
int x = packet.getPosX();
|
||||
int y = packet.getPosY();
|
||||
int z = packet.getPosZ();
|
||||
|
||||
WorldServer worldServer = (WorldServer) world;
|
||||
int viewDistance = (worldServer.func_73046_m().getConfigurationManager().getViewDistance() + 1) * 16;
|
||||
PlayerManager playerManager = worldServer.getPlayerManager();
|
||||
|
||||
int chunkX = packet.getPosX() >> 4;
|
||||
int chunkZ = packet.getPosZ() >> 4;
|
||||
|
||||
for (Object playerObj : world.playerEntities) {
|
||||
if (playerObj instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) playerObj;
|
||||
|
||||
if (isPlayerInRange(player, viewDistance, x, y, z)) {
|
||||
if (playerManager.isPlayerWatchingChunk(player, chunkX, chunkZ)) {
|
||||
Forestry.packetHandler.sendPacket(packet.getPacket(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isPlayerInRange(EntityPlayerMP player, int viewDistance, int x, int y, int z) {
|
||||
double distX = player.posX - x;
|
||||
double distY = player.posY - y;
|
||||
double distZ = player.posZ - z;
|
||||
return (distX * distX) + (distY * distY) + (distZ * distZ) < (viewDistance * viewDistance);
|
||||
}
|
||||
|
||||
public void sendToPlayer(ForestryPacket packet, EntityPlayer entityplayer) {
|
||||
if (!(entityplayer instanceof EntityPlayerMP) || (entityplayer instanceof FakePlayer)) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user