use of micdoodle8.mods.galacticraft.core.tile.TileEntityFluidPipe in project Galacticraft by micdoodle8.
the class GCNEIHighlightHandler method handleTextData.
@Override
public List<String> handleTextData(ItemStack stack, World world, EntityPlayer player, MovingObjectPosition mop, List<String> currenttip, ItemInfo.Layout layout) {
if (stack != null) {
if (stack.getItem() == Item.getItemFromBlock(GCBlocks.fluidTank)) {
if (layout == ItemInfo.Layout.BODY) {
TileEntity tile = world.getTileEntity(mop.getBlockPos());
if (tile instanceof TileEntityFluidTank) {
TileEntityFluidTank tank = (TileEntityFluidTank) tile;
FluidTankInfo[] infos = tank.getTankInfo(EnumFacing.DOWN);
if (infos.length == 1) {
FluidTankInfo info = infos[0];
currenttip.add(info.fluid != null ? info.fluid.getLocalizedName() : "Empty");
currenttip.add((info.fluid != null ? info.fluid.amount : 0) + " / " + info.capacity);
}
}
}
} else if (stack.getItem() == Item.getItemFromBlock(GCBlocks.oxygenPipe) || stack.getItem() == Item.getItemFromBlock(GCBlocks.oxygenPipePull)) {
if (layout == ItemInfo.Layout.BODY) {
TileEntity tile = world.getTileEntity(mop.getBlockPos());
if (tile instanceof TileEntityFluidPipe) {
TileEntityFluidPipe pipe = (TileEntityFluidPipe) tile;
currenttip.add(((BlockFluidPipe) pipe.getBlockType()).getMode().toString());
if (pipe.hasNetwork()) {
FluidNetwork network = ((FluidNetwork) pipe.getNetwork());
currenttip.add("Network: " + (network.buffer != null ? network.buffer.amount : 0) + " / " + network.getCapacity());
} else {
currenttip.add("Pipe: " + (pipe.getBuffer() != null ? pipe.getBuffer().amount + " / " + pipe.buffer.getCapacity() : "None"));
}
}
}
}
}
return currenttip;
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityFluidPipe in project Galacticraft by micdoodle8.
the class BlockFluidPipe method breakBlock.
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
final TileEntityFluidPipe tile = (TileEntityFluidPipe) worldIn.getTileEntity(pos);
int pipeColor = state.getValue(COLOR).getDyeDamage();
if (!ignoreDrop && tile != null && pipeColor != 15) {
spawnItem(worldIn, pos, pipeColor);
}
super.breakBlock(worldIn, pos, state);
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityFluidPipe in project Galacticraft by micdoodle8.
the class BlockFluidPipe method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
final TileEntityFluidPipe tileEntity = (TileEntityFluidPipe) worldIn.getTileEntity(pos);
if (super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ)) {
return true;
}
if (!worldIn.isRemote) {
final ItemStack stack = playerIn.inventory.getCurrentItem();
if (stack != null) {
if (stack.getItem() instanceof ItemDye) {
final int dyeColor = playerIn.inventory.getCurrentItem().getItemDamage();
final byte colorBefore = tileEntity.getColor(state);
tileEntity.onColorUpdate();
worldIn.setBlockState(pos, state.withProperty(COLOR, EnumDyeColor.byDyeDamage(dyeColor)));
GalacticraftCore.packetPipeline.sendToAllAround(new PacketSimple(PacketSimple.EnumSimplePacket.C_RECOLOR_PIPE, GCCoreUtil.getDimensionID(worldIn), new Object[] { pos }), new NetworkRegistry.TargetPoint(GCCoreUtil.getDimensionID(worldIn), pos.getX(), pos.getY(), pos.getZ(), 40.0));
if (colorBefore != (byte) dyeColor && !playerIn.capabilities.isCreativeMode && --playerIn.inventory.getCurrentItem().stackSize == 0) {
playerIn.inventory.mainInventory[playerIn.inventory.currentItem] = null;
}
if (colorBefore != (byte) dyeColor && colorBefore != 15) {
spawnItem(worldIn, pos, colorBefore);
}
// GCCorePacketManager.sendPacketToClients(GCCorePacketManager.getPacket(GalacticraftCore.CHANNELENTITIES, tileEntity, tileEntity.getColor(), (byte) -1)); TODO Fix pipe color
BlockPos tileVec = tileEntity.getPos();
for (final EnumFacing dir : EnumFacing.VALUES) {
final TileEntity tileAt = worldIn.getTileEntity(tileVec.offset(dir));
if (tileAt != null && tileAt instanceof IColorable) {
((IColorable) tileAt).onAdjacentColorChanged(dir);
}
}
return true;
}
}
}
return false;
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityFluidPipe in project Galacticraft by micdoodle8.
the class BlockFluidPipe method onUseWrench.
@Override
public boolean onUseWrench(World world, BlockPos pos, EntityPlayer entityPlayer, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
TileEntityFluidPipe tile = (TileEntityFluidPipe) world.getTileEntity(pos);
tile.switchType();
}
return true;
}
use of micdoodle8.mods.galacticraft.core.tile.TileEntityFluidPipe in project Galacticraft by micdoodle8.
the class TileEntityFluidPipeRenderer method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityFluidPipe pipe, double x, double y, double z, float partialTicks, int destroyStage) {
updateModels();
if (pipe.getBlockType() == GCBlocks.oxygenPipePull) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, (float) z);
RenderHelper.disableStandardItemLighting();
this.bindTexture(TextureMap.locationBlocksTexture);
if (Minecraft.isAmbientOcclusionEnabled()) {
GlStateManager.shadeModel(GL11.GL_SMOOTH);
} else {
GlStateManager.shadeModel(GL11.GL_FLAT);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
TileEntity[] adj = OxygenUtil.getAdjacentFluidConnections(pipe);
for (EnumFacing facing : EnumFacing.VALUES) {
TileEntity sideTile = adj[facing.ordinal()];
if (sideTile != null && !(sideTile instanceof IBufferTransmitter)) {
GL11.glPushMatrix();
if (sideTile instanceof TileEntityFluidTank)
switch(facing) {
case SOUTH:
GL11.glTranslatef(0F, 0F, 1 / 16F);
break;
case NORTH:
GL11.glTranslatef(0F, 0F, -1 / 16F);
break;
case EAST:
GL11.glTranslatef(1 / 16F, 0F, 0F);
break;
case WEST:
GL11.glTranslatef(-1 / 16F, 0F, 0F);
break;
}
ClientUtil.drawBakedModel(pullConnectorModel[facing.ordinal()]);
GL11.glPopMatrix();
}
}
GL11.glPopMatrix();
}
float scale;
if (pipe.hasNetwork()) {
FluidNetwork network = (FluidNetwork) pipe.getNetwork();
scale = network.fluidScale;
} else {
scale = pipe.buffer.getFluidAmount() / (float) pipe.buffer.getCapacity();
}
Fluid fluid;
if (pipe.hasNetwork()) {
FluidNetwork network = (FluidNetwork) pipe.getNetwork();
fluid = network.refFluid;
} else {
fluid = pipe.getBuffer() == null ? null : pipe.getBuffer().getFluid();
}
if (fluid == null) {
return;
}
if (scale > 0.01) {
this.bindTexture(TextureMap.locationBlocksTexture);
GL11.glPushMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z + 1.0F);
GL11.glScalef(1.0F, -1.0F, -1.0F);
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
float opacity = 1.0F;
boolean gas = fluid.isGaseous();
if (gas) {
opacity = scale;
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, opacity);
TileEntity[] connections = OxygenUtil.getAdjacentFluidConnections(pipe);
for (EnumFacing side : EnumFacing.VALUES) {
TileEntity sideTile = connections[side.ordinal()];
if (sideTile != null) {
Integer[] displayLists = getListAndRender(side, fluid);
if (displayLists != null) {
if (!gas) {
Integer list = displayLists[Math.max(3, (int) (scale * (stages - 1)))];
GL11.glCallList(list);
} else {
Integer list = displayLists[stages - 1];
GL11.glCallList(list);
}
}
}
}
Integer[] displayLists = getListAndRender(null, fluid);
if (displayLists != null) {
if (!gas) {
Integer list = displayLists[Math.max(3, (int) (scale * (stages - 1)))];
GL11.glCallList(list);
} else {
Integer list = displayLists[stages - 1];
GL11.glCallList(list);
}
}
GlStateManager.enableLighting();
GlStateManager.disableBlend();
GL11.glPopMatrix();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
}
Aggregations