From 3518db70937baff0de83a7ee8ff04a3c7e6f18e9 Mon Sep 17 00:00:00 2001 From: davboecki Date: Thu, 20 Sep 2012 00:41:16 +0200 Subject: [PATCH 01/18] Fix ItemStack merging of ItemStacks with different NBTTagCompount information. --- common/buildcraft/core/inventory/TransactorSimple.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/buildcraft/core/inventory/TransactorSimple.java b/common/buildcraft/core/inventory/TransactorSimple.java index 08e2a842..11c608c9 100644 --- a/common/buildcraft/core/inventory/TransactorSimple.java +++ b/common/buildcraft/core/inventory/TransactorSimple.java @@ -40,7 +40,7 @@ public class TransactorSimple extends Transactor { if(inventory.getStackInSlot(i) == null) continue; - if(!inventory.getStackInSlot(i).isItemEqual(stack)) + if(!inventory.getStackInSlot(i).isItemEqual(stack) || !ItemStack.func_77970_a(inventory.getStackInSlot(i), stack)) continue; if(inventory.getStackInSlot(i).stackSize >= inventory.getStackInSlot(i).getMaxStackSize()) @@ -75,7 +75,7 @@ public class TransactorSimple extends Transactor { return remaining; } - if(!inventory.getStackInSlot(slot).isItemEqual(stack)) + if(!inventory.getStackInSlot(slot).isItemEqual(stack) || !ItemStack.func_77970_a(inventory.getStackInSlot(slot), stack)) return 0; int space = inventory.getStackInSlot(slot).getMaxStackSize() - inventory.getStackInSlot(slot).stackSize; From e7bd894e151f5d238193e3f091161ce55fca7dd7 Mon Sep 17 00:00:00 2001 From: Xhamolk Date: Sat, 22 Sep 2012 12:15:48 -0600 Subject: [PATCH 02/18] Fixes pipes connecting improperly Pipes now check if IPipeConnection allows the connection. --- common/buildcraft/transport/Pipe.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index 8de03432..0525d9ad 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -16,6 +16,7 @@ import java.util.Random; import buildcraft.BuildCraftTransport; import buildcraft.api.core.Orientations; +import buildcraft.api.core.Position; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.Action; import buildcraft.api.gates.ActionManager; @@ -26,6 +27,7 @@ import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.Trigger; import buildcraft.api.gates.TriggerParameter; import buildcraft.api.transport.IPipe; +import buildcraft.api.transport.IPipeConnection; import buildcraft.core.IDropControlInventory; import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.triggers.ActionRedstoneOutput; @@ -131,6 +133,11 @@ public abstract class Pipe implements IPipe, IDropControlInventory { } public boolean isPipeConnected(TileEntity tile) { + if( tile instanceof IPipeConnection ){ + Orientations or = Utils.get3dOrientation(new Position(this.container), new Position(tile)); + if( !((IPipeConnection) tile).isPipeConnected(or) ) + return false; + } return logic.isPipeConnected(tile) && transport.isPipeConnected(tile); } From 07cca7ad0500326305a945a48b74f8f154730d60 Mon Sep 17 00:00:00 2001 From: Xhamolk Date: Sat, 22 Sep 2012 12:23:42 -0600 Subject: [PATCH 03/18] Update common/buildcraft/transport/PipeTransportItems.java --- .../buildcraft/transport/PipeTransportItems.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index acd54186..0da2f0d1 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -41,6 +41,7 @@ import net.minecraft.src.NBTTagCompound; import net.minecraft.src.NBTTagList; import net.minecraft.src.Packet; import net.minecraft.src.TileEntity; +import net.minecraftforge.common.ISidedInventory; public class PipeTransportItems extends PipeTransport { @@ -145,13 +146,12 @@ public class PipeTransportItems extends PipeTransport { if (!Utils.checkPipesConnections(entity, container)) return false; + if (entity instanceof TileGenericPipe) + if (container.pipe.transport instanceof PipeTransportItems) + return container.pipe.transport.inputOpen(o); if (entity instanceof IPipeEntry) - return true; - else if (entity instanceof TileGenericPipe) { - TileGenericPipe pipe = (TileGenericPipe) entity; - - return pipe.pipe.transport instanceof PipeTransportItems; - } else if (entity instanceof IInventory) + return ((IPipeEntry) entity).acceptItems(); + if (entity instanceof IInventory) if(Transactor.getTransactorFor(entity).add(item.getItemStack(), o.reverse(), false).stackSize > 0) return true; @@ -437,6 +437,10 @@ public class PipeTransportItems extends PipeTransport { @Override public boolean isPipeConnected(TileEntity tile) { + if( tile instanceof ISidedInventory ){ + Orientations or = Utils.get3dOrientation(new Position(container), new Position(tile)); + return ((ISidedInventory) tile).getSizeInventorySide(or.toDirection()) > 0; + } return tile instanceof TileGenericPipe || tile instanceof IPipeEntry || tile instanceof ISpecialInventory From 61fd692f77235c31884f6e89302f34e20c9e6ae1 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 16 Sep 2012 23:49:08 -0400 Subject: [PATCH 04/18] Update to new MCP --- common/buildcraft/BuildCraftEnergy.java | 2 +- common/buildcraft/BuildCraftTransport.java | 14 +-- .../buildcraft/builders/FillerFlattener.java | 8 +- common/buildcraft/builders/FillerPattern.java | 8 +- .../buildcraft/core/ItemRedstoneChipset.java | 4 +- common/buildcraft/core/ItemWrench.java | 2 +- common/buildcraft/core/proxy/CoreProxy.java | 10 +- .../factory/BlockAutoWorkbench.java | 2 +- common/buildcraft/factory/BlockHopper.java | 2 +- common/buildcraft/transport/ItemFacade.java | 5 +- common/buildcraft/transport/ItemGate.java | 2 +- common/buildcraft/transport/ItemPipe.java | 18 +-- .../transport/PipeTransportItems.java | 2 +- .../buildcraft/transport/TileGenericPipe.java | 104 +++++++++--------- 14 files changed, 91 insertions(+), 92 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 3f94e84f..6370e217 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -142,7 +142,7 @@ public class BuildCraftEnergy { LanguageRegistry.addName(bucketOil, "Oil Bucket"); bucketFuel = new ItemBuildCraft(Integer.parseInt(bucketFuelId.value)).setItemName("bucketFuel").setContainerItem(Item.bucketEmpty); - bucketFuel.setIconIndex(0 * 16 + 3).setMaxStackSize(1).setTabToDisplayOn(CreativeTabs.tabMisc); + bucketFuel.setIconIndex(0 * 16 + 3).setMaxStackSize(1).setCreativeTab(CreativeTabs.tabMisc); LanguageRegistry.addName(bucketFuel, "Fuel Bucket"); RefineryRecipe.registerRefineryRecipe(new RefineryRecipe(new LiquidStack(oilStill.blockID, 1, 0), null, new LiquidStack(fuel.shiftedIndex, 1, 0), 10, 1)); diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 276d7fe0..b7355457 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -237,12 +237,12 @@ public class BuildCraftTransport { groupItemsTrigger = Integer.parseInt(groupItemsTriggerProp.value); Property genericPipeId = BuildCraftCore.mainConfiguration.getOrCreateBlockIdProperty("pipe.id", DefaultProps.GENERIC_PIPE_ID); - + Property pipeWaterproofId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("pipeWaterproof.id", Configuration.CATEGORY_ITEM, DefaultProps.PIPE_WATERPROOF_ID); pipeWaterproof = new ItemBuildCraft(Integer.parseInt(pipeWaterproofId.value)).setIconIndex(2 * 16 + 1); pipeWaterproof.setItemName("pipeWaterproof"); - pipeWaterproof.setTabToDisplayOn(CreativeTabs.tabMaterials); + pipeWaterproof.setCreativeTab(CreativeTabs.tabMaterials); LanguageRegistry.addName(pipeWaterproof, "Pipe Waterproof"); genericPipeBlock = new BlockGenericPipe(Integer.parseInt(genericPipeId.value)); GameRegistry.registerBlock(genericPipeBlock); @@ -316,28 +316,28 @@ public class BuildCraftTransport { } Property redPipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("redPipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.RED_PIPE_WIRE); - redPipeWire = new ItemBuildCraft(Integer.parseInt(redPipeWireId.value)).setIconIndex(4 * 16 + 0).setTabToDisplayOn(CreativeTabs.tabRedstone); + redPipeWire = new ItemBuildCraft(Integer.parseInt(redPipeWireId.value)).setIconIndex(4 * 16 + 0).setCreativeTab(CreativeTabs.tabRedstone); redPipeWire.setItemName("redPipeWire"); LanguageRegistry.addName(redPipeWire, "Red Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 1), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(redPipeWire, 8))); Property bluePipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("bluePipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.BLUE_PIPE_WIRE); - bluePipeWire = new ItemBuildCraft(Integer.parseInt(bluePipeWireId.value)).setIconIndex(4 * 16 + 1).setTabToDisplayOn(CreativeTabs.tabRedstone); + bluePipeWire = new ItemBuildCraft(Integer.parseInt(bluePipeWireId.value)).setIconIndex(4 * 16 + 1).setCreativeTab(CreativeTabs.tabRedstone); bluePipeWire.setItemName("bluePipeWire"); LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 4), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(bluePipeWire, 8))); Property greenPipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("greenPipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.GREEN_PIPE_WIRE); - greenPipeWire = new ItemBuildCraft(Integer.parseInt(greenPipeWireId.value)).setIconIndex(4 * 16 + 2).setTabToDisplayOn(CreativeTabs.tabRedstone); + greenPipeWire = new ItemBuildCraft(Integer.parseInt(greenPipeWireId.value)).setIconIndex(4 * 16 + 2).setCreativeTab(CreativeTabs.tabRedstone); greenPipeWire.setItemName("greenPipeWire"); LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 2), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(greenPipeWire, 8))); Property yellowPipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("yellowPipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.YELLOW_PIPE_WIRE); - yellowPipeWire = new ItemBuildCraft(Integer.parseInt(yellowPipeWireId.value)).setIconIndex(4 * 16 + 3).setTabToDisplayOn(CreativeTabs.tabRedstone); + yellowPipeWire = new ItemBuildCraft(Integer.parseInt(yellowPipeWireId.value)).setIconIndex(4 * 16 + 3).setCreativeTab(CreativeTabs.tabRedstone); yellowPipeWire.setItemName("yellowPipeWire"); LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 11), @@ -355,7 +355,7 @@ public class BuildCraftTransport { facadeItem = new ItemFacade(Integer.parseInt(pipeFacadeId.value)); facadeItem.setItemName("pipeFacade"); ItemFacade.initialize(); - + BuildCraftCore.mainConfiguration.save(); new BptBlockPipe(genericPipeBlock.blockID); diff --git a/common/buildcraft/builders/FillerFlattener.java b/common/buildcraft/builders/FillerFlattener.java index e283d4fe..e2a4a878 100644 --- a/common/buildcraft/builders/FillerFlattener.java +++ b/common/buildcraft/builders/FillerFlattener.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -64,7 +64,7 @@ public class FillerFlattener extends FillerPattern { } if (lastX != Integer.MAX_VALUE && stackToPlace != null) { - stackToPlace.getItem().tryPlaceIntoWorld(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(tile.worldObj), tile.worldObj, + stackToPlace.getItem().onItemUse(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(tile.worldObj), tile.worldObj, lastX, lastY - 1, lastZ, 1, 0.0f, 0.0f, 0.0f); } diff --git a/common/buildcraft/builders/FillerPattern.java b/common/buildcraft/builders/FillerPattern.java index da7aa615..5c2fef4f 100644 --- a/common/buildcraft/builders/FillerPattern.java +++ b/common/buildcraft/builders/FillerPattern.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -66,7 +66,7 @@ public abstract class FillerPattern implements IFillerPattern { } if (found && stackToPlace != null) { - stackToPlace.getItem().tryPlaceIntoWorld(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(world), world, xSlot, ySlot - 1, + stackToPlace.getItem().onItemUse(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(world), world, xSlot, ySlot - 1, zSlot, 1, 0.0f, 0.0f, 0.0f); } diff --git a/common/buildcraft/core/ItemRedstoneChipset.java b/common/buildcraft/core/ItemRedstoneChipset.java index 1faf5a9e..3d2e0578 100644 --- a/common/buildcraft/core/ItemRedstoneChipset.java +++ b/common/buildcraft/core/ItemRedstoneChipset.java @@ -15,7 +15,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft { setHasSubtypes(true); setMaxDamage(0); - setTabToDisplayOn(CreativeTabs.tabRedstone); + setCreativeTab(CreativeTabs.tabRedstone); } @SuppressWarnings({ "all" }) @@ -40,7 +40,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft { return (new StringBuilder()).append(super.getItemName()).append(".").append(itemstack.getItemDamage()).toString(); } - + @Override @SideOnly(Side.CLIENT) public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List itemList) { diff --git a/common/buildcraft/core/ItemWrench.java b/common/buildcraft/core/ItemWrench.java index bf9214f6..6f08f35d 100644 --- a/common/buildcraft/core/ItemWrench.java +++ b/common/buildcraft/core/ItemWrench.java @@ -8,7 +8,7 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench { public ItemWrench(int i) { super(i); - setTabToDisplayOn(CreativeTabs.tabTools); + setCreativeTab(CreativeTabs.tabTools); } @Override diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index a35a7359..f2b43c78 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -40,9 +40,9 @@ public class CoreProxy { public String getMinecraftVersion() { return "1.3.2"; } /* INSTANCES */ - public Object getClient() { return null; } + public Object getClient() { return null; } public World getClientWorld() { return null; } - + /* SIMULATION */ public boolean isSimulating(World world) { return !world.isRemote; @@ -63,7 +63,7 @@ public class CoreProxy { /* WRAPPER */ public void feedSubBlocks(int id, CreativeTabs tab, List itemList) {} - + /* LOCALIZATION */ public void addName(Object obj, String s) {} public void addLocalization(String s1, String string) {} @@ -103,14 +103,14 @@ public class CoreProxy { if (Math.abs(player.posX - x) <= maxDistance && Math.abs(player.posY - y) <= maxDistance && Math.abs(player.posZ - z) <= maxDistance) - player.serverForThisPlayer.sendPacketToPlayer(packet); + player.playerNetServerHandler.sendPacketToPlayer(packet); } } } public void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) { EntityPlayerMP player = (EntityPlayerMP) entityplayer; - player.serverForThisPlayer.sendPacketToPlayer(packet.getPacket()); + player.playerNetServerHandler.sendPacketToPlayer(packet.getPacket()); } public void sendToServer(Packet packet) {} diff --git a/common/buildcraft/factory/BlockAutoWorkbench.java b/common/buildcraft/factory/BlockAutoWorkbench.java index 3e17a7ad..0361754a 100644 --- a/common/buildcraft/factory/BlockAutoWorkbench.java +++ b/common/buildcraft/factory/BlockAutoWorkbench.java @@ -33,7 +33,7 @@ public class BlockAutoWorkbench extends BlockBuildCraft { topTexture = 2 * 16 + 11; sideTexture = 2 * 16 + 12; setHardness(1.0F); - setCreativeTab(CreativeTabs.tabDeco); + setCreativeTab(CreativeTabs.tabDecorations); } @Override diff --git a/common/buildcraft/factory/BlockHopper.java b/common/buildcraft/factory/BlockHopper.java index ee6d90dc..3d4c10e4 100644 --- a/common/buildcraft/factory/BlockHopper.java +++ b/common/buildcraft/factory/BlockHopper.java @@ -20,7 +20,7 @@ public class BlockHopper extends BlockBuildCraft { public BlockHopper(int blockId) { super(blockId, Material.iron); setHardness(5F); - setCreativeTab(CreativeTabs.tabDeco); + setCreativeTab(CreativeTabs.tabDecorations); } @Override diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index 9b64b90d..6e75c176 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -32,7 +32,7 @@ public class ItemFacade extends ItemBuildCraft { setHasSubtypes(true); setMaxDamage(0); - this.setTabToDisplayOn(CreativeTabs.tabMisc); + this.setCreativeTab(CreativeTabs.tabMisc); } @Override @@ -77,8 +77,7 @@ public class ItemFacade extends ItemBuildCraft { return true; } else { if (((TileGenericPipe)tile).addFacade(Orientations.values()[side], ItemFacade.getBlockId(stack.getItemDamage()), ItemFacade.getMetaData(stack.getItemDamage()))){ - if (!player.capabilities.isCreativeMode) - stack.stackSize--; + stack.stackSize--; return true; } return false; diff --git a/common/buildcraft/transport/ItemGate.java b/common/buildcraft/transport/ItemGate.java index fa04410d..87ab8fa6 100644 --- a/common/buildcraft/transport/ItemGate.java +++ b/common/buildcraft/transport/ItemGate.java @@ -21,7 +21,7 @@ public class ItemGate extends ItemBuildCraft { setHasSubtypes(true); setMaxDamage(0); - setTabToDisplayOn(CreativeTabs.tabRedstone); + setCreativeTab(CreativeTabs.tabRedstone); } @SuppressWarnings({ "all" }) diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index c19bddd9..d48ac1fe 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -21,16 +21,16 @@ import net.minecraft.src.World; public class ItemPipe extends ItemBuildCraft implements IItemPipe { Pipe dummyPipe; - + private int textureIndex = 0; - + protected ItemPipe(int i) { super(i); - this.setTabToDisplayOn(CreativeTabs.tabTransport); + this.setCreativeTab(CreativeTabs.tabTransport); } - + @Override - public boolean tryPlaceIntoWorld(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int side, float par8, float par9, float par10) { + public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int side, float par8, float par9, float par10) { int blockID = BuildCraftTransport.genericPipeBlock.blockID; if (world.getBlockId(i, j, k) == Block.snow.blockID) @@ -49,15 +49,15 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { if (side == 5) i++; } - + if (itemstack.stackSize == 0) return false; if (entityplayer.canPlayerEdit(i, j, k) && world.canPlaceEntityOnSide(blockID, i, j, k, false, side, entityplayer)) { - + Pipe pipe = BlockGenericPipe.createPipe(shiftedIndex); if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) { - + Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer); // To move to a proxt // world.playSoundEffect((float)i + 0.5F, (float)j + 0.5F, @@ -75,7 +75,7 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { this.textureIndex = textureIndex; return this; } - + public int getTextureIndex() { return textureIndex; } diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index acd54186..740bbfc8 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -94,7 +94,7 @@ public class PipeTransportItems extends PipeTransport { ((IPipeTransportItemsHook) container.pipe).entityEntered(item, orientation); if (!worldObj.isRemote && item.getSynchroTracker().markTimeIfDelay(worldObj, 6 * BuildCraftCore.updateFactor)) { - int dimension = worldObj.provider.worldType; + int dimension = worldObj.provider.dimensionId; PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE, dimension, createItemPacket(item, orientation)); } diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 91034661..9cec1306 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -52,12 +52,12 @@ import net.minecraft.src.TileEntity; public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITankContainer, IPipeEntry, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IPipeConnection, IDropControlInventory, IPipeRenderState, ISyncedTile { - + private class CoreState implements IClientState { public int pipeId = -1; public int gateKind = 0; - + @Override public void writeData(DataOutputStream data) throws IOException { data.writeInt(pipeId); @@ -69,9 +69,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank pipeId = data.readInt(); gateKind = data.readInt(); } - + } - + private PipeRenderState renderState = new PipeRenderState(); private CoreState coreState = new CoreState(); @@ -84,10 +84,10 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank private boolean blockNeighborChange = false; private boolean refreshRenderState = false; private boolean pipeBound = false; - + private int[] facadeBlocks = new int[Orientations.dirs().length]; private int[] facadeMeta = new int[Orientations.dirs().length]; - + public TileGenericPipe() { } @@ -101,7 +101,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank pipe.writeToNBT(nbttagcompound); } else nbttagcompound.setInteger("pipeId", coreState.pipeId); - + for (int i = 0; i < Orientations.dirs().length; i++){ nbttagcompound.setInteger("facadeBlocks[" + i + "]", facadeBlocks[i]); nbttagcompound.setInteger("facadeMeta[" + i + "]", facadeMeta[i]); @@ -112,14 +112,14 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank @Override public void readFromNBT(NBTTagCompound nbttagcompound) { super.readFromNBT(nbttagcompound); - + coreState.pipeId = nbttagcompound.getInteger("pipeId"); pipe = BlockGenericPipe.createPipe(coreState.pipeId); if (pipe != null) { pipe.readFromNBT(nbttagcompound); } - + for (int i = 0; i < Orientations.dirs().length; i++){ facadeBlocks[i] = nbttagcompound.getInteger("facadeBlocks[" + i + "]"); facadeMeta[i] = nbttagcompound.getInteger("facadeMeta[" + i + "]"); @@ -149,10 +149,10 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank @Override public void updateEntity() { - + if (pipe == null) return; - + if (!initialized) initialize(pipe); @@ -160,13 +160,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank return; if (blockNeighborChange) { - + computeConnections(); pipe.onNeighborBlockChange(0); blockNeighborChange = false; refreshRenderState = true; } - + if (refreshRenderState){ refreshRenderState(); refreshRenderState = false; @@ -183,21 +183,21 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank //PRECONDITION: worldObj must not be null private void refreshRenderState() { - + //Only done on server/SSP if (worldObj.isRemote) return; - + // Pipe connections; for(Orientations o : Orientations.dirs()){ renderState.pipeConnectionMatrix.setConnected(o, this.pipeConnectionsBuffer[o.ordinal()]); } - + // Pipe Textures renderState.setTextureFile(pipe.getTextureFile()); for(Orientations o: Orientations.values()){ renderState.textureMatrix.setTextureIndex(o, pipe.getTextureIndex(o)); } - + // WireState for (IPipe.WireColor color : IPipe.WireColor.values()){ renderState.wireMatrix.setWire(color, pipe.wireSet[color.ordinal()]); @@ -205,33 +205,33 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank renderState.wireMatrix.setWireConnected(color, direction, pipe.isWireConnectedTo(this.getTile(direction), color)); } } - + // Wire Textures - + if (pipe.wireSet[IPipe.WireColor.Red.ordinal()]) { renderState.wireMatrix.setTextureIndex(WireColor.Red, pipe.signalStrength[IPipe.WireColor.Red.ordinal()] > 0 ? 6 : 5); } else { renderState.wireMatrix.setTextureIndex(WireColor.Red, 0); } - + if (pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) { renderState.wireMatrix.setTextureIndex(WireColor.Blue, pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] > 0 ? 8 : 7); } else { renderState.wireMatrix.setTextureIndex(WireColor.Blue, 0); } - + if (pipe.wireSet[IPipe.WireColor.Green.ordinal()]) { renderState.wireMatrix.setTextureIndex(WireColor.Green, pipe.signalStrength[IPipe.WireColor.Green.ordinal()] > 0 ? 10 : 9); } else { renderState.wireMatrix.setTextureIndex(WireColor.Green, 0); } - + if (pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) { renderState.wireMatrix.setTextureIndex(WireColor.Yellow, pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] > 0 ? 12 : 11); } else { renderState.wireMatrix.setTextureIndex(WireColor.Yellow, 0); } - + // Gate Textures renderState.setHasGate(pipe.hasGate()); renderState.setGateTexture(!pipe.hasGate()?0:pipe.gate.getTexture(pipe.isGateActive())); @@ -246,19 +246,19 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank renderState.facadeMatrix.setTextureIndex(direction, block.getBlockTextureFromSideAndMetadata(direction.ordinal(), this.facadeMeta[direction.ordinal()])); } } - - + + if (renderState.isDirty()){ worldObj.markBlockNeedsUpdate(this.xCoord, this.yCoord, this.zCoord); renderState.clean(); } - + } public void initialize(Pipe pipe) { - + this.pipe = pipe; - + tileBuffer = new TileBuffer[6]; for (Orientations o : Orientations.dirs()) { @@ -283,21 +283,21 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank if (pipe != null) pipe.initialize(); - + initialized = true; } private void bindPipe() { - + if (!pipeBound && pipe != null) { - + pipe.setTile(this); - + coreState.pipeId = pipe.itemID; pipeBound = true; } } - + @Override public IPipe getPipe() { return pipe; @@ -342,16 +342,16 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank @Override public void entityEntering(ItemStack payload, Orientations orientation) { - + /* FIXME: This is untested guesswork */ Position itemPos = new Position(xCoord, yCoord, zCoord, orientation); itemPos.moveBackwards(1.0); - + itemPos.x += 0.5; itemPos.y += 0.25; itemPos.z += 0.5; itemPos.moveForwards(0.5); - + EntityPassiveItem pipedItem = new EntityPassiveItem(worldObj, itemPos.x, itemPos.y, itemPos.z, payload); entityEntering(pipedItem, orientation); } @@ -373,13 +373,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank renderState = packet.getRenderState(); worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); } - return; + return; } @Override - public Packet getAuxillaryInfoPacket() { + public Packet getDescriptionPacket() { bindPipe(); - + PacketTileState packet = new PacketTileState(this.xCoord, this.yCoord, this.zCoord); if (pipe != null && pipe.gate != null){ coreState.gateKind = pipe.gate.kind.ordinal(); @@ -496,7 +496,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank else return false; } - + @Override public void onChunkUnload() { if (pipe != null){ @@ -504,9 +504,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank } } - + /** ITankContainer implementation **/ - + @Override public int fill(Orientations from, LiquidStack resource, boolean doFill) { if (BlockGenericPipe.isValid(pipe) && pipe.transport instanceof ITankContainer) @@ -546,31 +546,31 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank else return null; } - - + + public void scheduleRenderUpdate(){ refreshRenderState = true; } - + public boolean addFacade(Orientations direction, int blockid, int meta){ if (this.worldObj.isRemote) return false; if (this.facadeBlocks[direction.ordinal()] == blockid) return false; - + if (hasFacade(direction)){ dropFacade(direction); } - + this.facadeBlocks[direction.ordinal()] = blockid; this.facadeMeta[direction.ordinal()] = meta; scheduleRenderUpdate(); return true; } - + public boolean hasFacade(Orientations direction){ if (this.worldObj.isRemote) return false; return (this.facadeBlocks[direction.ordinal()] != 0); } - + public void dropFacade(Orientations direction){ if (this.worldObj.isRemote) return; if (!hasFacade(direction)) return; @@ -579,7 +579,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank this.facadeMeta[direction.ordinal()] = 0; scheduleRenderUpdate(); } - + /** IPipeRenderState implementation **/ @Override @@ -599,7 +599,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank @Override public void afterStateUpdated(byte stateId) { if (!worldObj.isRemote) return; - + switch (stateId){ case 0: if (pipe == null && coreState.pipeId != 0){ @@ -615,7 +615,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank } worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); } - + @Override public double getRenderDistance() { return 24; From 78dc1708d081b15468fade3031d13bc6c8fe6d74 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 21 Sep 2012 23:00:28 -0400 Subject: [PATCH 05/18] More MCP updates --- common/buildcraft/builders/ItemBptBase.java | 8 ++++---- common/buildcraft/builders/TilePathMarker.java | 4 ++-- common/buildcraft/core/gui/GuiAdvancedInterface.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/common/buildcraft/builders/ItemBptBase.java b/common/buildcraft/builders/ItemBptBase.java index b487a34c..19bed9b8 100644 --- a/common/buildcraft/builders/ItemBptBase.java +++ b/common/buildcraft/builders/ItemBptBase.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011-2012 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -27,7 +27,7 @@ public abstract class ItemBptBase extends ItemBuildCraft { maxStackSize = 1; iconIndex = 5 * 16 + 0; - this.setTabToDisplayOn(CreativeTabs.tabMisc); + this.setCreativeTab(CreativeTabs.tabMisc); } @SuppressWarnings({ "all" }) diff --git a/common/buildcraft/builders/TilePathMarker.java b/common/buildcraft/builders/TilePathMarker.java index f3d7671a..a9c65647 100644 --- a/common/buildcraft/builders/TilePathMarker.java +++ b/common/buildcraft/builders/TilePathMarker.java @@ -76,7 +76,7 @@ public class TilePathMarker extends TileMarker { double nearestDistance = 0, distance; //The initialization of nearestDistance is only to make the compiler shut up for (TilePathMarker t : availableMarkers) { - if (t == this || t == this.links[0] || t == this.links[1] || t.worldObj.provider.worldType != this.worldObj.provider.worldType) + if (t == this || t == this.links[0] || t == this.links[1] || t.worldObj.provider.dimensionId != this.worldObj.provider.dimensionId) continue; distance = Math.sqrt(Math.pow(this.xCoord - t.xCoord, 2) + Math.pow(this.yCoord - t.yCoord, 2) + Math.pow(this.zCoord - t.zCoord, 2)); @@ -257,7 +257,7 @@ public class TilePathMarker extends TileMarker { public static void clearAvailableMarkersList(World w) { for (Iterator it = availableMarkers.iterator(); it.hasNext();) { TilePathMarker t = it.next(); - if (t.worldObj.provider.worldType != w.provider.worldType) { + if (t.worldObj.provider.dimensionId != w.provider.dimensionId) { it.remove(); } } diff --git a/common/buildcraft/core/gui/GuiAdvancedInterface.java b/common/buildcraft/core/gui/GuiAdvancedInterface.java index 20ce187a..1d7bb86c 100644 --- a/common/buildcraft/core/gui/GuiAdvancedInterface.java +++ b/common/buildcraft/core/gui/GuiAdvancedInterface.java @@ -57,7 +57,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { drawTexturedModalRect(cornerX + x, cornerY + y, 16 * textureJ, 16 * textureI, 16, 16); } - + } public void drawStack(ItemStack item) { @@ -165,7 +165,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { if (s.length() > 0) { int i2 = (lastX - cornerX); int k2 = lastY - cornerY; - func_74190_a(s, i2, k2); + drawCreativeTabHoveringText(s, i2, k2); } } From 8da16b8956853003facd1804e923941a75194689 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 22 Sep 2012 21:43:40 -0400 Subject: [PATCH 06/18] Add an example chunkloading capability to the quarry. Also fix some naming issues. --- common/buildcraft/BuildCraftFactory.java | 27 ++++++++++++ common/buildcraft/core/TileBuildCraft.java | 2 +- .../core/network/ISynchronizedTile.java | 2 +- common/buildcraft/energy/TileEngine.java | 4 +- common/buildcraft/factory/TileQuarry.java | 44 +++++++++++++++++-- 5 files changed, 72 insertions(+), 7 deletions(-) diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index f330ab21..b8d158e6 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -8,6 +8,8 @@ package buildcraft; +import java.util.List; + import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; @@ -49,7 +51,10 @@ import buildcraft.silicon.TileLaser; import net.minecraft.src.Block; import net.minecraft.src.Item; import net.minecraft.src.ItemStack; +import net.minecraft.src.World; import net.minecraftforge.common.Configuration; +import net.minecraftforge.common.ForgeChunkManager; +import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.Property; @Mod(name="BuildCraft Factory", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Factory", dependencies = DefaultProps.DEPENDENCY_CORE) @@ -77,6 +82,28 @@ public class BuildCraftFactory { @PostInit public void postInit(FMLPostInitializationEvent evt) { FactoryProxy.proxy.initializeNEIIntegration(); + ForgeChunkManager.setForcedChunkLoadingCallback(instance,new QuarryChunkloadCallback()); + } + + public class QuarryChunkloadCallback implements ForgeChunkManager.LoadingCallback + { + @Override + public void ticketsLoaded(List tickets, World world) { + for (Ticket ticket : tickets) + { + int quarryX = ticket.getModData().getInteger("quarryX"); + int quarryY = ticket.getModData().getInteger("quarryY"); + int quarryZ = ticket.getModData().getInteger("quarryZ"); + + int blId = world.getBlockId(quarryX, quarryY, quarryZ); + if (blId == quarryBlock.blockID) + { + TileQuarry tq = (TileQuarry) world.getBlockTileEntity(quarryX, quarryY, quarryZ); + tq.forceChunkLoading(ticket); + } + } + } + } @Init public void load(FMLInitializationEvent evt) { diff --git a/common/buildcraft/core/TileBuildCraft.java b/common/buildcraft/core/TileBuildCraft.java index b511fe30..3fc68ba1 100644 --- a/common/buildcraft/core/TileBuildCraft.java +++ b/common/buildcraft/core/TileBuildCraft.java @@ -83,7 +83,7 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized } @Override - public Packet getAuxillaryInfoPacket() { + public Packet getDescriptionPacket() { return new PacketTileUpdate(this).getPacket(); } diff --git a/common/buildcraft/core/network/ISynchronizedTile.java b/common/buildcraft/core/network/ISynchronizedTile.java index 2605dfef..d6fa1711 100644 --- a/common/buildcraft/core/network/ISynchronizedTile.java +++ b/common/buildcraft/core/network/ISynchronizedTile.java @@ -21,7 +21,7 @@ public interface ISynchronizedTile { public Packet getUpdatePacket(); - public Packet getAuxillaryInfoPacket(); + public Packet getDescriptionPacket(); public PacketPayload getPacketPayload(); } diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 1cca041b..b272af17 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -321,10 +321,10 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven /* SMP UPDATING */ @Override - public Packet getAuxillaryInfoPacket() { + public Packet getDescriptionPacket() { createEngineIfNeeded(); - return super.getAuxillaryInfoPacket(); + return super.getDescriptionPacket(); } @Override diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index a72a4912..5fe29a91 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -12,6 +12,8 @@ package buildcraft.factory; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.common.FMLLog; + import buildcraft.BuildCraftFactory; import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.IAreaProvider; @@ -37,10 +39,14 @@ import buildcraft.core.utils.Utils; import net.minecraft.src.AxisAlignedBB; import net.minecraft.src.Block; +import net.minecraft.src.ChunkCoordIntPair; import net.minecraft.src.EntityItem; import net.minecraft.src.EntityPlayer; import net.minecraft.src.ItemStack; import net.minecraft.src.NBTTagCompound; +import net.minecraftforge.common.ForgeChunkManager; +import net.minecraftforge.common.ForgeChunkManager.Ticket; +import net.minecraftforge.common.ForgeChunkManager.Type; public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, IPipeConnection, IBuilderInventory { public @TileNetworkData @@ -109,6 +115,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, private boolean movingHorizontally; private boolean movingVertically; private double headTrajectory; + private Ticket chunkTicket; private void createArm() { @@ -386,7 +393,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, } private void mineStack(ItemStack stack) { - + System.out.printf("Mining stack %d\n", stack.itemID); // First, try to add to a nearby chest ItemStack added = Utils.addToRandomInventory(stack, worldObj, xCoord, yCoord, zCoord, Orientations.Unknown); stack.stackSize -= added.stackSize; @@ -425,6 +432,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, @Override public void invalidate() { + ForgeChunkManager.releaseTicket(chunkTicket); super.invalidate(); destroy(); @@ -456,6 +464,11 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, } private void setBoundaries(boolean useDefault) { + chunkTicket = ForgeChunkManager.requestTicket(BuildCraftFactory.instance, worldObj, Type.NORMAL); + chunkTicket.getModData().setInteger("quarryX", xCoord); + chunkTicket.getModData().setInteger("quarryY", yCoord); + chunkTicket.getModData().setInteger("quarryZ", zCoord); + ForgeChunkManager.forceChunk(chunkTicket, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4)); IAreaProvider a = null; @@ -473,7 +486,9 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, int ySize = a.yMax() - a.yMin() + 1; int zSize = a.zMax() - a.zMin() + 1; - if (xSize < 3 || zSize < 3) { + if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 4) >= chunkTicket.getMaxChunkListDepth()) + { + FMLLog.info("Quarry size is outside of bounds %d %d (%d)", xSize, zSize, chunkTicket.getMaxChunkListDepth()); a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10); useDefault = true; @@ -519,10 +534,10 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, } a.removeFromWorld(); + forceChunkLoading(chunkTicket); } private void initializeBluePrintBuilder() { - BptBlueprint bluePrint = new BptBlueprint(box.sizeX(), box.sizeY(), box.sizeZ()); for (int i = 0; i < bluePrint.sizeX; ++i) { @@ -573,6 +588,11 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, public void initialize() { super.initialize(); + if (CoreProxy.proxy.isSimulating(this.worldObj) && !box.initialized) + { + setBoundaries(false); + } + createUtilsIfNeeded(); sendNetworkUpdate(); @@ -738,4 +758,22 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, this.targetZ = z; } + public void forceChunkLoading(Ticket ticket) { + if (chunkTicket == null) + { + chunkTicket = ticket; + } + + ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4)); + + for (int chunkX = box.xMin >> 4; chunkX <= box.xMax >> 4; chunkX ++) + { + for (int chunkZ = box.zMin >> 4; chunkZ <= box.zMax >> 4; chunkZ ++) + { + FMLLog.info("Forcing chunk %d %d", chunkX, chunkZ); + ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(chunkX, chunkZ)); + } + } + } + } From bb7da60425a703ec0768531d9374c71d70a97466 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 25 Sep 2012 23:12:24 -0400 Subject: [PATCH 07/18] Update to use proper forge chunkloading API --- common/buildcraft/BuildCraftFactory.java | 13 ++++++++++++- common/buildcraft/factory/TileQuarry.java | 22 +++++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index b8d158e6..3329c920 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -10,6 +10,8 @@ package buildcraft; import java.util.List; +import com.google.common.collect.Lists; + import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; @@ -85,10 +87,17 @@ public class BuildCraftFactory { ForgeChunkManager.setForcedChunkLoadingCallback(instance,new QuarryChunkloadCallback()); } - public class QuarryChunkloadCallback implements ForgeChunkManager.LoadingCallback + public class QuarryChunkloadCallback implements ForgeChunkManager.OrderedLoadingCallback { @Override public void ticketsLoaded(List tickets, World world) { + // NO OP for OrderedLoadingCallback + } + + @Override + public List ticketsLoaded(List tickets, World world, + int maxTicketCount) { + List validTickets = Lists.newArrayList(); for (Ticket ticket : tickets) { int quarryX = ticket.getModData().getInteger("quarryX"); @@ -100,8 +109,10 @@ public class BuildCraftFactory { { TileQuarry tq = (TileQuarry) world.getBlockTileEntity(quarryX, quarryY, quarryZ); tq.forceChunkLoading(ticket); + validTickets.add(ticket); } } + return validTickets; } } diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index 5fe29a91..0e6de37e 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.List; import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.network.PacketDispatcher; import buildcraft.BuildCraftFactory; import buildcraft.api.core.BuildCraftAPI; @@ -44,6 +45,7 @@ import net.minecraft.src.EntityItem; import net.minecraft.src.EntityPlayer; import net.minecraft.src.ItemStack; import net.minecraft.src.NBTTagCompound; +import net.minecraft.src.Packet3Chat; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.ForgeChunkManager.Type; @@ -116,6 +118,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, private boolean movingVertically; private double headTrajectory; private Ticket chunkTicket; + private boolean isAlive; private void createArm() { @@ -134,6 +137,10 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, @Override public void updateEntity() { + if (!isAlive && CoreProxy.proxy.isSimulating(worldObj)) + { + return; + } super.updateEntity(); if (inProcess) { float energyToUse = 2 + powerProvider.getEnergyStored() / 1000; @@ -464,7 +471,16 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, } private void setBoundaries(boolean useDefault) { - chunkTicket = ForgeChunkManager.requestTicket(BuildCraftFactory.instance, worldObj, Type.NORMAL); + if (chunkTicket == null) + { + chunkTicket = ForgeChunkManager.requestTicket(BuildCraftFactory.instance, worldObj, Type.NORMAL); + } + if (chunkTicket == null) + { + isAlive = false; + PacketDispatcher.sendPacketToAllPlayers(new Packet3Chat(String.format("[BUILDCRAFT] Chunkloading capabilities exhausted. The quarry at %d, %d, %d will not work. Remove some quarries!", xCoord, yCoord, zCoord))); + return; + } chunkTicket.getModData().setInteger("quarryX", xCoord); chunkTicket.getModData().setInteger("quarryY", yCoord); chunkTicket.getModData().setInteger("quarryZ", zCoord); @@ -486,7 +502,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, int ySize = a.yMax() - a.yMin() + 1; int zSize = a.zMax() - a.zMin() + 1; - if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 4) >= chunkTicket.getMaxChunkListDepth()) + if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 8) >= chunkTicket.getMaxChunkListDepth()) { FMLLog.info("Quarry size is outside of bounds %d %d (%d)", xSize, zSize, chunkTicket.getMaxChunkListDepth()); a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10); @@ -764,13 +780,13 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, chunkTicket = ticket; } + isAlive = true; ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4)); for (int chunkX = box.xMin >> 4; chunkX <= box.xMax >> 4; chunkX ++) { for (int chunkZ = box.zMin >> 4; chunkZ <= box.zMax >> 4; chunkZ ++) { - FMLLog.info("Forcing chunk %d %d", chunkX, chunkZ); ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(chunkX, chunkZ)); } } From 425f131dedc36802aee24e197fed49ba9670da42 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 25 Sep 2012 23:19:29 -0400 Subject: [PATCH 08/18] Depend on a known good version of Forge --- common/buildcraft/BuildCraftCore.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index ac40f962..806eed1e 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -69,7 +69,7 @@ import net.minecraft.src.ItemStack; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Property; -@Mod(name="BuildCraft", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Core") +@Mod(name="BuildCraft", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", dependencies="required-after:Forge@[4.1.4.286,)") @NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) public class BuildCraftCore { public static enum RenderMode { @@ -142,9 +142,9 @@ public class BuildCraftCore { @PreInit public void loadConfiguration(FMLPreInitializationEvent evt) { - + Version.versionCheck(); - + bcLog.setParent(FMLLog.getLogger()); bcLog.info("Starting BuildCraft " + Version.getVersion()); bcLog.info("Copyright (c) SpaceToad, 2011"); @@ -266,7 +266,7 @@ public class BuildCraftCore { CommandHandler commandManager = (CommandHandler)event.getServer().getCommandManager(); commandManager.registerCommand(new CommandBuildCraft()); } - + public void loadRecipes() { GameRegistry.addRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", Character.valueOf('I'), Item.ingotIron, Character.valueOf('G'), stoneGearItem); GameRegistry.addRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", Character.valueOf('S'), Item.stick); From ded3f14ab90e74169d62231a49e0f55386cd23fb Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 25 Sep 2012 23:40:11 -0400 Subject: [PATCH 09/18] It's 285, not 286 :( --- common/buildcraft/BuildCraftCore.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index 806eed1e..d3b02ee9 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -69,7 +69,7 @@ import net.minecraft.src.ItemStack; import net.minecraftforge.common.Configuration; import net.minecraftforge.common.Property; -@Mod(name="BuildCraft", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", dependencies="required-after:Forge@[4.1.4.286,)") +@Mod(name="BuildCraft", version=Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", dependencies="required-after:Forge@[4.1.4.285,)") @NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) public class BuildCraftCore { public static enum RenderMode { From 87ef38ee92caa3581fa79712931910c77524742d Mon Sep 17 00:00:00 2001 From: Angus Mezick Date: Wed, 26 Sep 2012 15:11:58 -0400 Subject: [PATCH 10/18] Renaming functions for latest MCP/forge --- common/buildcraft/BuildCraftEnergy.java | 2 +- common/buildcraft/BuildCraftTransport.java | 10 +++++----- common/buildcraft/builders/FillerFlattener.java | 2 +- common/buildcraft/builders/FillerPattern.java | 2 +- common/buildcraft/builders/ItemBptBase.java | 2 +- common/buildcraft/builders/TilePathMarker.java | 4 ++-- common/buildcraft/core/ItemRedstoneChipset.java | 2 +- common/buildcraft/core/ItemWrench.java | 2 +- common/buildcraft/core/gui/GuiAdvancedInterface.java | 2 +- common/buildcraft/core/proxy/CoreProxy.java | 4 ++-- common/buildcraft/factory/BlockAutoWorkbench.java | 2 +- common/buildcraft/factory/BlockHopper.java | 2 +- common/buildcraft/transport/ItemFacade.java | 2 +- common/buildcraft/transport/ItemGate.java | 2 +- common/buildcraft/transport/ItemPipe.java | 4 ++-- common/buildcraft/transport/PipeTransportItems.java | 2 +- common/buildcraft/transport/TileGenericPipe.java | 2 +- 17 files changed, 24 insertions(+), 24 deletions(-) diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index 3f94e84f..6370e217 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -142,7 +142,7 @@ public class BuildCraftEnergy { LanguageRegistry.addName(bucketOil, "Oil Bucket"); bucketFuel = new ItemBuildCraft(Integer.parseInt(bucketFuelId.value)).setItemName("bucketFuel").setContainerItem(Item.bucketEmpty); - bucketFuel.setIconIndex(0 * 16 + 3).setMaxStackSize(1).setTabToDisplayOn(CreativeTabs.tabMisc); + bucketFuel.setIconIndex(0 * 16 + 3).setMaxStackSize(1).setCreativeTab(CreativeTabs.tabMisc); LanguageRegistry.addName(bucketFuel, "Fuel Bucket"); RefineryRecipe.registerRefineryRecipe(new RefineryRecipe(new LiquidStack(oilStill.blockID, 1, 0), null, new LiquidStack(fuel.shiftedIndex, 1, 0), 10, 1)); diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 276d7fe0..36de061b 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -242,7 +242,7 @@ public class BuildCraftTransport { pipeWaterproof = new ItemBuildCraft(Integer.parseInt(pipeWaterproofId.value)).setIconIndex(2 * 16 + 1); pipeWaterproof.setItemName("pipeWaterproof"); - pipeWaterproof.setTabToDisplayOn(CreativeTabs.tabMaterials); + pipeWaterproof.setCreativeTab(CreativeTabs.tabMaterials); LanguageRegistry.addName(pipeWaterproof, "Pipe Waterproof"); genericPipeBlock = new BlockGenericPipe(Integer.parseInt(genericPipeId.value)); GameRegistry.registerBlock(genericPipeBlock); @@ -316,28 +316,28 @@ public class BuildCraftTransport { } Property redPipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("redPipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.RED_PIPE_WIRE); - redPipeWire = new ItemBuildCraft(Integer.parseInt(redPipeWireId.value)).setIconIndex(4 * 16 + 0).setTabToDisplayOn(CreativeTabs.tabRedstone); + redPipeWire = new ItemBuildCraft(Integer.parseInt(redPipeWireId.value)).setIconIndex(4 * 16 + 0).setCreativeTab(CreativeTabs.tabRedstone); redPipeWire.setItemName("redPipeWire"); LanguageRegistry.addName(redPipeWire, "Red Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 1), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(redPipeWire, 8))); Property bluePipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("bluePipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.BLUE_PIPE_WIRE); - bluePipeWire = new ItemBuildCraft(Integer.parseInt(bluePipeWireId.value)).setIconIndex(4 * 16 + 1).setTabToDisplayOn(CreativeTabs.tabRedstone); + bluePipeWire = new ItemBuildCraft(Integer.parseInt(bluePipeWireId.value)).setIconIndex(4 * 16 + 1).setCreativeTab(CreativeTabs.tabRedstone); bluePipeWire.setItemName("bluePipeWire"); LanguageRegistry.addName(bluePipeWire, "Blue Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 4), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(bluePipeWire, 8))); Property greenPipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("greenPipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.GREEN_PIPE_WIRE); - greenPipeWire = new ItemBuildCraft(Integer.parseInt(greenPipeWireId.value)).setIconIndex(4 * 16 + 2).setTabToDisplayOn(CreativeTabs.tabRedstone); + greenPipeWire = new ItemBuildCraft(Integer.parseInt(greenPipeWireId.value)).setIconIndex(4 * 16 + 2).setCreativeTab(CreativeTabs.tabRedstone); greenPipeWire.setItemName("greenPipeWire"); LanguageRegistry.addName(greenPipeWire, "Green Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 2), new ItemStack(Item.redstone, 1), new ItemStack(Item.ingotIron, 1) }, 500, new ItemStack(greenPipeWire, 8))); Property yellowPipeWireId = BuildCraftCore.mainConfiguration.getOrCreateIntProperty("yellowPipeWire.id", Configuration.CATEGORY_ITEM, DefaultProps.YELLOW_PIPE_WIRE); - yellowPipeWire = new ItemBuildCraft(Integer.parseInt(yellowPipeWireId.value)).setIconIndex(4 * 16 + 3).setTabToDisplayOn(CreativeTabs.tabRedstone); + yellowPipeWire = new ItemBuildCraft(Integer.parseInt(yellowPipeWireId.value)).setIconIndex(4 * 16 + 3).setCreativeTab(CreativeTabs.tabRedstone); yellowPipeWire.setItemName("yellowPipeWire"); LanguageRegistry.addName(yellowPipeWire, "Yellow Pipe Wire"); AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(Item.dyePowder, 1, 11), diff --git a/common/buildcraft/builders/FillerFlattener.java b/common/buildcraft/builders/FillerFlattener.java index e283d4fe..e1fb6b1b 100644 --- a/common/buildcraft/builders/FillerFlattener.java +++ b/common/buildcraft/builders/FillerFlattener.java @@ -64,7 +64,7 @@ public class FillerFlattener extends FillerPattern { } if (lastX != Integer.MAX_VALUE && stackToPlace != null) { - stackToPlace.getItem().tryPlaceIntoWorld(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(tile.worldObj), tile.worldObj, + stackToPlace.getItem().onItemUse(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(tile.worldObj), tile.worldObj, lastX, lastY - 1, lastZ, 1, 0.0f, 0.0f, 0.0f); } diff --git a/common/buildcraft/builders/FillerPattern.java b/common/buildcraft/builders/FillerPattern.java index da7aa615..d3556caa 100644 --- a/common/buildcraft/builders/FillerPattern.java +++ b/common/buildcraft/builders/FillerPattern.java @@ -66,7 +66,7 @@ public abstract class FillerPattern implements IFillerPattern { } if (found && stackToPlace != null) { - stackToPlace.getItem().tryPlaceIntoWorld(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(world), world, xSlot, ySlot - 1, + stackToPlace.getItem().onItemUse(stackToPlace, CoreProxy.proxy.getBuildCraftPlayer(world), world, xSlot, ySlot - 1, zSlot, 1, 0.0f, 0.0f, 0.0f); } diff --git a/common/buildcraft/builders/ItemBptBase.java b/common/buildcraft/builders/ItemBptBase.java index b487a34c..3df8373a 100644 --- a/common/buildcraft/builders/ItemBptBase.java +++ b/common/buildcraft/builders/ItemBptBase.java @@ -27,7 +27,7 @@ public abstract class ItemBptBase extends ItemBuildCraft { maxStackSize = 1; iconIndex = 5 * 16 + 0; - this.setTabToDisplayOn(CreativeTabs.tabMisc); + this.setCreativeTab(CreativeTabs.tabMisc); } @SuppressWarnings({ "all" }) diff --git a/common/buildcraft/builders/TilePathMarker.java b/common/buildcraft/builders/TilePathMarker.java index f3d7671a..a9c65647 100644 --- a/common/buildcraft/builders/TilePathMarker.java +++ b/common/buildcraft/builders/TilePathMarker.java @@ -76,7 +76,7 @@ public class TilePathMarker extends TileMarker { double nearestDistance = 0, distance; //The initialization of nearestDistance is only to make the compiler shut up for (TilePathMarker t : availableMarkers) { - if (t == this || t == this.links[0] || t == this.links[1] || t.worldObj.provider.worldType != this.worldObj.provider.worldType) + if (t == this || t == this.links[0] || t == this.links[1] || t.worldObj.provider.dimensionId != this.worldObj.provider.dimensionId) continue; distance = Math.sqrt(Math.pow(this.xCoord - t.xCoord, 2) + Math.pow(this.yCoord - t.yCoord, 2) + Math.pow(this.zCoord - t.zCoord, 2)); @@ -257,7 +257,7 @@ public class TilePathMarker extends TileMarker { public static void clearAvailableMarkersList(World w) { for (Iterator it = availableMarkers.iterator(); it.hasNext();) { TilePathMarker t = it.next(); - if (t.worldObj.provider.worldType != w.provider.worldType) { + if (t.worldObj.provider.dimensionId != w.provider.dimensionId) { it.remove(); } } diff --git a/common/buildcraft/core/ItemRedstoneChipset.java b/common/buildcraft/core/ItemRedstoneChipset.java index 1faf5a9e..703d109a 100644 --- a/common/buildcraft/core/ItemRedstoneChipset.java +++ b/common/buildcraft/core/ItemRedstoneChipset.java @@ -15,7 +15,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft { setHasSubtypes(true); setMaxDamage(0); - setTabToDisplayOn(CreativeTabs.tabRedstone); + setCreativeTab(CreativeTabs.tabRedstone); } @SuppressWarnings({ "all" }) diff --git a/common/buildcraft/core/ItemWrench.java b/common/buildcraft/core/ItemWrench.java index bf9214f6..6f08f35d 100644 --- a/common/buildcraft/core/ItemWrench.java +++ b/common/buildcraft/core/ItemWrench.java @@ -8,7 +8,7 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench { public ItemWrench(int i) { super(i); - setTabToDisplayOn(CreativeTabs.tabTools); + setCreativeTab(CreativeTabs.tabTools); } @Override diff --git a/common/buildcraft/core/gui/GuiAdvancedInterface.java b/common/buildcraft/core/gui/GuiAdvancedInterface.java index 20ce187a..4a88ab60 100644 --- a/common/buildcraft/core/gui/GuiAdvancedInterface.java +++ b/common/buildcraft/core/gui/GuiAdvancedInterface.java @@ -165,7 +165,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { if (s.length() > 0) { int i2 = (lastX - cornerX); int k2 = lastY - cornerY; - func_74190_a(s, i2, k2); + drawCreativeTabHoveringText(s, i2, k2); } } diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index a35a7359..d5c9ac7a 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -103,14 +103,14 @@ public class CoreProxy { if (Math.abs(player.posX - x) <= maxDistance && Math.abs(player.posY - y) <= maxDistance && Math.abs(player.posZ - z) <= maxDistance) - player.serverForThisPlayer.sendPacketToPlayer(packet); + player.playerNetServerHandler.sendPacketToPlayer(packet); } } } public void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) { EntityPlayerMP player = (EntityPlayerMP) entityplayer; - player.serverForThisPlayer.sendPacketToPlayer(packet.getPacket()); + player.playerNetServerHandler.sendPacketToPlayer(packet.getPacket()); } public void sendToServer(Packet packet) {} diff --git a/common/buildcraft/factory/BlockAutoWorkbench.java b/common/buildcraft/factory/BlockAutoWorkbench.java index 3e17a7ad..0361754a 100644 --- a/common/buildcraft/factory/BlockAutoWorkbench.java +++ b/common/buildcraft/factory/BlockAutoWorkbench.java @@ -33,7 +33,7 @@ public class BlockAutoWorkbench extends BlockBuildCraft { topTexture = 2 * 16 + 11; sideTexture = 2 * 16 + 12; setHardness(1.0F); - setCreativeTab(CreativeTabs.tabDeco); + setCreativeTab(CreativeTabs.tabDecorations); } @Override diff --git a/common/buildcraft/factory/BlockHopper.java b/common/buildcraft/factory/BlockHopper.java index ee6d90dc..3d4c10e4 100644 --- a/common/buildcraft/factory/BlockHopper.java +++ b/common/buildcraft/factory/BlockHopper.java @@ -20,7 +20,7 @@ public class BlockHopper extends BlockBuildCraft { public BlockHopper(int blockId) { super(blockId, Material.iron); setHardness(5F); - setCreativeTab(CreativeTabs.tabDeco); + setCreativeTab(CreativeTabs.tabDecorations); } @Override diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index 9b64b90d..05e60463 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -32,7 +32,7 @@ public class ItemFacade extends ItemBuildCraft { setHasSubtypes(true); setMaxDamage(0); - this.setTabToDisplayOn(CreativeTabs.tabMisc); + this.setCreativeTab(CreativeTabs.tabMisc); } @Override diff --git a/common/buildcraft/transport/ItemGate.java b/common/buildcraft/transport/ItemGate.java index fa04410d..87ab8fa6 100644 --- a/common/buildcraft/transport/ItemGate.java +++ b/common/buildcraft/transport/ItemGate.java @@ -21,7 +21,7 @@ public class ItemGate extends ItemBuildCraft { setHasSubtypes(true); setMaxDamage(0); - setTabToDisplayOn(CreativeTabs.tabRedstone); + setCreativeTab(CreativeTabs.tabRedstone); } @SuppressWarnings({ "all" }) diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index c19bddd9..b9c221f7 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -26,11 +26,11 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { protected ItemPipe(int i) { super(i); - this.setTabToDisplayOn(CreativeTabs.tabTransport); + this.setCreativeTab(CreativeTabs.tabTransport); } @Override - public boolean tryPlaceIntoWorld(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int side, float par8, float par9, float par10) { + public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int side, float par8, float par9, float par10) { int blockID = BuildCraftTransport.genericPipeBlock.blockID; if (world.getBlockId(i, j, k) == Block.snow.blockID) diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index acd54186..740bbfc8 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -94,7 +94,7 @@ public class PipeTransportItems extends PipeTransport { ((IPipeTransportItemsHook) container.pipe).entityEntered(item, orientation); if (!worldObj.isRemote && item.getSynchroTracker().markTimeIfDelay(worldObj, 6 * BuildCraftCore.updateFactor)) { - int dimension = worldObj.provider.worldType; + int dimension = worldObj.provider.dimensionId; PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE, dimension, createItemPacket(item, orientation)); } diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 91034661..287a8e27 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -377,7 +377,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank } @Override - public Packet getAuxillaryInfoPacket() { + public Packet getDescriptionPacket() { bindPipe(); PacketTileState packet = new PacketTileState(this.xCoord, this.yCoord, this.zCoord); From 4774f0ecdbd2efcc24b18fd8b34bbe62b5807fb4 Mon Sep 17 00:00:00 2001 From: Angus Mezick Date: Thu, 27 Sep 2012 10:35:36 -0400 Subject: [PATCH 11/18] update forge version number in build.xml files --- build.xml | 2 +- buildcraft_resources/build.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.xml b/build.xml index 475ef893..c4214a7f 100644 --- a/build.xml +++ b/build.xml @@ -18,7 +18,7 @@ - + diff --git a/buildcraft_resources/build.xml b/buildcraft_resources/build.xml index c3af5f57..e8b46fc5 100644 --- a/buildcraft_resources/build.xml +++ b/buildcraft_resources/build.xml @@ -17,7 +17,7 @@ - + From 6d5942bc8ae0382ba47a2c2e77c74002a20612f9 Mon Sep 17 00:00:00 2001 From: psxlover Date: Sun, 30 Sep 2012 22:42:09 +0300 Subject: [PATCH 12/18] Refactored lasers. Moved PowerLaser logic from EntityLaser. --- common/buildcraft/builders/TileBuilder.java | 2 +- .../buildcraft/builders/TilePathMarker.java | 2 +- common/buildcraft/core/EntityEnergyLaser.java | 21 ++-- common/buildcraft/core/EntityLaser.java | 116 ++++++++---------- common/buildcraft/core/EntityPowerLaser.java | 28 +++++ .../buildcraft/core/render/RenderLaser.java | 5 +- common/buildcraft/silicon/TileLaser.java | 4 +- 7 files changed, 95 insertions(+), 83 deletions(-) diff --git a/common/buildcraft/builders/TileBuilder.java b/common/buildcraft/builders/TileBuilder.java index f472838d..731f36d9 100644 --- a/common/buildcraft/builders/TileBuilder.java +++ b/common/buildcraft/builders/TileBuilder.java @@ -235,7 +235,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP for (BlockIndex b : path) { if (previous != null) { - EntityLaser laser = new EntityPowerLaser(worldObj, + EntityPowerLaser laser = new EntityPowerLaser(worldObj, new Position(previous.i + 0.5, previous.j + 0.5, previous.k + 0.5), new Position(b.i + 0.5, b.j + 0.5, b.k + 0.5)); diff --git a/common/buildcraft/builders/TilePathMarker.java b/common/buildcraft/builders/TilePathMarker.java index a9c65647..e10085c4 100644 --- a/common/buildcraft/builders/TilePathMarker.java +++ b/common/buildcraft/builders/TilePathMarker.java @@ -60,7 +60,7 @@ public class TilePathMarker extends TileMarker { if (CoreProxy.proxy.isRenderWorld(worldObj)) return; - EntityLaser laser = new EntityPowerLaser(worldObj, new Position(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5), new Position(pathMarker.xCoord + 0.5, pathMarker.yCoord + 0.5, pathMarker.zCoord + 0.5)); + EntityPowerLaser laser = new EntityPowerLaser(worldObj, new Position(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5), new Position(pathMarker.xCoord + 0.5, pathMarker.yCoord + 0.5, pathMarker.zCoord + 0.5)); laser.show(); laser.setTexture(DefaultProps.TEXTURE_PATH_ENTITIES + "/laser_1.png"); diff --git a/common/buildcraft/core/EntityEnergyLaser.java b/common/buildcraft/core/EntityEnergyLaser.java index 3dc5b5c6..b0c9d456 100644 --- a/common/buildcraft/core/EntityEnergyLaser.java +++ b/common/buildcraft/core/EntityEnergyLaser.java @@ -58,27 +58,20 @@ public class EntityEnergyLaser extends EntityLaser { } @Override - protected void updateData() { - super.updateData(); - + protected void updateDataClient() { + super.updateDataClient(); powerAverage = (float)decodeDouble(dataWatcher.getWatchableObjectInt(15)); } - + @Override - public void setPositions(Position head, Position tail) { - super.setPositions(head, tail); + protected void updateDataServer() { + super.updateDataServer(); dataWatcher.updateObject(15, Integer.valueOf(encodeDouble((double)powerAverage))); } @Override - protected void initClientSide() { - super.initClientSide(); + protected void entityInit() { + super.entityInit(); dataWatcher.addObject(15, Integer.valueOf(0)); } - - @Override - protected void initServerSide() { - super.initServerSide(); - dataWatcher.addObject(15, encodeDouble((double)powerAverage)); - } } diff --git a/common/buildcraft/core/EntityLaser.java b/common/buildcraft/core/EntityLaser.java index 534cf77e..3a68c453 100644 --- a/common/buildcraft/core/EntityLaser.java +++ b/common/buildcraft/core/EntityLaser.java @@ -16,19 +16,22 @@ import net.minecraft.src.Entity; import net.minecraft.src.NBTTagCompound; import net.minecraft.src.World; -public class EntityLaser extends Entity { +public abstract class EntityLaser extends Entity { protected Position head, tail; public double renderSize = 0; public double angleY = 0; public double angleZ = 0; - protected String texture; + + private boolean isVisible = false; + protected boolean needsUpdate = true; public EntityLaser(World world) { super(world); - initClientSide(); + head = new Position(0, 0, 0); + tail = new Position(0, 0, 0); } public EntityLaser(World world, Position head, Position tail) { @@ -39,46 +42,23 @@ public class EntityLaser extends Entity { this.tail = tail; setPositionAndRotation(head.x, head.y, head.z, 0, 0); - - initServerSide(); + setSize(10, 10); } - protected void initClientSide() { - - head = new Position(0, 0, 0); - tail = new Position(0, 0, 0); - - dataWatcher.addObject(8 , Integer.valueOf(0)); - dataWatcher.addObject(9 , Integer.valueOf(0)); + @Override + protected void entityInit() { + preventEntitySpawning = false; + noClip = true; + isImmuneToFire = true; + + dataWatcher.addObject(8, Integer.valueOf(0)); + dataWatcher.addObject(9, Integer.valueOf(0)); dataWatcher.addObject(10, Integer.valueOf(0)); dataWatcher.addObject(11, Integer.valueOf(0)); dataWatcher.addObject(12, Integer.valueOf(0)); dataWatcher.addObject(13, Integer.valueOf(0)); dataWatcher.addObject(14, Byte.valueOf((byte) 0)); - - dataWatcher.addObject(16, ""); - } - - protected void initServerSide() { - - preventEntitySpawning = false; - noClip = true; - isImmuneToFire = true; - - setPositionAndRotation(head.x, head.y, head.z, 0, 0); - setSize(10, 10); - - dataWatcher.addObject(8 , Integer.valueOf(encodeDouble(head.x))); - dataWatcher.addObject(9 , Integer.valueOf(encodeDouble(head.y))); - dataWatcher.addObject(10, Integer.valueOf(encodeDouble(head.z))); - dataWatcher.addObject(11, Integer.valueOf(encodeDouble(tail.x))); - dataWatcher.addObject(12, Integer.valueOf(encodeDouble(tail.y))); - dataWatcher.addObject(13, Integer.valueOf(encodeDouble(tail.z))); - - dataWatcher.addObject(14, Byte.valueOf((byte) 0)); - - dataWatcher.addObject(16, ""); } @Override @@ -87,8 +67,13 @@ public class EntityLaser extends Entity { if (head == null || tail == null) return; + if (CoreProxy.proxy.isSimulating(worldObj) && needsUpdate) { + updateDataServer(); + needsUpdate = false; + } + if (CoreProxy.proxy.isRenderWorld(worldObj)) - updateData(); + updateDataClient(); boundingBox.minX = Math.min(head.x, tail.x); boundingBox.minY = Math.min(head.y, tail.y); @@ -116,66 +101,62 @@ public class EntityLaser extends Entity { angleY = -Math.atan2(dy, dx) * 180 / Math.PI; } - protected void updateData() { - + protected void updateDataClient() { head.x = decodeDouble(dataWatcher.getWatchableObjectInt(8)); head.y = decodeDouble(dataWatcher.getWatchableObjectInt(9)); head.z = decodeDouble(dataWatcher.getWatchableObjectInt(10)); tail.x = decodeDouble(dataWatcher.getWatchableObjectInt(11)); tail.y = decodeDouble(dataWatcher.getWatchableObjectInt(12)); tail.z = decodeDouble(dataWatcher.getWatchableObjectInt(13)); - texture = dataWatcher.getWatchableObjectString(16); + + isVisible = (dataWatcher.getWatchableObjectByte(14) == 1); } - public void setPositions(Position head, Position tail) { - - this.head = head; - this.tail = tail; - - setPositionAndRotation(head.x, head.y, head.z, 0, 0); - - dataWatcher.updateObject(8 , Integer.valueOf(encodeDouble(head.x))); - dataWatcher.updateObject(9 , Integer.valueOf(encodeDouble(head.y))); + protected void updateDataServer() { + dataWatcher.updateObject(8, Integer.valueOf(encodeDouble(head.x))); + dataWatcher.updateObject(9, Integer.valueOf(encodeDouble(head.y))); dataWatcher.updateObject(10, Integer.valueOf(encodeDouble(head.z))); dataWatcher.updateObject(11, Integer.valueOf(encodeDouble(tail.x))); dataWatcher.updateObject(12, Integer.valueOf(encodeDouble(tail.y))); dataWatcher.updateObject(13, Integer.valueOf(encodeDouble(tail.z))); - onUpdate(); + dataWatcher.updateObject(14, Byte.valueOf((byte) (isVisible ? 1 : 0))); + } + + public void setPositions(Position head, Position tail) { + this.head = head; + this.tail = tail; + + setPositionAndRotation(head.x, head.y, head.z, 0, 0); + + needsUpdate = true; } public void show() { - dataWatcher.updateObject(14, Byte.valueOf((byte) 1)); + isVisible = true; + needsUpdate = true; } public void hide() { - dataWatcher.updateObject(14, Byte.valueOf((byte) 0)); + isVisible = false; + needsUpdate = true; } public boolean isVisible() { - return dataWatcher.getWatchableObjectByte(14) == 0 ? false : true; + return this.isVisible; } - public void setTexture(String texture) { - this.texture = texture; - dataWatcher.updateObject(16, texture); - } - - public String getTexture() { - return texture; - } + public abstract String getTexture(); protected int encodeDouble(double d) { - return (int) (d * 8000); + return (int) (d * 8192); } protected double decodeDouble(int i) { - return (i / 8000D); + return (i / 8192D); } - @Override - protected void entityInit() {} - + //The read/write to nbt seem to be useless @Override protected void readEntityFromNBT(NBTTagCompound nbt) { @@ -201,4 +182,9 @@ public class EntityLaser extends Entity { nbt.setDouble("tailY", tail.y); nbt.setDouble("tailZ", tail.z); } + + //Workaround for the laser's posY loosing it's precision e.g 103.5 becomes 104 + public Position renderOffset() { + return new Position(head.x - posX, head.y - posY, head.z - posZ); + } } diff --git a/common/buildcraft/core/EntityPowerLaser.java b/common/buildcraft/core/EntityPowerLaser.java index 25563658..9d88c2a4 100644 --- a/common/buildcraft/core/EntityPowerLaser.java +++ b/common/buildcraft/core/EntityPowerLaser.java @@ -4,6 +4,7 @@ import net.minecraft.src.World; import buildcraft.api.core.Position; public class EntityPowerLaser extends EntityLaser { + private String texture; public EntityPowerLaser(World world) { super(world); @@ -13,4 +14,31 @@ public class EntityPowerLaser extends EntityLaser { super(world, head, tail); } + @Override + protected void entityInit() { + super.entityInit(); + dataWatcher.addObject(15, ""); + } + + @Override + public String getTexture() { + return texture; + } + + public void setTexture(String texture) { + this.texture = texture; + needsUpdate = true; + } + + @Override + protected void updateDataClient() { + super.updateDataClient(); + texture = dataWatcher.getWatchableObjectString(15); + } + + @Override + protected void updateDataServer() { + super.updateDataServer(); + dataWatcher.updateObject(15, texture); + } } diff --git a/common/buildcraft/core/render/RenderLaser.java b/common/buildcraft/core/render/RenderLaser.java index eeb6bea7..70a8f09b 100644 --- a/common/buildcraft/core/render/RenderLaser.java +++ b/common/buildcraft/core/render/RenderLaser.java @@ -1,5 +1,6 @@ package buildcraft.core.render; +import buildcraft.api.core.Position; import net.minecraft.src.Entity; import net.minecraft.src.ModelBase; import net.minecraft.src.ModelRenderer; @@ -38,7 +39,9 @@ public class RenderLaser extends Render { GL11.glPushMatrix(); GL11.glDisable(2896 /* GL_LIGHTING */); - GL11.glTranslated(x, y, z); + + Position offset = laser.renderOffset(); + GL11.glTranslated(x + offset.x, y + offset.y, z + offset.z); GL11.glRotatef((float) laser.angleZ, 0, 1, 0); GL11.glRotatef((float) laser.angleY, 0, 0, 1); diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java index d5977834..f6ba5561 100644 --- a/common/buildcraft/silicon/TileLaser.java +++ b/common/buildcraft/silicon/TileLaser.java @@ -207,7 +207,9 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor { assemblyTable.zCoord + 0.475 + (worldObj.rand.nextFloat() - 0.5) / 5F); laser.setPositions(head, tail); - laser.show(); + + if(!laser.isVisible()) + laser.show(); } protected void removeLaser() { From 2e6c0ea4758eff86f55e27b9dbab30f1cd8b9b95 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 1 Oct 2012 22:47:50 -0400 Subject: [PATCH 13/18] Fix chunkloading for quarries. --- common/buildcraft/BuildCraftFactory.java | 15 +++-- common/buildcraft/factory/BlockQuarry.java | 75 ++++++++++++---------- common/buildcraft/factory/TileQuarry.java | 55 +++++++++++++--- 3 files changed, 97 insertions(+), 48 deletions(-) diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index 3329c920..9072f538 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -91,12 +91,19 @@ public class BuildCraftFactory { { @Override public void ticketsLoaded(List tickets, World world) { - // NO OP for OrderedLoadingCallback + for (Ticket ticket : tickets) + { + int quarryX = ticket.getModData().getInteger("quarryX"); + int quarryY = ticket.getModData().getInteger("quarryY"); + int quarryZ = ticket.getModData().getInteger("quarryZ"); + TileQuarry tq = (TileQuarry) world.getBlockTileEntity(quarryX, quarryY, quarryZ); + tq.forceChunkLoading(ticket); + + } } @Override - public List ticketsLoaded(List tickets, World world, - int maxTicketCount) { + public List ticketsLoaded(List tickets, World world, int maxTicketCount) { List validTickets = Lists.newArrayList(); for (Ticket ticket : tickets) { @@ -107,8 +114,6 @@ public class BuildCraftFactory { int blId = world.getBlockId(quarryX, quarryY, quarryZ); if (blId == quarryBlock.blockID) { - TileQuarry tq = (TileQuarry) world.getBlockTileEntity(quarryX, quarryY, quarryZ); - tq.forceChunkLoading(ticket); validTickets.add(ticket); } } diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java index 5bd98930..fc50c606 100644 --- a/common/buildcraft/factory/BlockQuarry.java +++ b/common/buildcraft/factory/BlockQuarry.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -11,6 +11,8 @@ package buildcraft.factory; import java.util.ArrayList; +import com.google.common.math.IntMath; + import buildcraft.BuildCraftFactory; import buildcraft.api.core.Orientations; import buildcraft.api.core.Position; @@ -57,6 +59,11 @@ public class BlockQuarry extends BlockMachineRoot { new Position(i, j, k)); world.setBlockMetadataWithNotify(i, j, k, orientation.reverse().ordinal()); + if (entityliving instanceof EntityPlayer) + { + TileQuarry tq = (TileQuarry) world.getBlockTileEntity(i,j,k); + tq.placedBy = (EntityPlayer) entityliving; + } } @Override @@ -125,46 +132,48 @@ public class BlockQuarry extends BlockMachineRoot { world.setBlockMetadata(x, y, z, 1); } } - + @Override public void breakBlock(World world, int i, int j, int k, int par5, int par6) { - - if (CoreProxy.proxy.isRenderWorld(world)){ + + if (!CoreProxy.proxy.isSimulating(world)){ return; } - + TileEntity tile = world.getBlockTileEntity(i, j, k); if (tile instanceof TileQuarry){ TileQuarry quarry = (TileQuarry)tile; Box box = quarry.box; - - //X - Axis - for (int x = box.xMin; x <= box.xMax; x++) { - markFrameForDecay(world, x, box.yMin, box.zMin); - markFrameForDecay(world, x, box.yMax, box.zMin); - markFrameForDecay(world, x, box.yMin, box.zMax); - markFrameForDecay(world, x, box.yMax, box.zMax); - } - - //Z - Axis - for (int z = box.zMin + 1; z <= box.zMax - 1; z++) { - markFrameForDecay(world, box.xMin, box.yMin, z); - markFrameForDecay(world, box.xMax, box.yMin, z); - markFrameForDecay(world, box.xMin, box.yMax, z); - markFrameForDecay(world, box.xMax, box.yMax, z); - } - - //Y - Axis - for (int y = box.yMin + 1; y <= box.yMax -1; y++) { - - markFrameForDecay(world, box.xMin, y, box.zMin); - markFrameForDecay(world, box.xMax, y, box.zMin); - markFrameForDecay(world, box.xMin, y, box.zMax); - markFrameForDecay(world, box.xMax, y, box.zMax); + if (box.isInitialized() && Integer.MAX_VALUE != box.xMax) + { + //X - Axis + for (int x = box.xMin; x <= box.xMax; x++) { + markFrameForDecay(world, x, box.yMin, box.zMin); + markFrameForDecay(world, x, box.yMax, box.zMin); + markFrameForDecay(world, x, box.yMin, box.zMax); + markFrameForDecay(world, x, box.yMax, box.zMax); + } + + //Z - Axis + for (int z = box.zMin + 1; z <= box.zMax - 1; z++) { + markFrameForDecay(world, box.xMin, box.yMin, z); + markFrameForDecay(world, box.xMax, box.yMin, z); + markFrameForDecay(world, box.xMin, box.yMax, z); + markFrameForDecay(world, box.xMax, box.yMax, z); + } + + //Y - Axis + for (int y = box.yMin + 1; y <= box.yMax -1; y++) { + + markFrameForDecay(world, box.xMin, y, box.zMin); + markFrameForDecay(world, box.xMax, y, box.zMin); + markFrameForDecay(world, box.xMin, y, box.zMax); + markFrameForDecay(world, box.xMax, y, box.zMax); + } } quarry.destroy(); } - + Utils.preDestroyBlock(world, i, j, k); // byte width = 1; @@ -197,7 +206,7 @@ public class BlockQuarry extends BlockMachineRoot { super.breakBlock(world, i, j, k, par5, par6); } - + @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { TileQuarry tile = (TileQuarry) world.getBlockTileEntity(i, j, k); diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index 0e6de37e..66267ba2 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -11,9 +11,13 @@ package buildcraft.factory; import java.util.ArrayList; import java.util.List; +import java.util.Set; + +import com.google.common.collect.Sets; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.network.PacketDispatcher; +import cpw.mods.fml.common.network.Player; import buildcraft.BuildCraftFactory; import buildcraft.api.core.BuildCraftAPI; @@ -42,6 +46,7 @@ import net.minecraft.src.AxisAlignedBB; import net.minecraft.src.Block; import net.minecraft.src.ChunkCoordIntPair; import net.minecraft.src.EntityItem; +import net.minecraft.src.EntityLiving; import net.minecraft.src.EntityPlayer; import net.minecraft.src.ItemStack; import net.minecraft.src.NBTTagCompound; @@ -118,7 +123,8 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, private boolean movingVertically; private double headTrajectory; private Ticket chunkTicket; - private boolean isAlive; + public @TileNetworkData boolean isAlive; + public EntityPlayer placedBy; private void createArm() { @@ -139,6 +145,12 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, public void updateEntity() { if (!isAlive && CoreProxy.proxy.isSimulating(worldObj)) { + super.updateEntity(); + return; + } + if (!CoreProxy.proxy.isSimulating(worldObj) && isAlive) + { + super.updateEntity(); return; } super.updateEntity(); @@ -152,7 +164,7 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, } } - if (CoreProxy.proxy.isSimulating(worldObj)) { + if (CoreProxy.proxy.isSimulating(worldObj) && inProcess) { sendNetworkUpdate(); } if (inProcess || !isDigging) { @@ -400,7 +412,6 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, } private void mineStack(ItemStack stack) { - System.out.printf("Mining stack %d\n", stack.itemID); // First, try to add to a nearby chest ItemStack added = Utils.addToRandomInventory(stack, worldObj, xCoord, yCoord, zCoord, Orientations.Unknown); stack.stackSize -= added.stackSize; @@ -478,7 +489,11 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, if (chunkTicket == null) { isAlive = false; - PacketDispatcher.sendPacketToAllPlayers(new Packet3Chat(String.format("[BUILDCRAFT] Chunkloading capabilities exhausted. The quarry at %d, %d, %d will not work. Remove some quarries!", xCoord, yCoord, zCoord))); + if (placedBy!=null && CoreProxy.proxy.isSimulating(worldObj)) + { + PacketDispatcher.sendPacketToPlayer(new Packet3Chat(String.format("[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", xCoord, yCoord, zCoord)), (Player) placedBy); + } + sendNetworkUpdate(); return; } chunkTicket.getModData().setInteger("quarryX", xCoord); @@ -504,7 +519,10 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 8) >= chunkTicket.getMaxChunkListDepth()) { - FMLLog.info("Quarry size is outside of bounds %d %d (%d)", xSize, zSize, chunkTicket.getMaxChunkListDepth()); + if (placedBy != null) + { + PacketDispatcher.sendPacketToPlayer(new Packet3Chat(String.format("Quarry size is outside of chunkloading bounds or too small %d %d (%d)", xSize, zSize, chunkTicket.getMaxChunkListDepth())),(Player) placedBy); + } a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10); useDefault = true; @@ -589,11 +607,18 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, @Override public void postPacketHandling(PacketUpdate packet) { - super.postPacketHandling(packet); - createUtilsIfNeeded(); - + if (isAlive) + { + createUtilsIfNeeded(); + } + else + { + box.deleteLasers(); + box.reset(); + return; + } if (arm != null) { arm.setHead(headPosX, headPosY, headPosZ); arm.updatePosition(); @@ -780,16 +805,26 @@ public class TileQuarry extends TileMachine implements IMachine, IPowerReceptor, chunkTicket = ticket; } + Set chunks = Sets.newHashSet(); isAlive = true; - ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4)); + ChunkCoordIntPair quarryChunk = new ChunkCoordIntPair(xCoord >> 4, zCoord >> 4); + chunks.add(quarryChunk); + ForgeChunkManager.forceChunk(ticket, quarryChunk); for (int chunkX = box.xMin >> 4; chunkX <= box.xMax >> 4; chunkX ++) { for (int chunkZ = box.zMin >> 4; chunkZ <= box.zMax >> 4; chunkZ ++) { - ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(chunkX, chunkZ)); + ChunkCoordIntPair chunk = new ChunkCoordIntPair(chunkX, chunkZ); + ForgeChunkManager.forceChunk(ticket, chunk); + chunks.add(chunk); } } + if (placedBy != null) + { + PacketDispatcher.sendPacketToPlayer(new Packet3Chat(String.format("[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded",xCoord, yCoord, zCoord, chunks.size())),(Player) placedBy); + } + sendNetworkUpdate(); } } From ba1562b67f2555c3a19b4710f3a185b23b3a3e80 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 1 Oct 2012 23:21:53 -0400 Subject: [PATCH 14/18] Revert broken pipe logic changes. No pipes are connecting anywhere now.. Revert "Update common/buildcraft/transport/PipeTransportItems.java" This reverts commit 07cca7ad0500326305a945a48b74f8f154730d60. Revert "Fixes pipes connecting improperly" This reverts commit e7bd894e151f5d238193e3f091161ce55fca7dd7. --- common/buildcraft/transport/Pipe.java | 7 ------- .../buildcraft/transport/PipeTransportItems.java | 16 ++++++---------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index 0525d9ad..8de03432 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -16,7 +16,6 @@ import java.util.Random; import buildcraft.BuildCraftTransport; import buildcraft.api.core.Orientations; -import buildcraft.api.core.Position; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.Action; import buildcraft.api.gates.ActionManager; @@ -27,7 +26,6 @@ import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.Trigger; import buildcraft.api.gates.TriggerParameter; import buildcraft.api.transport.IPipe; -import buildcraft.api.transport.IPipeConnection; import buildcraft.core.IDropControlInventory; import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.triggers.ActionRedstoneOutput; @@ -133,11 +131,6 @@ public abstract class Pipe implements IPipe, IDropControlInventory { } public boolean isPipeConnected(TileEntity tile) { - if( tile instanceof IPipeConnection ){ - Orientations or = Utils.get3dOrientation(new Position(this.container), new Position(tile)); - if( !((IPipeConnection) tile).isPipeConnected(or) ) - return false; - } return logic.isPipeConnected(tile) && transport.isPipeConnected(tile); } diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index 31103aba..740bbfc8 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -41,7 +41,6 @@ import net.minecraft.src.NBTTagCompound; import net.minecraft.src.NBTTagList; import net.minecraft.src.Packet; import net.minecraft.src.TileEntity; -import net.minecraftforge.common.ISidedInventory; public class PipeTransportItems extends PipeTransport { @@ -146,12 +145,13 @@ public class PipeTransportItems extends PipeTransport { if (!Utils.checkPipesConnections(entity, container)) return false; - if (entity instanceof TileGenericPipe) - if (container.pipe.transport instanceof PipeTransportItems) - return container.pipe.transport.inputOpen(o); if (entity instanceof IPipeEntry) - return ((IPipeEntry) entity).acceptItems(); - if (entity instanceof IInventory) + return true; + else if (entity instanceof TileGenericPipe) { + TileGenericPipe pipe = (TileGenericPipe) entity; + + return pipe.pipe.transport instanceof PipeTransportItems; + } else if (entity instanceof IInventory) if(Transactor.getTransactorFor(entity).add(item.getItemStack(), o.reverse(), false).stackSize > 0) return true; @@ -437,10 +437,6 @@ public class PipeTransportItems extends PipeTransport { @Override public boolean isPipeConnected(TileEntity tile) { - if( tile instanceof ISidedInventory ){ - Orientations or = Utils.get3dOrientation(new Position(container), new Position(tile)); - return ((ISidedInventory) tile).getSizeInventorySide(or.toDirection()) > 0; - } return tile instanceof TileGenericPipe || tile instanceof IPipeEntry || tile instanceof ISpecialInventory From 890c4d45e9c757782ff11e2071a700f7d17e2f87 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 1 Oct 2012 23:37:17 -0400 Subject: [PATCH 15/18] Fix addToRandomInventory putting stuff from quarries etc into adjacent engines.. --- common/buildcraft/core/utils/Utils.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/buildcraft/core/utils/Utils.java b/common/buildcraft/core/utils/Utils.java index 060e8f01..d2d7215c 100644 --- a/common/buildcraft/core/utils/Utils.java +++ b/common/buildcraft/core/utils/Utils.java @@ -68,28 +68,28 @@ public class Utils { for(Orientations orientation : Orientations.values()) { if(from.reverse() == orientation) continue; - + Position pos = new Position(x, y, z, orientation); pos.moveForwards(1.0); TileEntity tileInventory = world.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); ITransactor transactor = Transactor.getTransactorFor(tileInventory); - if(transactor != null + if(transactor != null && !(tileInventory instanceof TileBuildCraft) && transactor.add(stack, from, false).stackSize > 0) possibleInventories.add(transactor); } - + if (possibleInventories.size() > 0) { int choice = world.rand.nextInt(possibleInventories.size()); return possibleInventories.get(choice).add(stack, from, true); } - + ItemStack added = stack.copy(); added.stackSize = 0; return added; - + } - + /** * Depending on the kind of item in the pipe, set the floor at a different * level to optimize graphical aspect. @@ -180,7 +180,7 @@ public class Utils { public static void dropItems(World world, ItemStack stack, int i, int j, int k) { if(stack.stackSize <= 0) return; - + float f1 = 0.7F; double d = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D; double d1 = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D; From e8571a8e53926d1b621c76ef103e0d6a6b48c7e3 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 1 Oct 2012 23:56:26 -0400 Subject: [PATCH 16/18] Fix up a bunch of "markBlockAsNeedsUpdate" to markBlockNeedsUpdate" and fixed engine to notify neighbours This fixes the engine being a bit derpy when being rotated --- common/buildcraft/builders/TileFiller.java | 18 +++++++-------- common/buildcraft/energy/TileEngine.java | 22 +++++++++---------- .../buildcraft/transport/TileGenericPipe.java | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/common/buildcraft/builders/TileFiller.java b/common/buildcraft/builders/TileFiller.java index 38fa8a28..34df93bf 100644 --- a/common/buildcraft/builders/TileFiller.java +++ b/common/buildcraft/builders/TileFiller.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -136,7 +136,7 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo } if (done) { - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); sendNetworkUpdate(); } } @@ -177,7 +177,7 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo } if (worldObj != null) { - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); } if (currentPattern == null) { @@ -309,7 +309,7 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo super.handleDescriptionPacket(packet); currentPattern = FillerManager.registry.getPattern(currentPatternId); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); if (!initialized && box.isInitialized()) { box.createLasers(worldObj, LaserKind.Stripes); @@ -323,7 +323,7 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo super.handleUpdatePacket(packet); currentPattern = FillerManager.registry.getPattern(currentPatternId); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); if (!initialized && box.isInitialized()) { box.createLasers(worldObj, LaserKind.Stripes); @@ -393,11 +393,11 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo /* ISPECIALINVENTORY */ @Override public int addItem(ItemStack stack, boolean doAdd, Orientations from) { - + ITransactor transactor = new TransactorSimple(this); ItemStack added = transactor.add(stack, from, doAdd); return added.stackSize; - + } @Override diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index b272af17..fdb80c55 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -38,7 +38,7 @@ import net.minecraft.src.NBTTagCompound; import net.minecraft.src.Packet; import net.minecraft.src.TileEntity; -//TODO: All Engines need to take func_48081_b into account +//TODO: All Engines need to take func_48081_b into account public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInventory, ITankContainer, IEngineProvider, IOverrideDefaultTriggers, IPipeConnection, IBuilderInventory { @@ -132,7 +132,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven progressPart = 0; } } else if (isRedstonePowered && engine.isActive()) { - + Position pos = new Position(xCoord, yCoord, zCoord, engine.orientation); pos.moveForwards(1.0); TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); @@ -148,7 +148,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven setActive(false); } else setActive(false); - + } else setActive(false); @@ -158,11 +158,11 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven private void setActive(boolean isActive) { if(this.isActive == isActive) return; - + this.isActive = isActive; sendNetworkUpdate(); } - + private void createEngineIfNeeded() { if (engine == null) { int kind = worldObj.getBlockMetadata(xCoord, yCoord, zCoord); @@ -189,8 +189,8 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven engine.orientation = o; } orientation = o.ordinal(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); - + worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord)); break; } } @@ -466,7 +466,7 @@ public class TileEngine extends TileBuildCraft implements IPowerReceptor, IInven public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain) { return null; } - + @Override public LiquidTank[] getTanks() { if (engine == null) { diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 9cec1306..ae2eb66d 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -371,7 +371,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank initialize(BlockGenericPipe.createPipe(packet.getPipeId())); } renderState = packet.getRenderState(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); } return; } @@ -613,7 +613,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank } break; } - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); } @Override From 5885f08fabbd88028dda8663c7165ce00c854dc7 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 2 Oct 2012 00:09:26 -0400 Subject: [PATCH 17/18] IronEngines now accept Ice at a 1:1 ratio with water buckets, assuming your engine is hot --- common/buildcraft/energy/EngineIron.java | 30 ++++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/common/buildcraft/energy/EngineIron.java b/common/buildcraft/energy/EngineIron.java index d6ccefd8..1bc4012c 100644 --- a/common/buildcraft/energy/EngineIron.java +++ b/common/buildcraft/energy/EngineIron.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -18,7 +18,9 @@ import buildcraft.api.liquids.LiquidTank; import buildcraft.core.DefaultProps; import buildcraft.core.utils.Utils; import buildcraft.energy.gui.ContainerEngine; +import net.minecraft.src.Block; import net.minecraft.src.ICrafting; +import net.minecraft.src.Item; import net.minecraft.src.ItemStack; import net.minecraft.src.NBTTagCompound; @@ -125,7 +127,15 @@ public class EngineIron extends Engine { super.update(); if (itemInInventory != null) { - LiquidStack liquid = LiquidManager.getLiquidForFilledItem(itemInInventory); + LiquidStack liquid = null; + if (Block.ice.blockID == itemInInventory.itemID && heat > COOLANT_THRESHOLD) + { + liquid = LiquidManager.getLiquidForFilledItem(new ItemStack(Item.bucketWater)); + } + else + { + liquid = LiquidManager.getLiquidForFilledItem(itemInInventory); + } if (liquid != null) { if (fill(Orientations.Unknown, liquid, false) == liquid.amount) { @@ -190,7 +200,7 @@ public class EngineIron extends Engine { coolantQty = nbttagcompound.getInteger("coolantQty"); heat = nbttagcompound.getInteger("heat"); penaltyCooling = nbttagcompound.getInteger("penaltyCooling"); - + if (nbttagcompound.hasKey("itemInInventory")) { NBTTagCompound cpt = nbttagcompound.getCompoundTag("itemInInventory"); itemInInventory = ItemStack.loadItemStackFromNBT(cpt); @@ -206,8 +216,8 @@ public class EngineIron extends Engine { nbttagcompound.setInteger("coolantId", coolantId); nbttagcompound.setInteger("coolantQty", coolantQty); nbttagcompound.setInteger("heat", heat); - nbttagcompound.setInteger("penaltyCooling", penaltyCooling); - + nbttagcompound.setInteger("penaltyCooling", penaltyCooling); + if (itemInInventory != null) { NBTTagCompound cpt = new NBTTagCompound(); itemInInventory.writeToNBT(cpt); @@ -272,10 +282,10 @@ public class EngineIron extends Engine { public int getHeat() { return heat; } - + /* ITANKCONTAINER */ public int fill(Orientations from, LiquidStack resource, boolean doFill) { - + // Handle coolant if (IronEngineCoolant.getCoolantForLiquid(resource) != null) return fillCoolant(from, resource, doFill); @@ -337,7 +347,7 @@ public class EngineIron extends Engine { new LiquidTank(coolantId, coolantQty, MAX_LIQUID) }; } - + /* IINVENTORY */ @Override public int getSizeInventory() { return 1; } @Override public ItemStack getStackInSlot(int i) { return itemInInventory; } From 7fcc3dcd54e3333b9caf827a1654e0ac39a249e7 Mon Sep 17 00:00:00 2001 From: Andrew Hill Date: Fri, 5 Oct 2012 17:01:23 +1000 Subject: [PATCH 18/18] fix for #301 filler is now sided - top for pattern, all other sides for inventory. --- common/buildcraft/builders/TileFiller.java | 51 ++++++++++------------ 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/common/buildcraft/builders/TileFiller.java b/common/buildcraft/builders/TileFiller.java index 34df93bf..67994e10 100644 --- a/common/buildcraft/builders/TileFiller.java +++ b/common/buildcraft/builders/TileFiller.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -12,20 +12,16 @@ package buildcraft.builders; import buildcraft.BuildCraftCore; import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.LaserKind; -import buildcraft.api.core.Orientations; import buildcraft.api.filler.FillerManager; import buildcraft.api.filler.IFillerPattern; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IActionReceptor; -import buildcraft.api.inventory.ISpecialInventory; import buildcraft.api.power.IPowerProvider; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerFramework; import buildcraft.core.Box; import buildcraft.core.IMachine; import buildcraft.core.TileBuildCraft; -import buildcraft.core.inventory.ITransactor; -import buildcraft.core.inventory.TransactorSimple; import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.TileNetworkData; import buildcraft.core.proxy.CoreProxy; @@ -35,8 +31,10 @@ import buildcraft.core.utils.Utils; import net.minecraft.src.EntityPlayer; import net.minecraft.src.ItemStack; import net.minecraft.src.NBTTagCompound; +import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.ISidedInventory; -public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPowerReceptor, IMachine, IActionReceptor { +public class TileFiller extends TileBuildCraft implements ISidedInventory, IPowerReceptor, IMachine, IActionReceptor { public @TileNetworkData Box box = new Box(); @@ -390,29 +388,24 @@ public class TileFiller extends TileBuildCraft implements ISpecialInventory, IPo return true; } - /* ISPECIALINVENTORY */ - @Override - public int addItem(ItemStack stack, boolean doAdd, Orientations from) { - - ITransactor transactor = new TransactorSimple(this); - ItemStack added = transactor.add(stack, from, doAdd); - return added.stackSize; - + /** + * Get the start of the side inventory. + * @param side The global side to get the start of range. + */ + public int getStartInventorySide(ForgeDirection side) { + if(side == ForgeDirection.UP) + return 0; + return 9; } - @Override - public ItemStack[] extractItem(boolean doRemove, Orientations from, int maxItemCount) { - for (int i = 9; i < contents.length; ++i) { - if (contents[i] != null) { - if (doRemove) { - return new ItemStack[] { decrStackSize(i, 1) }; - } else { - return new ItemStack[] { contents[i] }; - } - } - } + /** + * Get the size of the side inventory. + * @param side The global side. + */ + public int getSizeInventorySide(ForgeDirection side) { + if(side == ForgeDirection.UP) + return 9; + return getSizeInventory()-9; - return null; } - }