use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class TileEntityPressureTube method onNeighborTileUpdate.
@Override
public void onNeighborTileUpdate() {
super.onNeighborTileUpdate();
updateConnections(worldObj, xCoord, yCoord, zCoord);
for (TubeModule module : modules) {
if (module != null)
module.onNeighborTileUpdate();
}
}
use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class TileEntityPressureTube method onNeighborBlockUpdate.
@Override
public void onNeighborBlockUpdate() {
super.onNeighborBlockUpdate();
updateConnections(worldObj, xCoord, yCoord, zCoord);
for (TubeModule module : modules) {
if (module != null)
module.onNeighborBlockUpdate();
}
}
use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class RenderPressureTube method renderModelAt.
public void renderModelAt(TileEntityPressureTube tile, double d, double d1, double d2, float f) {
// start
GL11.glPushMatrix();
// GL11.glDisable(GL11.GL_TEXTURE_2D);
// GL11.glEnable(GL11.GL_BLEND);
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
FMLClientHandler.instance().getClient().getTextureManager().bindTexture(tile.CRITICAL_PRESSURE == PneumaticValues.MAX_PRESSURE_PRESSURE_TUBE ? Textures.MODEL_PRESSURE_TUBE : Textures.MODEL_ADVANCED_PRESSURE_TUBE);
// GL11.glColor4f(0.82F, 0.56F, 0.09F, 1.0F);
// size
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glRotatef(0, 0.0F, 1.0F, 0.0F);
GL11.glScalef(1.0F, -1F, -1F);
attachFakeModule(tile);
boolean[] renderSides = Arrays.copyOf(tile.sidesConnected, tile.sidesConnected.length);
for (int i = 0; i < 6; i++) {
if (tile.modules[i] != null && tile.modules[i].isInline()) {
renderSides[i] = true;
}
}
model.renderModel(0.0625F, renderSides);
// GL11.glEnable(GL11.GL_TEXTURE_2D);
// end
GL11.glPopMatrix();
for (int i = 0; i < tile.modules.length; i++) {
TubeModule module = tile.modules[i];
if (module != null) {
if (module.isFake()) {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
GL11.glColor4d(1, 1, 1, 0.3);
}
module.renderDynamic(d, d1, d2, f, 0, false);
if (module.isFake()) {
tile.modules[i] = null;
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4d(1, 1, 1, 1);
}
}
}
GL11.glColor4d(1, 1, 1, 1);
}
use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class BlockPressureTube method tryPlaceModule.
public boolean tryPlaceModule(EntityPlayer player, World world, int x, int y, int z, int par6, boolean simulate) {
if (player.getCurrentEquippedItem() != null) {
if (player.getCurrentEquippedItem().getItem() instanceof ItemTubeModule) {
TileEntityPressureTube pressureTube = ModInteractionUtils.getInstance().getTube(world.getTileEntity(x, y, z));
if (pressureTube.modules[par6] == null && ModInteractionUtils.getInstance().occlusionTest(boundingBoxes[par6], world.getTileEntity(x, y, z))) {
TubeModule module = ModuleRegistrator.getModule(((ItemTubeModule) player.getCurrentEquippedItem().getItem()).moduleName);
if (simulate)
module.markFake();
pressureTube.setModule(module, ForgeDirection.getOrientation(par6));
if (!simulate) {
onNeighborBlockChange(world, x, y, z, this);
world.notifyBlocksOfNeighborChange(x, y, z, this, ForgeDirection.getOrientation(par6).getOpposite().ordinal());
if (!player.capabilities.isCreativeMode)
player.getCurrentEquippedItem().stackSize--;
world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Block.soundTypeGlass.getStepResourcePath(), Block.soundTypeGlass.getVolume() * 5.0F, Block.soundTypeGlass.getPitch() * .9F);
}
return true;
}
} else if (player.getCurrentEquippedItem().getItem() == Itemss.advancedPCB && !simulate) {
TubeModule module = BlockPressureTube.getLookedModule(world, x, y, z, player);
if (module != null && !module.isUpgraded() && module.canUpgrade()) {
if (!world.isRemote) {
module.upgrade();
if (!player.capabilities.isCreativeMode)
player.getCurrentEquippedItem().stackSize--;
}
return true;
}
}
}
return false;
}
use of pneumaticCraft.common.block.tubes.TubeModule in project PneumaticCraft by MineMaarten.
the class BlockPressureTube method collisionRayTrace.
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
MovingObjectPosition bestMOP = null;
AxisAlignedBB bestAABB = null;
setBlockBounds(BBConstants.PRESSURE_PIPE_MIN_POS, BBConstants.PRESSURE_PIPE_MIN_POS, BBConstants.PRESSURE_PIPE_MIN_POS, BBConstants.PRESSURE_PIPE_MAX_POS, BBConstants.PRESSURE_PIPE_MAX_POS, BBConstants.PRESSURE_PIPE_MAX_POS);
MovingObjectPosition mop = super.collisionRayTrace(world, x, y, z, origin, direction);
if (isCloserMOP(origin, bestMOP, mop)) {
bestMOP = mop;
bestAABB = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
TileEntityPressureTube tube = ModInteractionUtils.getInstance().getTube(world.getTileEntity(x, y, z));
for (int i = 0; i < 6; i++) {
if (tube.sidesConnected[i]) {
setBlockBounds(boundingBoxes[i]);
mop = super.collisionRayTrace(world, x, y, z, origin, direction);
if (isCloserMOP(origin, bestMOP, mop)) {
bestMOP = mop;
bestAABB = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
}
}
//unknown indicates we hit the tube.
if (bestMOP != null)
bestMOP.hitInfo = ForgeDirection.UNKNOWN;
TubeModule[] modules = tube.modules;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (modules[dir.ordinal()] != null) {
setBlockBounds(modules[dir.ordinal()].boundingBoxes[dir.ordinal()]);
mop = super.collisionRayTrace(world, x, y, z, origin, direction);
if (isCloserMOP(origin, bestMOP, mop)) {
mop.hitInfo = dir;
bestMOP = mop;
bestAABB = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
}
}
}
if (bestAABB != null)
setBlockBounds(bestAABB);
return bestMOP;
}
Aggregations