@Override public void afterStateUpdated(byte stateId) { if (!worldObj.isRemote) return; switch (stateId) { case 0: if (pipe == null && coreState.pipeId != 0) { initialize(BlockGenericPipe.createPipe(coreState.pipeId)); } if (pipe != null) { if (pipe.gate == null) { pipe.gate = new GateVanilla(pipe); } pipe.gate.kind = GateKind.values()[coreState.gateKind]; } break; } worldObj.markBlockNeedsUpdate(xCoord, yCoord, zCoord); }
@Override 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, player, side, xOffset, yOffset, zOffset); world.notifyBlocksOfNeighborChange(x, y, z, BuildCraftTransport.genericPipeBlock.blockID); Pipe pipe = getPipe(world, x, y, z); if (isValid(pipe)) { // / Right click while sneaking without wrench to strip equipment // from the pipe. if (player.isSneaking() && (player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof IToolWrench))) { if (pipe.hasGate() || pipe.isWired()) return stripEquipment(pipe); } else if (player.getCurrentEquippedItem() == null) { // Fall through the end of the test } else if (player.getCurrentEquippedItem().itemID == Item.sign.itemID) // Sign will be placed anyway, so lets show the sign gui return false; else if (player.getCurrentEquippedItem().getItem() instanceof ItemPipe) return false; else if (player.getCurrentEquippedItem().getItem() instanceof IToolWrench) // Only check the instance at this point. Call the IToolWrench // interface callbacks for the individual pipe/logic calls return pipe.blockActivated(player); else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.redPipeWire) { if (!pipe.wireSet[IPipe.WireColor.Red.ordinal()]) { pipe.wireSet[IPipe.WireColor.Red.ordinal()] = true; if (!player.capabilities.isCreativeMode) { player.getCurrentEquippedItem().splitStack(1); } pipe.signalStrength[IPipe.WireColor.Red.ordinal()] = 0; pipe.container.scheduleNeighborChange(); return true; } } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.bluePipeWire) { if (!pipe.wireSet[IPipe.WireColor.Blue.ordinal()]) { pipe.wireSet[IPipe.WireColor.Blue.ordinal()] = true; if (!player.capabilities.isCreativeMode) { player.getCurrentEquippedItem().splitStack(1); } pipe.signalStrength[IPipe.WireColor.Blue.ordinal()] = 0; pipe.container.scheduleNeighborChange(); return true; } } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.greenPipeWire) { if (!pipe.wireSet[IPipe.WireColor.Green.ordinal()]) { pipe.wireSet[IPipe.WireColor.Green.ordinal()] = true; if (!player.capabilities.isCreativeMode) { player.getCurrentEquippedItem().splitStack(1); } pipe.signalStrength[IPipe.WireColor.Green.ordinal()] = 0; pipe.container.scheduleNeighborChange(); return true; } } else if (player.getCurrentEquippedItem().getItem() == BuildCraftTransport.yellowPipeWire) { if (!pipe.wireSet[IPipe.WireColor.Yellow.ordinal()]) { pipe.wireSet[IPipe.WireColor.Yellow.ordinal()] = true; if (!player.capabilities.isCreativeMode) { player.getCurrentEquippedItem().splitStack(1); } pipe.signalStrength[IPipe.WireColor.Yellow.ordinal()] = 0; pipe.container.scheduleNeighborChange(); return true; } } else if (player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGate.itemID || player.getCurrentEquippedItem().itemID == BuildCraftTransport.pipeGateAutarchic.itemID) if (!pipe.hasGate()) { pipe.gate = Gate.makeGate(pipe, player.getCurrentEquippedItem()); if (!player.capabilities.isCreativeMode) { player.getCurrentEquippedItem().splitStack(1); } pipe.container.scheduleRenderUpdate(); return true; } boolean openGateGui = false; if (pipe.hasGate()) { RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); if (rayTraceResult != null && rayTraceResult.hitPart == Part.Gate) { openGateGui = true; } } if (openGateGui) { pipe.gate.openGui(player); return true; } else return pipe.blockActivated(player); } return false; }