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:
Aidan C. Brady committed 2014-08-07 21:33:17 -04:00
1 parent 14b40d901a
commit 1fd5e498e8
20 files changed
+99 -54

No files matched your search

+31 -4
View File
@@ -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