mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Major packet improvements - trying to get on the good side of server owners. More to come.
Instead of sending to all players in a dimension or within a defined range, packets will now only be sent to players who have the chunk loaded that the packet is being sent from on the server.
This commit is contained in:
1 parent
14b40d901a
commit
1fd5e498e8
20 files changed
+99
-54
No files matched your search
@@ -1,6 +1,7 @@
|
||||
package mekanism.api;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class Range4D
|
||||
{
|
||||
@@ -31,15 +32,41 @@ public class Range4D
|
||||
yMin = 0;
|
||||
zMin = chunk.zCoord*16;
|
||||
xMax = xMin+16;
|
||||
yMax = 255;
|
||||
zMax = zMin+16;
|
||||
}
|
||||
|
||||
public static Range4D getLoadedChunks(MinecraftServer server)
|
||||
public Range4D(Coord4D coord)
|
||||
{
|
||||
int range = server.getConfigurationManager().getViewDistance();
|
||||
xMin = coord.xCoord;
|
||||
yMin = coord.yCoord;
|
||||
zMin = coord.zCoord;
|
||||
|
||||
xMax = coord.xCoord+1;
|
||||
yMax = coord.yCoord+1;
|
||||
zMax = coord.zCoord+1;
|
||||
}
|
||||
|
||||
public static Range4D getChunkRange(EntityPlayer player)
|
||||
{
|
||||
int radius = FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().getViewDistance();
|
||||
|
||||
return new Range4D(new Chunk3D(player)).expandChunks(radius);
|
||||
}
|
||||
|
||||
public Range4D expandChunks(int chunks)
|
||||
{
|
||||
xMin -= chunks*16;
|
||||
xMax += chunks*16;
|
||||
zMin -= chunks*16;
|
||||
zMax += chunks*16;
|
||||
|
||||
return null;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean intersects(Range4D range)
|
||||
{
|
||||
return (xMax+1 - 1.E-05D > range.xMin) && (range.xMax+1 - 1.E-05D > xMin) && (yMax+1 - 1.E-05D > range.yMin) && (range.yMax+1 - 1.E-05D > yMin) && (zMax+1 - 1.E-05D > range.zMin) && (range.zMax+1 - 1.E-05D > zMin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,10 +12,9 @@ import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IClientTicker;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.api.Range4D;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@@ -31,7 +30,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
|
||||
private List<DelayQueue> updateQueue = new ArrayList<DelayQueue>();
|
||||
|
||||
protected AxisAlignedBB packetRange = null;
|
||||
protected Range4D packetRange = null;
|
||||
|
||||
protected int ticksSinceCreate = 0;
|
||||
|
||||
@@ -95,7 +94,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
refresh();
|
||||
}
|
||||
|
||||
public AxisAlignedBB getPacketRange()
|
||||
public Range4D getPacketRange()
|
||||
{
|
||||
if(packetRange == null)
|
||||
{
|
||||
@@ -115,7 +114,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
return transmitters.iterator().next().getTile().getWorldObj();
|
||||
}
|
||||
|
||||
protected AxisAlignedBB genPacketRange()
|
||||
protected Range4D genPacketRange()
|
||||
{
|
||||
if(getSize() == 0)
|
||||
{
|
||||
@@ -144,14 +143,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
if(coord.zCoord > maxZ) maxZ = coord.zCoord;
|
||||
}
|
||||
|
||||
minX -= 40;
|
||||
minY -= 40;
|
||||
minZ -= 40;
|
||||
maxX += 40;
|
||||
maxY += 40;
|
||||
maxZ += 40;
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
return new Range4D(minX, minY, minZ, maxX, maxY, maxZ, getWorld().provider.dimensionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user