add gate verification post-copy, fix minor update bug

This commit is contained in:
asiekierka 2014-10-26 07:32:12 +01:00
parent 59686cd481
commit fd370955bd
5 changed files with 78 additions and 21 deletions

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

View file

@ -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<ITrigger> triggerList = getAllValidTriggers();
List<IAction> 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<ITrigger> getAllValidTriggers() {
ArrayList<ITrigger> triggers = new ArrayList<ITrigger>(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<IAction> list) {
@ -501,15 +549,20 @@ public final class Gate implements IGate {
expansion.addActions(list);
}
}
public LinkedList<IAction> getActions() {
LinkedList<IAction> result = new LinkedList<IAction>();
addActions(result);
return result;
public List<IAction> getAllValidActions() {
ArrayList<IAction> actions = new ArrayList<IAction>(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) {

View file

@ -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;
}

View file

@ -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<ITrigger> it = potentialTriggers.iterator();