further optimization for large blueprints handling
This commit is contained in:
parent
854dab6c32
commit
d38ab99d89
3 changed files with 36 additions and 32 deletions
|
@ -182,6 +182,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
|
|||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
ItemStack result;
|
||||
|
||||
if (items[i] == null) {
|
||||
result = null;
|
||||
} else if (items[i].stackSize > j) {
|
||||
|
@ -192,7 +193,9 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
|
|||
result = tmp;
|
||||
}
|
||||
|
||||
initializeComputing();
|
||||
if (i == 0) {
|
||||
initializeComputing();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -201,7 +204,9 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
|
|||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
items[i] = itemstack;
|
||||
|
||||
initializeComputing();
|
||||
if (i == 0) {
|
||||
initializeComputing();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -302,6 +307,10 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
|
|||
}
|
||||
|
||||
private void initializeComputing() {
|
||||
if (getWorld().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!box.isInitialized()) {
|
||||
return;
|
||||
} else if (blockScanner == null) {
|
||||
|
@ -323,20 +332,14 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
|
|||
|
||||
}
|
||||
} else {
|
||||
if (items[0] == null || !(items[0].getItem() instanceof ItemBlueprint)) {
|
||||
blockScanner = null;
|
||||
writingBlueprint = null;
|
||||
writingContext = null;
|
||||
}
|
||||
blockScanner = null;
|
||||
writingBlueprint = null;
|
||||
writingContext = null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getComputingProgressScaled(int scale) {
|
||||
if (blockScanner == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return (int) ((float) computingTime / (float) 100 * scale);
|
||||
}
|
||||
return (int) ((float) computingTime / (float) 100 * scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,18 +8,6 @@
|
|||
*/
|
||||
package buildcraft.builders.gui;
|
||||
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.builders.TileArchitect;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.network.PacketPayload;
|
||||
import buildcraft.core.network.PacketPayloadStream;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
@ -27,6 +15,12 @@ import net.minecraft.util.ResourceLocation;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import buildcraft.builders.TileArchitect;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class GuiArchitect extends GuiBuildCraft {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/template_gui.png");
|
||||
|
|
|
@ -30,6 +30,8 @@ import buildcraft.transport.Pipe;
|
|||
*/
|
||||
public class RPCHandler {
|
||||
|
||||
public static int MAX_PACKET_SIZE = 30 * 1024;
|
||||
|
||||
private static Map <String, RPCHandler> handlers =
|
||||
new TreeMap <String, RPCHandler> ();
|
||||
|
||||
|
@ -99,7 +101,7 @@ public class RPCHandler {
|
|||
if (packet != null) {
|
||||
ArrayList<PacketRPCTile> packets = packet.breakIntoSmallerPackets(30 * 1024);
|
||||
|
||||
for (PacketRPCTile p : packets) {
|
||||
for (PacketRPCTile p : packet.breakIntoSmallerPackets(MAX_PACKET_SIZE)) {
|
||||
BuildCraftCore.instance.sendToServer(p);
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +115,9 @@ public class RPCHandler {
|
|||
PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
|
||||
|
||||
if (packet != null) {
|
||||
BuildCraftCore.instance.sendToPlayer(player, packet);
|
||||
for (PacketRPCTile p : packet.breakIntoSmallerPackets(MAX_PACKET_SIZE)) {
|
||||
BuildCraftCore.instance.sendToPlayer(player, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,13 +137,16 @@ public class RPCHandler {
|
|||
PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals);
|
||||
|
||||
if (packet != null) {
|
||||
for (Object o : tile.getWorldObj().playerEntities) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) o;
|
||||
for (PacketRPCTile p : packet
|
||||
.breakIntoSmallerPackets(MAX_PACKET_SIZE)) {
|
||||
for (Object o : tile.getWorldObj().playerEntities) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) o;
|
||||
|
||||
if (Math.abs(player.posX - tile.xCoord) <= maxDistance
|
||||
&& Math.abs(player.posY - tile.yCoord) <= maxDistance
|
||||
&& Math.abs(player.posZ - tile.zCoord) <= maxDistance) {
|
||||
BuildCraftCore.instance.sendToPlayer(player, packet);
|
||||
if (Math.abs(player.posX - tile.xCoord) <= maxDistance
|
||||
&& Math.abs(player.posY - tile.yCoord) <= maxDistance
|
||||
&& Math.abs(player.posZ - tile.zCoord) <= maxDistance) {
|
||||
BuildCraftCore.instance.sendToPlayer(player, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue