Package buildcraft.api.transport

Examples of buildcraft.api.transport.IPipePluggable


      bcRenderState.gateMatrix.setIsGateLit(gate != null && gate.isGateActive(), direction);
      bcRenderState.gateMatrix.setIsGatePulsing(gate != null && gate.isGatePulsing(), direction);
    }
    // Facades
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
      IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
      if (!(pluggable instanceof ItemFacade.FacadePluggable)) {
        bcRenderState.facadeMatrix.setFacade(direction, null, 0, true);
        continue;
      }
      ItemFacade.FacadeState[] states = ((ItemFacade.FacadePluggable) pluggable).states;
      if (states == null) {
        bcRenderState.facadeMatrix.setFacade(direction, null, 0, true);
        continue;
      }
      // Iterate over all states and activate first proper
      ItemFacade.FacadeState defaultState = null, activeState = null;
      for (ItemFacade.FacadeState state : states) {
        if (state.wire == null) {
          defaultState = state;
          continue;
        }
        if (getBCPipePart().isWireActive(state.wire)) {
          activeState = state;
          break;
        }
      }
      if (activeState == null) {
        activeState = defaultState;
      }
      Block block = activeState != null ? activeState.block : null;
      int metadata = activeState != null ? activeState.metadata : 0;
      boolean transparent = activeState == null || block == null;
      bcRenderState.facadeMatrix.setFacade(direction, block, metadata, transparent);
    }

    //Plugs
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
      IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
      bcRenderState.plugMatrix.setConnected(direction, pluggable instanceof ItemPlug.PlugPluggable);

      if (pluggable instanceof ItemRobotStation.RobotStationPluggable) {
        DockingStation station = ((ItemRobotStation.RobotStationPluggable) pluggable).getStation();
View Full Code Here


    return setPluggable(direction, new ItemGate.GatePluggable((Gate)gate));
  }

  @Override
  public Object getStation(ForgeDirection direction) {
    IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
    return pluggable instanceof ItemRobotStation.RobotStationPluggable ? ((ItemRobotStation.RobotStationPluggable) pluggable).getStation() : null;
  }
View Full Code Here

    return pluggable instanceof ItemRobotStation.RobotStationPluggable ? ((ItemRobotStation.RobotStationPluggable) pluggable).getStation() : null;
  }

  @Override
  public ItemStack getFacade(ForgeDirection direction) {
    IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
    return pluggable instanceof ItemFacade.FacadePluggable ? ItemFacade.getFacade(((ItemFacade.FacadePluggable) pluggable).states) : null;
  }
View Full Code Here

    return sideProperties.pluggables[i];
  }

  @Override
  public boolean hasBlockingPluggable(ForgeDirection side) {
    IPipePluggable pluggable = sideProperties.pluggables[side.ordinal()];
    return pluggable != null && pluggable.blocking(pipe, side);
  }
View Full Code Here

  public static class SideProperties {
    IPipePluggable[] pluggables = new IPipePluggable[ForgeDirection.VALID_DIRECTIONS.length];

    public void writeToNBT(NBTTagCompound nbt) {
      for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
        IPipePluggable pluggable = pluggables[i];
        final String key = "pluggable[" + i + "]";
        if (pluggable == null) {
          nbt.removeTag(key);
        } else {
          NBTTagCompound pluggableData = new NBTTagCompound();
          pluggableData.setString("pluggableClass", pluggable.getClass().getName());
          pluggable.writeToNBT(pluggableData);
          nbt.setTag(key, pluggableData);
        }
      }
    }
View Full Code Here

          Class<?> pluggableClass = Class.forName(pluggableData.getString("pluggableClass"));
          if (!IPipePluggable.class.isAssignableFrom(pluggableClass)) {
            BCLog.logger.warn("Wrong pluggable class: " + pluggableClass);
            continue;
          }
          IPipePluggable pluggable = (IPipePluggable) pluggableClass.newInstance();
          pluggable.readFromNBT(pluggableData);
          pluggables[i] = pluggable;
        } catch (Exception e) {
          BCLog.logger.warn("Failed to load side state");
          e.printStackTrace();
        }
      }

      // Migration code
      for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
        IPipePluggable pluggable = null;
        if (nbt.hasKey("facadeState[" + i + "]")) {
          pluggable = new ItemFacade.FacadePluggable(ItemFacade.FacadeState.readArray(nbt.getTagList("facadeState[" + i + "]", Constants.NBT.TAG_COMPOUND)));
        } else {
          // Migration support for 5.0.x and 6.0.x
          if (nbt.hasKey("facadeBlocks[" + i + "]")) {
View Full Code Here

      pluggables = newPluggables;
    }

    public boolean dropItem(LogisticsTileGenericPipe pipe, ForgeDirection direction) {
      boolean result = false;
      IPipePluggable pluggable = pluggables[direction.ordinal()];
      if (pluggable != null) {
        pluggable.onDetachedPipe(((PipeWrapper)pipe.pipe.bcPipePart.getWrapped()).getTile(), direction);
        ItemStack[] stacks = pluggable.getDropItems(pipe);
        if (stacks != null) {
          for (ItemStack stack : stacks) {
            InvUtils.dropItems(pipe.getWorldObj(), stack, pipe.xCoord, pipe.yCoord, pipe.zCoord);
          }
        }
View Full Code Here

      }
    }

    public void validate(LogisticsTileGenericPipe pipe) {
      for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        IPipePluggable p = pluggables[d.ordinal()];

        if (p != null) {
          p.validate(pipe, d);
        }
      }
    }
View Full Code Here

  }

  @Override
  public void updateCoreStateGateData() {
    for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
      IPipePluggable pluggable = (IPipePluggable) this.container.tilePart.getPluggables(i);
      ((BCCoreState)this.container.bcCoreState.getOriginal()).gates[i] = pluggable instanceof ItemGate.GatePluggable ? (ItemGate.GatePluggable) pluggable : null;
    }
  }
View Full Code Here

      renderState.gateMatrix.setIsGatePulsing(gate != null && gate.isGatePulsing(), direction);
    }

    // Facades
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
      IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
      if (!(pluggable instanceof ItemFacade.FacadePluggable)) {
        renderState.facadeMatrix.setFacade(direction, null, 0, true);
        continue;
      }
      FacadeState[] states = ((ItemFacade.FacadePluggable) pluggable).states;
      if (states == null) {
        renderState.facadeMatrix.setFacade(direction, null, 0, true);
        continue;
      }
      // Iterate over all states and activate first proper
      FacadeState defaultState = null, activeState = null;
      for (FacadeState state : states) {
        if (state.wire == null) {
          defaultState = state;
          continue;
        }
        if (pipe != null && pipe.isWireActive(state.wire)) {
          activeState = state;
          break;
        }
      }
      if (activeState == null) {
        activeState = defaultState;
      }
      Block block = activeState != null ? activeState.block : null;
      int metadata = activeState != null ? activeState.metadata : 0;
      boolean transparent = activeState == null || block == null;
      renderState.facadeMatrix.setFacade(direction, block, metadata, transparent);
    }

    //Plugs
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
      IPipePluggable pluggable = sideProperties.pluggables[direction.ordinal()];
      renderState.plugMatrix.setConnected(direction, pluggable instanceof ItemPlug.PlugPluggable);

      if (pluggable instanceof ItemRobotStation.RobotStationPluggable) {
        DockingStation station = ((ItemRobotStation.RobotStationPluggable) pluggable).getStation();
View Full Code Here

TOP

Related Classes of buildcraft.api.transport.IPipePluggable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.