From fd370955bdda140ff317e41070197f328dfd4266 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Sun, 26 Oct 2014 07:32:12 +0100 Subject: [PATCH] add gate verification post-copy, fix minor update bug --- .../assets/buildcraft/lang/en_US.lang | 13 +++- .../textures/blocks/pipeStainedOverlay.png | Bin 0 -> 161 bytes common/buildcraft/transport/Gate.java | 69 ++++++++++++++++-- .../buildcraft/transport/ItemGateCopier.java | 6 +- .../transport/gui/ContainerGateInterface.java | 11 +-- 5 files changed, 78 insertions(+), 21 deletions(-) create mode 100644 buildcraft_resources/assets/buildcraft/textures/blocks/pipeStainedOverlay.png diff --git a/buildcraft_resources/assets/buildcraft/lang/en_US.lang b/buildcraft_resources/assets/buildcraft/lang/en_US.lang index c3f30ce9..9b765577 100644 --- a/buildcraft_resources/assets/buildcraft/lang/en_US.lang +++ b/buildcraft_resources/assets/buildcraft/lang/en_US.lang @@ -18,6 +18,16 @@ buildcraft.boardRobotCrafter=Crafter buildcraft.boardRobotDelivery=Delivery buildcraft.boardRobotPump=Pump +chat.gateCopier.clear=Gate information cleared. +chat.gateCopier.gateCopied=Copied gate information to copier. +chat.gateCopier.gatePasted=Pasted copied data to gate. +chat.gateCopier.noGate=No gate found on this side! +chat.gateCopier.noInformation=No gate information stored! +chat.gateCopier.warning.actionParameters=§6Warning: Target has less action parameters! +chat.gateCopier.warning.logic=§6Warning: Target has different logic type! +chat.gateCopier.warning.load=§6Warning: Gate triggers/actions might be missing! +chat.gateCopier.warning.slots=§6Warning: Target has less slots! +chat.gateCopier.warning.triggerParameters=§6Warning: Target has less trigger parameters! chat.pipe.power.iron.mode=Switched to %d RF/t limit color.black=Black @@ -147,7 +157,6 @@ gui.pipes.emzuli.title=Extraction Presets gui.pipes.emzuli.paint=Paint Items %s gui.pipes.emzuli.nopaint=Don't Paint Items -item.scienceBook.name=Engineering Science Book item.bucketFuel.name=Fuel Bucket item.bucketOil.name=Oil Bucket item.woodenGearItem.name=Wood Gear @@ -259,8 +268,6 @@ tile.refineryBlock.name=Refinery tile.spring.oil.name=Oil Spring tile.spring.water.name=Water Spring tile.tankBlock.name=Tank -tile.energyConverter.name=Energy Converter -tile.energyConverter.tooltip=Convert BC energy between old and new power API|Added for compatibility with other mods|while they are not migrated to the new power API.|Could be removed in the future. tile.zonePlan.name=Zone Planner tile.architect.rotate=Rotate: On diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeStainedOverlay.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeStainedOverlay.png new file mode 100644 index 0000000000000000000000000000000000000000..3c536afbe894017cf8acb3083fef2d1789f081d8 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPqmn65oxZLelpa_GWr;B5V#p&b}2j>6(|9?+Bz$_st yxn1G&ObHDZ=6nWaMSK1_{T?ZY-V%dZ;t~vJOu5s4%UrPqY4vpVb6Mw<&;$V1swx=( literal 0 HcmV?d00001 diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index 5e319651..8787a7c9 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -10,12 +10,14 @@ package buildcraft.transport; import java.util.ArrayList; import java.util.BitSet; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; +import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -223,6 +225,39 @@ public final class Gate implements IGate { } } + public boolean verifyGateStatements() { + List triggerList = getAllValidTriggers(); + List actionList = getAllValidActions(); + boolean warning = false; + + for (int i = 0; i < MAX_STATEMENTS; ++i) { + if ((triggers[i] != null || actions[i] != null) && i >= material.numSlots) { + triggers[i] = null; + actions[i] = null; + warning = true; + continue; + } + + if (triggers[i] != null) { + if (!triggerList.contains(triggers[i]) || + triggers[i].minParameters() > material.numTriggerParameters) { + triggers[i] = null; + warning = true; + } + } + + if (actions[i] != null) { + if (!actionList.contains(actions[i]) || + actions[i].minParameters() > material.numActionParameters) { + actions[i] = null; + warning = true; + } + } + } + + return !warning; + } + public void readFromNBT(NBTTagCompound data) { readStatementsFromNBT(data); @@ -488,6 +523,19 @@ public final class Gate implements IGate { expansion.addTriggers(list); } } + + public List getAllValidTriggers() { + ArrayList triggers = new ArrayList(64); + triggers.addAll(StatementManager.getPipeTriggers(pipe.container)); + + for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = pipe.container.getTile(o); + Block block = pipe.container.getBlock(o); + triggers.addAll(StatementManager.getNeighborTriggers(block, tile)); + } + + return triggers; + } // ACTIONS public void addActions(List list) { @@ -501,15 +549,20 @@ public final class Gate implements IGate { expansion.addActions(list); } } - - public LinkedList getActions() { - LinkedList result = new LinkedList(); - - addActions(result); - - return result; + + public List getAllValidActions() { + ArrayList actions = new ArrayList(64); + actions.addAll(StatementManager.getPipeActions(pipe.container)); + + for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = pipe.container.getTile(o); + Block block = pipe.container.getBlock(o); + actions.addAll(StatementManager.getNeighborActions(block, tile)); + } + + return actions; } - + @Override public void setPulsing(boolean pulsing) { if (pulsing != isPulsing) { diff --git a/common/buildcraft/transport/ItemGateCopier.java b/common/buildcraft/transport/ItemGateCopier.java index 8a5e22ea..b060f337 100644 --- a/common/buildcraft/transport/ItemGateCopier.java +++ b/common/buildcraft/transport/ItemGateCopier.java @@ -87,7 +87,11 @@ public class ItemGateCopier extends ItemBuildCraft { } gate.readStatementsFromNBT(data); - + if (!gate.verifyGateStatements()) { + player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.warning.load")); + } + + ((TileGenericPipe) tile).sendUpdateToClient(); player.addChatMessage(new ChatComponentTranslation("chat.gateCopier.gatePasted")); return true; } diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index 6e727216..ba2ad1bf 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -105,15 +105,8 @@ public class ContainerGateInterface extends BuildCraftContainer { // Do not attempt to create a list of potential actions and triggers on // the client. if (!pipe.container.getWorldObj().isRemote) { - potentialTriggers.addAll(StatementManager.getPipeTriggers(pipe.container)); - potentialActions.addAll(StatementManager.getPipeActions(pipe.container)); - - for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { - TileEntity tile = pipe.container.getTile(o); - Block block = pipe.container.getBlock(o); - potentialTriggers.addAll(StatementManager.getNeighborTriggers(block, tile)); - potentialActions.addAll(StatementManager.getNeighborActions(block, tile)); - } + potentialTriggers.addAll(gate.getAllValidTriggers()); + potentialActions.addAll(gate.getAllValidActions()); if (gate.material.numTriggerParameters == 0) { Iterator it = potentialTriggers.iterator();