Clean up some Gate code
This commit is contained in:
parent
5353a47aec
commit
8995ff79bf
4 changed files with 37 additions and 37 deletions
|
@ -36,7 +36,7 @@ public interface IPipe {
|
||||||
|
|
||||||
public boolean isWired(WireColor color);
|
public boolean isWired(WireColor color);
|
||||||
|
|
||||||
public boolean hasInterface();
|
public boolean hasGate();
|
||||||
|
|
||||||
public TileEntity getContainer();
|
public TileEntity getContainer();
|
||||||
|
|
||||||
|
|
|
@ -586,8 +586,8 @@ public class BlockGenericPipe extends BlockContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float xOffset, float yOffset, float zOffset) {
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset) {
|
||||||
super.onBlockActivated(world, x, y, z, entityplayer, side, xOffset, yOffset, zOffset);
|
super.onBlockActivated(world, x, y, z, player, side, xOffset, yOffset, zOffset);
|
||||||
|
|
||||||
world.notifyBlocksOfNeighborChange(x, y, z, BuildCraftTransport.genericPipeBlock.blockID);
|
world.notifyBlocksOfNeighborChange(x, y, z, BuildCraftTransport.genericPipeBlock.blockID);
|
||||||
|
|
||||||
|
@ -597,70 +597,70 @@ public class BlockGenericPipe extends BlockContainer {
|
||||||
|
|
||||||
// / Right click while sneaking without wrench to strip equipment
|
// / Right click while sneaking without wrench to strip equipment
|
||||||
// from the pipe.
|
// from the pipe.
|
||||||
if (entityplayer.isSneaking()
|
if (player.isSneaking()
|
||||||
&& (entityplayer.getCurrentEquippedItem() == null || !(entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench))) {
|
&& (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof IToolWrench))) {
|
||||||
|
|
||||||
if (pipe.hasGate() || pipe.isWired())
|
if (pipe.hasGate() || pipe.isWired())
|
||||||
return stripEquipment(pipe);
|
return stripEquipment(pipe);
|
||||||
|
|
||||||
} else if (entityplayer.getCurrentEquippedItem() == null) {
|
} else if (player.getCurrentEquippedItem() == null) {
|
||||||
// Fall through the end of the test
|
// Fall through the end of the test
|
||||||
} else if (entityplayer.getCurrentEquippedItem().itemID == Item.sign.itemID)
|
} else if (player.getCurrentEquippedItem().itemID == Item.sign.itemID)
|
||||||
// Sign will be placed anyway, so lets show the sign gui
|
// Sign will be placed anyway, so lets show the sign gui
|
||||||
return false;
|
return false;
|
||||||
else if (entityplayer.getCurrentEquippedItem().getItem() instanceof ItemPipe)
|
else if (player.getCurrentEquippedItem().getItem() instanceof ItemPipe)
|
||||||
return false;
|
return false;
|
||||||
else if (entityplayer.getCurrentEquippedItem().getItem() instanceof IToolWrench)
|
else if (player.getCurrentEquippedItem().getItem() instanceof IToolWrench)
|
||||||
// Only check the instance at this point. Call the IToolWrench
|
// Only check the instance at this point. Call the IToolWrench
|
||||||
// interface callbacks for the individual pipe/logic calls
|
// interface callbacks for the individual pipe/logic calls
|
||||||
return pipe.blockActivated(entityplayer);
|
return pipe.blockActivated(player);
|
||||||
else if (entityplayer.getCurrentEquippedItem().getItem() == BuildCraftTransport.redPipeWire) {
|
else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.redPipeWire) {
|
||||||
if (!pipe.wireSet[IPipe.WireColor.Red.ordinal()]) {
|
if (!pipe.wireSet[IPipe.WireColor.Red.ordinal()]) {
|
||||||
pipe.wireSet[IPipe.WireColor.Red.ordinal()] = true;
|
pipe.wireSet[IPipe.WireColor.Red.ordinal()] = true;
|
||||||
if (!entityplayer.capabilities.isCreativeMode) {
|
if (!player.capabilities.isCreativeMode) {
|
||||||
entityplayer.getCurrentEquippedItem().splitStack(1);
|
player.getCurrentEquippedItem().splitStack(1);
|
||||||
}
|
}
|
||||||
pipe.signalStrength[IPipe.WireColor.Red.ordinal()] = 0;
|
pipe.signalStrength[IPipe.WireColor.Red.ordinal()] = 0;
|
||||||
pipe.container.scheduleNeighborChange();
|
pipe.container.scheduleNeighborChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (entityplayer.getCurrentEquippedItem().getItem() == BuildCraftTransport.bluePipeWire) {
|
} else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.bluePipeWire) {
|
||||||
if (!pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) {
|
if (!pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) {
|
||||||
pipe.wireSet[IPipe.WireColor.Blue.ordinal()] = true;
|
pipe.wireSet[IPipe.WireColor.Blue.ordinal()] = true;
|
||||||
if (!entityplayer.capabilities.isCreativeMode) {
|
if (!player.capabilities.isCreativeMode) {
|
||||||
entityplayer.getCurrentEquippedItem().splitStack(1);
|
player.getCurrentEquippedItem().splitStack(1);
|
||||||
}
|
}
|
||||||
pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] = 0;
|
pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] = 0;
|
||||||
pipe.container.scheduleNeighborChange();
|
pipe.container.scheduleNeighborChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (entityplayer.getCurrentEquippedItem().getItem() == BuildCraftTransport.greenPipeWire) {
|
} else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.greenPipeWire) {
|
||||||
if (!pipe.wireSet[IPipe.WireColor.Green.ordinal()]) {
|
if (!pipe.wireSet[IPipe.WireColor.Green.ordinal()]) {
|
||||||
pipe.wireSet[IPipe.WireColor.Green.ordinal()] = true;
|
pipe.wireSet[IPipe.WireColor.Green.ordinal()] = true;
|
||||||
if (!entityplayer.capabilities.isCreativeMode) {
|
if (!player.capabilities.isCreativeMode) {
|
||||||
entityplayer.getCurrentEquippedItem().splitStack(1);
|
player.getCurrentEquippedItem().splitStack(1);
|
||||||
}
|
}
|
||||||
pipe.signalStrength[IPipe.WireColor.Green.ordinal()] = 0;
|
pipe.signalStrength[IPipe.WireColor.Green.ordinal()] = 0;
|
||||||
pipe.container.scheduleNeighborChange();
|
pipe.container.scheduleNeighborChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (entityplayer.getCurrentEquippedItem().getItem() == BuildCraftTransport.yellowPipeWire) {
|
} else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.yellowPipeWire) {
|
||||||
if (!pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) {
|
if (!pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) {
|
||||||
pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] = true;
|
pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] = true;
|
||||||
if (!entityplayer.capabilities.isCreativeMode) {
|
if (!player.capabilities.isCreativeMode) {
|
||||||
entityplayer.getCurrentEquippedItem().splitStack(1);
|
player.getCurrentEquippedItem().splitStack(1);
|
||||||
}
|
}
|
||||||
pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] = 0;
|
pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] = 0;
|
||||||
pipe.container.scheduleNeighborChange();
|
pipe.container.scheduleNeighborChange();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (entityplayer.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGate.itemID
|
} else if (player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGate.itemID
|
||||||
|| entityplayer.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGateAutarchic.itemID)
|
|| player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGateAutarchic.itemID)
|
||||||
if (!pipe.hasInterface()) {
|
if (!pipe.hasGate()) {
|
||||||
|
|
||||||
pipe.gate = new GateVanilla(pipe, entityplayer.getCurrentEquippedItem());
|
pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem());
|
||||||
if (!entityplayer.capabilities.isCreativeMode) {
|
if (!player.capabilities.isCreativeMode) {
|
||||||
entityplayer.getCurrentEquippedItem().splitStack(1);
|
player.getCurrentEquippedItem().splitStack(1);
|
||||||
}
|
}
|
||||||
pipe.container.scheduleRenderUpdate();
|
pipe.container.scheduleRenderUpdate();
|
||||||
return true;
|
return true;
|
||||||
|
@ -669,7 +669,7 @@ public class BlockGenericPipe extends BlockContainer {
|
||||||
boolean openGateGui = false;
|
boolean openGateGui = false;
|
||||||
|
|
||||||
if (pipe.hasGate()) {
|
if (pipe.hasGate()) {
|
||||||
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, entityplayer);
|
RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player);
|
||||||
|
|
||||||
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) {
|
if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) {
|
||||||
openGateGui = true;
|
openGateGui = true;
|
||||||
|
@ -677,11 +677,11 @@ public class BlockGenericPipe extends BlockContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openGateGui) {
|
if (openGateGui) {
|
||||||
pipe.gate.openGui(entityplayer);
|
pipe.gate.openGui(player);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return pipe.blockActivated(entityplayer);
|
return pipe.blockActivated(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -289,9 +289,13 @@ public abstract class Gate {
|
||||||
return stack.itemID == BuildCraftTransport.pipeGate.itemID || stack.itemID == BuildCraftTransport.pipeGateAutarchic.itemID;
|
return stack.itemID == BuildCraftTransport.pipeGate.itemID || stack.itemID == BuildCraftTransport.pipeGateAutarchic.itemID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Gate makeGateFromNBT(NBTTagCompound data, Pipe pipe) {
|
public static Gate makeGate(Pipe pipe, NBTTagCompound data) {
|
||||||
Gate gate = new GateVanilla(pipe);
|
Gate gate = new GateVanilla(pipe);
|
||||||
gate.readFromNBT(data);
|
gate.readFromNBT(data);
|
||||||
return gate;
|
return gate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Gate makeGate(Pipe pipe, ItemStack stack) {
|
||||||
|
return new GateVanilla(pipe, stack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ public abstract class Pipe implements IPipe, IDropControlInventory {
|
||||||
// Load pulser if any
|
// Load pulser if any
|
||||||
if (data.hasKey("Gate")) {
|
if (data.hasKey("Gate")) {
|
||||||
NBTTagCompound gateNBT = data.getCompoundTag("Gate");
|
NBTTagCompound gateNBT = data.getCompoundTag("Gate");
|
||||||
gate = Gate.makeGateFromNBT(gateNBT, this);
|
gate = Gate.makeGate(this, gateNBT);
|
||||||
} else if (data.hasKey("gateKind")) {
|
} else if (data.hasKey("gateKind")) {
|
||||||
// Legacy implementation
|
// Legacy implementation
|
||||||
Gate.GateKind kind = Gate.GateKind.values()[data.getInteger("gateKind")];
|
Gate.GateKind kind = Gate.GateKind.values()[data.getInteger("gateKind")];
|
||||||
|
@ -362,10 +362,6 @@ public abstract class Pipe implements IPipe, IDropControlInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasInterface() {
|
|
||||||
return hasGate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasGate() {
|
public boolean hasGate() {
|
||||||
return gate != null;
|
return gate != null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue