mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Fix #757 Particles rendering in other dimensions
This commit is contained in:
1 parent
aa47599278
commit
e04bbcba84
15 files changed
+32
-31
No files matched your search
@@ -148,7 +148,7 @@ public class BeekeepingLogic implements IBeekeepingLogic, IStreamable {
|
||||
this.active = active;
|
||||
|
||||
if (!housing.getWorld().isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketBeekeepingLogicActive(housing));
|
||||
Proxies.net.sendNetworkPacket(new PacketBeekeepingLogicActive(housing), housing.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
@Override
|
||||
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(this);
|
||||
Proxies.net.sendNetworkPacket(packet);
|
||||
Proxies.net.sendNetworkPacket(packet, worldObj);
|
||||
|
||||
if (oldAccess == EnumAccess.SHARED || newAccess == EnumAccess.SHARED) {
|
||||
// pipes connected to this need to update
|
||||
|
||||
@@ -125,7 +125,7 @@ public abstract class TileAlvearyClimatiser extends TileAlveary implements IEner
|
||||
if (worldObj.isRemote) {
|
||||
worldObj.func_147479_m(xCoord, yCoord, zCoord);
|
||||
} else {
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ public class TileAlvearySwarmer extends TileAlvearyWithGui implements ISidedInve
|
||||
this.active = active;
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public class TileFruitPod extends TileEntity implements IFruitBearer, IStreamabl
|
||||
}
|
||||
|
||||
private void sendNetworkUpdateRipening() {
|
||||
Proxies.net.sendNetworkPacket(new PacketRipeningUpdate(this));
|
||||
Proxies.net.sendNetworkPacket(new PacketRipeningUpdate(this), worldObj);
|
||||
}
|
||||
|
||||
public void fromRipeningPacket(int newMaturity) {
|
||||
|
||||
@@ -321,7 +321,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
}
|
||||
|
||||
public void sendNetworkUpdate() {
|
||||
Proxies.net.sendNetworkPacket(new PacketTileStream(this));
|
||||
Proxies.net.sendNetworkPacket(new PacketTileStream(this), worldObj);
|
||||
}
|
||||
|
||||
private void sendNetworkUpdateRipening() {
|
||||
@@ -332,7 +332,7 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
colourFruits = newColourFruits;
|
||||
|
||||
PacketRipeningUpdate ripeningUpdate = new PacketRipeningUpdate(this);
|
||||
Proxies.net.sendNetworkPacket(ripeningUpdate);
|
||||
Proxies.net.sendNetworkPacket(ripeningUpdate, worldObj);
|
||||
}
|
||||
|
||||
private static final short hasFruitFlag = 1;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class TileStairs extends TileEntity implements IStreamable {
|
||||
}
|
||||
|
||||
public void sendNetworkUpdate() {
|
||||
Proxies.net.sendNetworkPacket(new PacketTileStream(this));
|
||||
Proxies.net.sendNetworkPacket(new PacketTileStream(this), worldObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,8 +27,6 @@ public class Defaults {
|
||||
public static final int FLAG_BLOCK_UPDATE = 1;
|
||||
public static final int FLAG_BLOCK_SYNCH = 2;
|
||||
|
||||
public static final int NET_MAX_UPDATE_DISTANCE = 50;
|
||||
|
||||
public static final int BUCKET_VOLUME = 1000;
|
||||
public static final int FLUID_PER_HONEY_DROP = 100;
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ public abstract class Engine extends TileBase implements IEnergyConnection, IAct
|
||||
this.active = active;
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this));
|
||||
Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
if (added) {
|
||||
setInventorySlotContents(SLOT_ANALYZE, null);
|
||||
PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay());
|
||||
Proxies.net.sendNetworkPacket(packet);
|
||||
Proxies.net.sendNetworkPacket(packet, worldObj);
|
||||
}
|
||||
|
||||
getErrorLogic().setCondition(!added, EnumErrorCode.NOSPACE);
|
||||
@@ -186,7 +186,7 @@ public class TileAnalyzer extends TilePowered implements ISidedInventory, ILiqui
|
||||
setInventorySlotContents(SLOT_ANALYZE, inputStack);
|
||||
slot.setStackInSlot(null);
|
||||
PacketItemStackDisplay packet = new PacketItemStackDisplay(this, getIndividualOnDisplay());
|
||||
Proxies.net.sendNetworkPacket(packet);
|
||||
Proxies.net.sendNetworkPacket(packet, worldObj);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ public abstract class TileForestry extends TileEntity implements IStreamable, IE
|
||||
/* INetworkedEntity */
|
||||
public final void sendNetworkUpdate() {
|
||||
PacketTileStream packet = new PacketTileStream(this);
|
||||
Proxies.net.sendNetworkPacket(packet);
|
||||
Proxies.net.sendNetworkPacket(packet, worldObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -209,7 +209,7 @@ public class ProxyCommon {
|
||||
}
|
||||
|
||||
public void playSoundFX(World world, int x, int y, int z, Block block) {
|
||||
Proxies.net.sendNetworkPacket(new PacketFXSignal(PacketFXSignal.SoundFXType.LEAF, x, y, z, block, 0));
|
||||
Proxies.net.sendNetworkPacket(new PacketFXSignal(PacketFXSignal.SoundFXType.LEAF, x, y, z, block, 0), world);
|
||||
}
|
||||
|
||||
public void playSoundFX(World world, int x, int y, int z, String sound, float volume, float pitch) {
|
||||
@@ -244,7 +244,7 @@ public class ProxyCommon {
|
||||
public void sendFXSignal(PacketFXSignal.VisualFXType visualFX, PacketFXSignal.SoundFXType soundFX, World world, int xCoord, int yCoord, int zCoord,
|
||||
Block block, int i) {
|
||||
if (Proxies.common.isSimulating(world)) {
|
||||
Proxies.net.sendNetworkPacket(new PacketFXSignal(visualFX, soundFX, xCoord, yCoord, zCoord, block, i));
|
||||
Proxies.net.sendNetworkPacket(new PacketFXSignal(visualFX, soundFX, xCoord, yCoord, zCoord, block, i), world);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,40 +13,43 @@ package forestry.core.proxy;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
|
||||
import forestry.Forestry;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.ILocatedPacket;
|
||||
|
||||
public class ProxyNetwork {
|
||||
|
||||
public <P extends ForestryPacket & ILocatedPacket> void sendNetworkPacket(P packet) {
|
||||
if (packet == null) {
|
||||
public <P extends ForestryPacket & ILocatedPacket> void sendNetworkPacket(P packet, World world) {
|
||||
if (packet == null || !(world instanceof WorldServer)) {
|
||||
return;
|
||||
}
|
||||
int x = packet.getPosX();
|
||||
int y = packet.getPosY();
|
||||
int z = packet.getPosZ();
|
||||
|
||||
World[] worlds = DimensionManager.getWorlds();
|
||||
for (World world : worlds) {
|
||||
for (int j = 0; j < world.playerEntities.size(); j++) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) world.playerEntities.get(j);
|
||||
if (isPlayerInRange(player, x, y, z)) {
|
||||
WorldServer worldServer = (WorldServer) world;
|
||||
int viewDistance = (worldServer.func_73046_m().getConfigurationManager().getViewDistance() + 1) * 16;
|
||||
|
||||
for (Object playerObj : world.playerEntities) {
|
||||
if (playerObj instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) playerObj;
|
||||
|
||||
if (isPlayerInRange(player, viewDistance, x, y, z)) {
|
||||
Forestry.packetHandler.sendPacket(packet.getPacket(), player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isPlayerInRange(EntityPlayerMP player, int x, int y, int z) {
|
||||
return Math.abs(player.posX - x) <= Defaults.NET_MAX_UPDATE_DISTANCE &&
|
||||
Math.abs(player.posY - y) <= Defaults.NET_MAX_UPDATE_DISTANCE &&
|
||||
Math.abs(player.posZ - z) <= Defaults.NET_MAX_UPDATE_DISTANCE;
|
||||
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) {
|
||||
|
||||
@@ -334,7 +334,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
@Override
|
||||
public void onSwitchAccess(EnumAccess oldAccess, EnumAccess newAccess) {
|
||||
PacketGuiUpdate packet = new PacketGuiUpdate(this);
|
||||
Proxies.net.sendNetworkPacket(packet);
|
||||
Proxies.net.sendNetworkPacket(packet, worldObj);
|
||||
|
||||
if (oldAccess == EnumAccess.SHARED || newAccess == EnumAccess.SHARED) {
|
||||
// pipes connected to this need to update
|
||||
|
||||
@@ -265,7 +265,7 @@ public class MachineTrader extends TileBase {
|
||||
String newAddressName = newAddress.getName();
|
||||
if (newAddressName != null && newAddressName.equals(addressName)) {
|
||||
PacketTraderAddress packetResponse = new PacketTraderAddress(this, addressName);
|
||||
Proxies.net.sendNetworkPacket(packetResponse);
|
||||
Proxies.net.sendNetworkPacket(packetResponse, worldObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user