use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.
the class ModuleRegulatorTube method renderModule.
@Override
protected void renderModule() {
super.renderModule();
if (isFake()) {
if (!hasTicked) {
TileEntityPneumaticBase tile = (TileEntityPneumaticBase) getTube();
NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(tile.xCoord, tile.yCoord, tile.zCoord));
TileEntity neighbor = tile.getWorldObj().getTileEntity(tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ);
inLine = neighbor instanceof IPneumaticMachine;
if (inLine) {
inverted = ((IPneumaticMachine) neighbor).getAirHandler().getPressure(dir) > tile.getPressure(ForgeDirection.UNKNOWN);
NetworkHandler.sendToServer(new PacketDescriptionPacketRequest(neighbor.xCoord, neighbor.yCoord, neighbor.zCoord));
}
hasTicked = true;
}
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (inLine && !inverted) {
GL11.glColor4d(0, 1, 0, 0.3);
} else {
GL11.glColor4d(1, 0, 0, 0.3);
}
GL11.glPushMatrix();
GL11.glTranslated(0, 1, 0.2 + ClientTickHandler.TICKS % 20 * 0.015);
GL11.glRotated(90, 1, 0, 0);
RenderUtils.render3DArrow();
GL11.glColor4d(1, 1, 1, 1);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_BLEND);
}
}
use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.
the class WailaPneumaticHandler method addTipToMachine.
public static void addTipToMachine(List<String> currenttip, IWailaDataAccessor accessor) {
NBTTagCompound tCompound = accessor.getNBTData();
TileEntity te = accessor.getTileEntity();
if (te instanceof IPneumaticMachine) {
addTipToMachine(currenttip, (IPneumaticMachine) te, tCompound.getFloat("pressure"));
}
}
use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.
the class TileEntityPressureTube method updateConnections.
public void updateConnections(World world, int x, int y, int z) {
sidesConnected = new boolean[6];
boolean hasModule = false;
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
TileEntity te = getTileCache()[direction.ordinal()].getTileEntity();
IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
if (machine != null) {
sidesConnected[direction.ordinal()] = isConnectedTo(direction) && machine.isConnectedTo(direction.getOpposite());
} else if (te instanceof ISidedPneumaticMachine) {
sidesConnected[direction.ordinal()] = ((ISidedPneumaticMachine) te).getAirHandler(direction.getOpposite()) != null;
}
if (modules[direction.ordinal()] != null) {
hasModule = true;
}
}
int sidesCount = 0;
for (boolean bool : sidesConnected) {
if (bool)
sidesCount++;
}
if (sidesCount == 1 && !hasModule) {
for (int i = 0; i < 6; i++) {
if (sidesConnected[i]) {
if (isConnectedTo(ForgeDirection.getOrientation(i).getOpposite()))
sidesConnected[i ^ 1] = true;
break;
}
}
}
for (int i = 0; i < 6; i++) {
if (modules[i] != null && modules[i].isInline())
sidesConnected[i] = false;
}
}
use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.
the class TileEntityUVLightBox method updateConnections.
public void updateConnections() {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (isConnectedTo(direction)) {
boolean checkingLeft = ForgeDirection.getOrientation(getBlockMetadata()).getRotation(ForgeDirection.UP) == direction;
TileEntity te = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
if (te instanceof IPneumaticMachine) {
/*sidesConnected[direction.ordinal()]*/
boolean isConnected = ((IPneumaticMachine) te).isConnectedTo(direction.getOpposite());
if (checkingLeft)
leftConnected = isConnected;
else
rightConnected = isConnected;
} else {
/*sidesConnected[direction.ordinal()]*/
if (checkingLeft)
leftConnected = false;
else
rightConnected = false;
}
}
}
}
use of pneumaticCraft.api.tileentity.IPneumaticMachine in project PneumaticCraft by MineMaarten.
the class ProgWidgetPressureCondition method getEvaluator.
@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {
@Override
protected boolean evaluate(ChunkPosition pos) {
TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
if (te instanceof IPneumaticMachine) {
IAirHandler airHandler = ((IPneumaticMachine) te).getAirHandler();
float pressure = Float.MIN_VALUE;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
if (getSides()[d.ordinal()]) {
pressure = Math.max(airHandler.getPressure(d), pressure);
}
}
return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ? pressure == ((ICondition) widget).getRequiredCount() : pressure >= ((ICondition) widget).getRequiredCount();
}
return false;
}
};
}
Aggregations