diff --git a/.gitignore b/.gitignore index 7e4570ab..39a19e4a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ out/ *.ipr *.iws run/ +build/ diff --git a/src/main/java/com/glodblock/github/FluidCraft.java b/src/main/java/com/glodblock/github/FluidCraft.java index 5c3061a6..8529c5d6 100644 --- a/src/main/java/com/glodblock/github/FluidCraft.java +++ b/src/main/java/com/glodblock/github/FluidCraft.java @@ -28,7 +28,7 @@ import cpw.mods.fml.common.network.NetworkRegistry; modid = FluidCraft.MODID, version = FluidCraft.VERSION, name = FluidCraft.MODNAME, - dependencies = "required-after:appliedenergistics2;after:waila") + dependencies = "required-after:appliedenergistics2;required-after:BuildCraft|Factory;required-after:CoFHCore;after:waila") public class FluidCraft { public static final String MODID = "GRADLETOKEN_MODID"; diff --git a/src/main/java/com/glodblock/github/client/render/ItemCertusQuartzTankRender.java b/src/main/java/com/glodblock/github/client/render/ItemCertusQuartzTankRender.java index ba32fddd..eaaa37c7 100644 --- a/src/main/java/com/glodblock/github/client/render/ItemCertusQuartzTankRender.java +++ b/src/main/java/com/glodblock/github/client/render/ItemCertusQuartzTankRender.java @@ -1,20 +1,38 @@ package com.glodblock.github.client.render; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import com.glodblock.github.FluidCraft; +import com.glodblock.github.client.render.tank.ModelCertusTank; +import com.glodblock.github.common.tile.TileCertusQuartzTank; +import com.glodblock.github.loader.ItemAndBlockHolder; +import cpw.mods.fml.client.registry.ClientRegistry; public class ItemCertusQuartzTankRender implements IItemRenderer { - public ItemCertusQuartzTankRender() { + private final ModelCertusTank model = new ModelCertusTank(); - // - // MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.CERTUS_QUARTZ_TANK), - // this); + public ItemCertusQuartzTankRender() { + ClientRegistry.bindTileEntitySpecialRenderer(TileCertusQuartzTank.class, new RenderBlockCertusQuartzTank()); + MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.CERTUS_QUARTZ_TANK), this); } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return true; + return type != ItemRenderType.EQUIPPED_FIRST_PERSON; } @Override @@ -23,5 +41,65 @@ public class ItemCertusQuartzTankRender implements IItemRenderer { } @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) {} + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + Minecraft.getMinecraft().renderEngine + .bindTexture(FluidCraft.resource("textures/blocks/certus_quartz_tank/map.png")); + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glScalef(1, -1, -1); + this.model.render(0.0625f); + GL11.glScalef(1, -1, 1); + this.model.render(0.0625f); + + if (item != null && item.hasTagCompound()) { + FluidStack storedFluid = FluidStack + .loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("tileEntity")); + int tankCapacity = 32000; + + if (storedFluid != null && storedFluid.getFluid() != null) { + IIcon fluidIcon = storedFluid.getFluid().getIcon(); + if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon(); + Tessellator tessellator = Tessellator.instance; + RenderBlocks renderer = new RenderBlocks(); + GL11.glScalef(1, 1, -1); + renderer.setRenderBounds( + 0.08F, + 0.001F, + 0.08F, + 0.92F, + (float) storedFluid.amount / (float) tankCapacity * 0.999F, + 0.92F); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + Block waterBlock = FluidRegistry.WATER.getBlock(); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F( + (storedFluid.getFluid().getColor() >> 16 & 0xFF) / 255.0F, + (storedFluid.getFluid().getColor() >> 8 & 0xFF) / 255.0F, + (storedFluid.getFluid().getColor() & 0xFF) / 255.0F, + 1.0F); + tessellator.setNormal(0.0F, -1F, 0.0F); + renderer.renderFaceYNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderer.renderFaceZNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderer.renderFaceXNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon); + tessellator.draw(); + } + } + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/com/glodblock/github/client/render/ItemWalrusRender.java b/src/main/java/com/glodblock/github/client/render/ItemWalrusRender.java index bc09137e..6a6ff280 100644 --- a/src/main/java/com/glodblock/github/client/render/ItemWalrusRender.java +++ b/src/main/java/com/glodblock/github/client/render/ItemWalrusRender.java @@ -27,25 +27,19 @@ public class ItemWalrusRender implements IItemRenderer { } @Override - public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) { + public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; } @Override - public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) { + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus); GL11.glPushMatrix(); switch (type) { - case ENTITY: - break; - case EQUIPPED: - break; case EQUIPPED_FIRST_PERSON: GL11.glRotated(180, 0, 1, 0); GL11.glTranslatef(-1F, 0.5F, -0.5F); break; - case FIRST_PERSON_MAP: - break; case INVENTORY: GL11.glTranslatef(-0.5F, -0.5F, -0.1F); break; @@ -57,8 +51,7 @@ public class ItemWalrusRender implements IItemRenderer { } @Override - public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, - IItemRenderer.ItemRendererHelper helper) { + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { return true; } } diff --git a/src/main/java/com/glodblock/github/client/render/RenderBlockCertusQuartzTank.java b/src/main/java/com/glodblock/github/client/render/RenderBlockCertusQuartzTank.java new file mode 100644 index 00000000..77100c16 --- /dev/null +++ b/src/main/java/com/glodblock/github/client/render/RenderBlockCertusQuartzTank.java @@ -0,0 +1,54 @@ +package com.glodblock.github.client.render; + +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import com.glodblock.github.client.render.tank.FluidTankRenderer; +import com.glodblock.github.common.tile.TileCertusQuartzTank; +import com.glodblock.github.util.RenderUtil; +import com.glodblock.github.util.Util; + +public class RenderBlockCertusQuartzTank extends TileEntitySpecialRenderer { + + @Override + public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { + TileCertusQuartzTank tank = (TileCertusQuartzTank) tileentity; + + FluidStack liquid = tank.tank.getFluid(); + if (liquid == null || liquid.getFluid() == null || liquid.amount <= 0) { + return; + } + + int color = liquid.getFluid().getColor(liquid); + + int[] displayList = FluidTankRenderer.getFluidDisplayLists(liquid, tileentity.getWorldObj(), false); + if (displayList == null) { + return; + } + + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + + bindTexture(TextureMap.locationBlocksTexture); + RenderUtil.setGLColorFromInt(color); + + GL11.glTranslatef((float) x + 0.0625F, (float) y + 0.5F, (float) z + 0.0625F); + GL11.glScalef(0.875F, 0.99F, 0.875F); + GL11.glTranslatef(0, -0.5F, 0); + + int dl = (int) ((float) liquid.amount / (float) (tank.tank.getCapacity()) + * (FluidTankRenderer.DISPLAY_STAGES - 1)); + GL11.glCallList(displayList[Util.clamp(dl, 0, FluidTankRenderer.DISPLAY_STAGES - 1)]); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } +} diff --git a/src/main/java/com/glodblock/github/client/render/tank/FluidTankRenderer.java b/src/main/java/com/glodblock/github/client/render/tank/FluidTankRenderer.java new file mode 100644 index 00000000..baad1e66 --- /dev/null +++ b/src/main/java/com/glodblock/github/client/render/tank/FluidTankRenderer.java @@ -0,0 +1,121 @@ +package com.glodblock.github.client.render.tank; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GLAllocation; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import com.glodblock.github.util.RenderUtil; + +public class FluidTankRenderer { + + public static final int DISPLAY_STAGES = 100; + private static final Map flowingRenderCache = new HashMap<>(); + private static final Map stillRenderCache = new HashMap<>(); + private static final RenderEntityBlock.RenderInfo liquidBlock = new RenderEntityBlock.RenderInfo(); + + public static void onTextureReload() { + for (int[] ia : flowingRenderCache.values()) { + for (int i : ia) { + GL11.glDeleteLists(i, 1); + } + } + flowingRenderCache.clear(); + + for (int[] ia : stillRenderCache.values()) { + for (int i : ia) { + GL11.glDeleteLists(i, 1); + } + } + stillRenderCache.clear(); + } + + public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) { + if (fluidStack == null) { + return null; + } + return getFluidTexture(fluidStack.getFluid(), flowing); + } + + public static IIcon getFluidTexture(Fluid fluid, boolean flowing) { + if (fluid == null) { + return null; + } + IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon(); + if (icon == null) { + icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager() + .getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + } + return icon; + } + + public static void setColorForFluidStack(FluidStack fluidstack) { + if (fluidstack == null) { + return; + } + int color = fluidstack.getFluid().getColor(fluidstack); + RenderUtil.setGLColorFromInt(color); + } + + public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing) { + if (fluidStack == null) { + return null; + } + Fluid fluid = fluidStack.getFluid(); + if (fluid == null) { + return null; + } + Map cache = flowing ? flowingRenderCache : stillRenderCache; + int[] diplayLists = cache.get(fluid); + if (diplayLists != null) { + return diplayLists; + } + + diplayLists = new int[DISPLAY_STAGES]; + + if (fluid.getBlock() != null) { + liquidBlock.baseBlock = fluid.getBlock(); + } else { + liquidBlock.baseBlock = Blocks.water; + } + liquidBlock.texture = getFluidTexture(fluidStack, flowing); + + cache.put(fluid, diplayLists); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_CULL_FACE); + + for (int s = 0; s < DISPLAY_STAGES; ++s) { + diplayLists[s] = GLAllocation.generateDisplayLists(1); + GL11.glNewList(diplayLists[s], 4864 /* GL_COMPILE */); + + liquidBlock.minX = 0.01f; + liquidBlock.minY = 0; + liquidBlock.minZ = 0.01f; + + liquidBlock.maxX = 0.99f; + liquidBlock.maxY = Math.max(s, 1) / (float) DISPLAY_STAGES; + liquidBlock.maxZ = 0.99f; + + RenderEntityBlock.INSTANCE.renderBlock(liquidBlock); + GL11.glEndList(); + } + + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + + return diplayLists; + } +} diff --git a/src/main/java/com/glodblock/github/client/render/tank/ModelCertusTank.java b/src/main/java/com/glodblock/github/client/render/tank/ModelCertusTank.java new file mode 100644 index 00000000..2ae7804e --- /dev/null +++ b/src/main/java/com/glodblock/github/client/render/tank/ModelCertusTank.java @@ -0,0 +1,144 @@ +package com.glodblock.github.client.render.tank; + +import net.minecraft.block.Block; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import org.lwjgl.opengl.GL11; + +import com.glodblock.github.common.tile.TileCertusQuartzTank; + +public class ModelCertusTank extends ModelBase { + + ModelRenderer Shape1; + + public ModelCertusTank() { + this.textureWidth = 64; + this.textureHeight = 64; + + this.Shape1 = new ModelRenderer(this, 0, 0); + this.Shape1.addBox(0F, 0F, 0F, 14, 16, 14); + this.Shape1.setRotationPoint(-7F, -8F, -7F); + this.Shape1.setTextureSize(this.textureWidth, this.textureHeight); + this.Shape1.mirror = true; + setRotation(this.Shape1, 0F, 0F, 0F); + + } + + public void render(float f) { + this.Shape1.render(f); + } + + public void renderFluid(TileEntity tileEntity, double x, double y, double z, RenderBlocks renderer) { + Tessellator tessellator = Tessellator.instance; + if (tileEntity != null + && ((TileCertusQuartzTank) tileEntity).getTankInfo(ForgeDirection.UNKNOWN)[0].fluid != null) { + Fluid storedFluid = ((TileCertusQuartzTank) tileEntity).getRenderFluid(); + float scale = ((TileCertusQuartzTank) tileEntity).getRenderScale(); + if (storedFluid != null && scale > 0) { + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + Block id = Block.getBlockById(FluidRegistry.WATER.getID()); + IIcon fluidIcon = storedFluid.getIcon(); + if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon(); + renderer.setRenderBounds(0.08F, 0.001F, 0.08F, 0.92, scale * 0.999F, 0.92F); + tessellator.setColorRGBA_F( + (storedFluid.getColor() >> 16 & 0xFF) / 255.0F, + (storedFluid.getColor() >> 8 & 0xFF) / 255.0F, + (storedFluid.getColor() & 0xFF) / 255.0F, + 1.0F); + tessellator.setNormal(0.0F, -1F, 0.0F); + renderer.renderFaceYNeg(id, x, y, z, fluidIcon); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(id, x, y, z, fluidIcon); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderer.renderFaceZNeg(id, x, y, z, fluidIcon); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(id, x, y, z, fluidIcon); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderer.renderFaceXNeg(id, x, y, z, fluidIcon); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(id, x, y, z, fluidIcon); + } + } + } + + public void renderInnerBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) { + Tessellator tessellator = Tessellator.instance; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + tessellator.setBrightness(15728640); + boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank; + boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank; + int meta = 0; + if (tankUp && tankDown) meta = 3; + else if (tankUp) meta = 2; + else if (tankDown) meta = 1; + if (!tankUp) { + tessellator.setNormal(0, -1, 0); + renderer.renderFaceYNeg(block, x, y + 0.99F, z, block.getIcon(1, 0)); + } + if (!tankDown) { + tessellator.setNormal(0, 1, 0); + renderer.renderFaceYPos(block, x, y - 0.99F, z, block.getIcon(0, 0)); + } + IIcon sideIcon = block.getIcon(3, meta); + tessellator.setNormal(0, 0, -1); + renderer.renderFaceZNeg(block, x, y, z + 0.875F, sideIcon); + tessellator.setNormal(0, 0, 1); + renderer.renderFaceZPos(block, x, y, z - 0.875F, sideIcon); + tessellator.setNormal(-1, 0, 0); + renderer.renderFaceXNeg(block, x + 0.875F, y, z, sideIcon); + tessellator.setNormal(1, 0, 0); + renderer.renderFaceXPos(block, x - 0.875F, y, z, sideIcon); + GL11.glPopMatrix(); + } + + public void renderOuterBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) { + Tessellator tessellator = Tessellator.instance; + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank; + boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank; + int meta = 0; + if (tankUp && tankDown) meta = 3; + else if (tankUp) meta = 2; + else if (tankDown) meta = 1; + if (!tankDown) { + tessellator.setNormal(0.0F, -1F, 0.0F); + renderer.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0)); + } + if (!tankUp) { + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, x, y, z, block.getIcon(1, 0)); + } + + IIcon sideIcon = block.getIcon(3, meta); + tessellator.setNormal(0.0F, 0.0F, -1F); + renderer.renderFaceZNeg(block, x, y, z, sideIcon); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, x, y, z, sideIcon); + tessellator.setNormal(-1F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, x, y, z, sideIcon); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, x, y, z, sideIcon); + GL11.glPopMatrix(); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + +} diff --git a/src/main/java/com/glodblock/github/client/render/tank/RenderEntityBlock.java b/src/main/java/com/glodblock/github/client/render/tank/RenderEntityBlock.java new file mode 100644 index 00000000..c11107a6 --- /dev/null +++ b/src/main/java/com/glodblock/github/client/render/tank/RenderEntityBlock.java @@ -0,0 +1,169 @@ +package com.glodblock.github.client.render.tank; + +import java.util.Arrays; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.Render; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class RenderEntityBlock extends Render { + + public static RenderEntityBlock INSTANCE = new RenderEntityBlock(); + protected RenderBlocks renderBlocks; + + private RenderEntityBlock() { + renderBlocks = field_147909_c; + } + + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + throw new UnsupportedOperationException("Not supported yet."); + } + + public static class RenderInfo { + + public double minX = 0.0F; + public double minY = 0.0F; + public double minZ = 0.0F; + public double maxX = 1.0F; + public double maxY = 1.0F; + public double maxZ = 1.0F; + public Block baseBlock = Blocks.sand; + public IIcon texture = null; + public IIcon[] textureArray = null; + public boolean[] renderSide = new boolean[] { true, true, true, true, true, true }; + public int light = -1; + public int brightness = -1; + + public RenderInfo() {} + + public RenderInfo(Block template, IIcon[] texture) { + this(); + this.baseBlock = template; + this.textureArray = texture; + } + + public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { + this(); + setBounds(minX, minY, minZ, maxX, maxY, maxZ); + } + + public void setSkyBlockLight(World world, int x, int y, int z, int light) { + this.brightness = world.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, x, y, z) << 16 | light; + } + + public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) { + return baseBlock.getMixedBrightnessForBlock(iblockaccess, i, j, k); + } + + public final void setBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { + this.minX = minX; + this.minY = minY; + this.minZ = minZ; + this.maxX = maxX; + this.maxY = maxY; + this.maxZ = maxZ; + } + + public final void setRenderSingleSide(int side) { + Arrays.fill(renderSide, false); + renderSide[side] = true; + } + + public final void setRenderAllSides() { + Arrays.fill(renderSide, true); + } + + public void rotate() { + double temp = minX; + minX = minZ; + minZ = temp; + + temp = maxX; + maxX = maxZ; + maxZ = temp; + } + + public void reverseX() { + double temp = minX; + minX = 1 - maxX; + maxX = 1 - temp; + } + + public void reverseZ() { + double temp = minZ; + minZ = 1 - maxZ; + maxZ = 1 - temp; + } + + public IIcon getBlockTextureFromSide(int i) { + if (texture != null) { + return texture; + } + + int index = i; + + if (textureArray == null || textureArray.length == 0) { + return baseBlock.getBlockTextureFromSide(index); + } else { + if (index >= textureArray.length) { + index = 0; + } + + return textureArray[index]; + } + } + } + + @Override + public void doRender(Entity entity, double x, double y, double z, float f, float f1) { + // NO-OP + } + + public void renderBlock(RenderInfo info) { + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + + renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ); + + if (info.light != -1) { + tessellator.setBrightness(info.light << 20 | info.light << 4); + } else if (info.brightness != -1) { + tessellator.setBrightness(info.brightness << 4); + } + + if (info.renderSide[0]) { + tessellator.setNormal(0, -1, 0); + renderBlocks.renderFaceYNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(0)); + } + if (info.renderSide[1]) { + tessellator.setNormal(0, 1, 0); + renderBlocks.renderFaceYPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(1)); + } + if (info.renderSide[2]) { + tessellator.setNormal(0, 0, -1); + renderBlocks.renderFaceZNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(2)); + } + if (info.renderSide[3]) { + tessellator.setNormal(0, 0, 1); + renderBlocks.renderFaceZPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(3)); + } + if (info.renderSide[4]) { + tessellator.setNormal(-1, 0, 0); + renderBlocks.renderFaceXNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(4)); + } + if (info.renderSide[5]) { + tessellator.setNormal(1, 0, 0); + renderBlocks.renderFaceXPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(5)); + } + tessellator.draw(); + } +} diff --git a/src/main/java/com/glodblock/github/common/block/BaseBlockContainer.java b/src/main/java/com/glodblock/github/common/block/BaseBlockContainer.java index a3be7566..f4170e63 100644 --- a/src/main/java/com/glodblock/github/common/block/BaseBlockContainer.java +++ b/src/main/java/com/glodblock/github/common/block/BaseBlockContainer.java @@ -9,10 +9,14 @@ import net.minecraft.item.ItemStack; public abstract class BaseBlockContainer extends BlockContainer { - public BaseBlockContainer(Material p_i45386_1_) { - super(p_i45386_1_); + public BaseBlockContainer(Material material) { + super(material); } public void addInformation(ItemStack itemStack, EntityPlayer player, List toolTip, boolean advancedToolTips) {} + + public ItemStack stack() { + return new ItemStack(this, 1); + } } diff --git a/src/main/java/com/glodblock/github/common/block/BlockCertusQuartzTank.java b/src/main/java/com/glodblock/github/common/block/BlockCertusQuartzTank.java index c8a4b498..89ff8c3a 100644 --- a/src/main/java/com/glodblock/github/common/block/BlockCertusQuartzTank.java +++ b/src/main/java/com/glodblock/github/common/block/BlockCertusQuartzTank.java @@ -1,11 +1,16 @@ package com.glodblock.github.common.block; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; @@ -13,13 +18,11 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import appeng.api.implementations.items.IAEWrench; -import buildcraft.api.tools.IToolWrench; -import buildcraft.factory.BlockTank; -import com.glodblock.github.FluidCraft; import com.glodblock.github.common.item.ItemCertusQuartzTank; import com.glodblock.github.common.tabs.FluidCraftingTabs; import com.glodblock.github.common.tile.TileCertusQuartzTank; +import com.glodblock.github.loader.ChannelLoader; import com.glodblock.github.loader.IRegister; import com.glodblock.github.loader.ItemAndBlockHolder; import com.glodblock.github.util.NameConst; @@ -28,98 +31,116 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class BlockCertusQuartzTank extends BlockTank implements IRegister { +public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegister { - private IIcon textureStackedSide; + IIcon breakIcon; + IIcon topIcon; + IIcon bottomIcon; + IIcon sideIcon; + IIcon sideMiddleIcon; + IIcon sideTopIcon; + IIcon sideBottomIcon; public BlockCertusQuartzTank() { + super(Material.glass); setBlockName(NameConst.BLOCK_CERTUS_QUARTZ_TANK); - setResistance(1.0F); - setHardness(0.5F); + setResistance(10.0F); + setHardness(2.0F); setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F); } - public ItemStack getDropWithNBT(World world, int x, int y, int z) { - NBTTagCompound nbt = new NBTTagCompound(); - TileEntity te = world.getTileEntity(x, y, z); - if (te instanceof TileCertusQuartzTank) { - ItemStack dropStack = new ItemStack(ItemAndBlockHolder.CERTUS_QUARTZ_TANK, 1); - ((TileCertusQuartzTank) te).writeToNBTWithoutCoords(nbt); - if (!nbt.getCompoundTag("tank").hasKey("Empty")) { - dropStack.setTagCompound(nbt); - } + @Override + public boolean canRenderInPass(int pass) { + return true; + } + @Override + public TileEntity createNewTileEntity(World var1, int var2) { + return new TileCertusQuartzTank(); + } + + public ItemStack getDropWithNBT(World world, int x, int y, int z) { + NBTTagCompound tileEntity = new NBTTagCompound(); + TileEntity worldTE = world.getTileEntity(x, y, z); + if (worldTE instanceof TileCertusQuartzTank) { + ItemStack dropStack = new ItemStack(ItemAndBlockHolder.CERTUS_QUARTZ_TANK, 1); + + ((TileCertusQuartzTank) worldTE).writeToNBTWithoutCoords(tileEntity); + + if (!tileEntity.hasKey("Empty")) { + dropStack.setTagCompound(new NBTTagCompound()); + dropStack.stackTagCompound.setTag("tileEntity", tileEntity); + } return dropStack; + } return null; } - public TileEntity createNewTileEntity(World world, int metadata) { - return new TileCertusQuartzTank(); - } - - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister) { - super.registerBlockIcons(par1IconRegister); - textureStackedSide = par1IconRegister.registerIcon(FluidCraft.MODID + ":certus_quartz_tank/side_stacked"); - } - @Override - public IIcon getIconAbsolute(IBlockAccess iblockaccess, int x, int y, int z, int side, int metadata) { - if (side >= 2 && (iblockaccess.getBlock(x, y - 1, z) instanceof BlockCertusQuartzTank)) { - return textureStackedSide; - } else { - return super.getIconAbsolute(side, metadata); + public IIcon getIcon(int side, int meta) { + switch (meta) { + case 1: + return this.sideTopIcon; + case 2: + return this.sideBottomIcon; + case 3: + return this.sideMiddleIcon; + default: + return side == 0 ? this.bottomIcon : side == 1 ? this.topIcon : this.sideIcon; } } @Override - public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer p, int blockID, float offsetX, - float offsetY, float offsetZ) { - ItemStack current = p.inventory.getCurrentItem(); + public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) { + return getDropWithNBT(world, x, y, z); + } - if (p.isSneaking() && current != null) { - try { - if (current.getItem() instanceof IToolWrench - && ((IToolWrench) current.getItem()).canWrench(p, x, y, z)) { - dropBlockAsItem(worldObj, x, y, z, getDropWithNBT(worldObj, x, y, z)); - worldObj.setBlockToAir(x, y, z); - ((IToolWrench) current.getItem()).wrenchUsed(p, x, y, z); - return true; - } - } catch (Throwable e) { - // No IToolWrench - } + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileCertusQuartzTank) { + TileCertusQuartzTank tank = (TileCertusQuartzTank) tile; + return tank.getFluidLightLevel(); + } + return super.getLightValue(world, x, y, z); + } + + @Override + public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer entityplayer, int blockID, + float offsetX, float offsetY, float offsetZ) { + ItemStack current = entityplayer.inventory.getCurrentItem(); + + if (entityplayer.isSneaking() && current != null) { if (current.getItem() instanceof IAEWrench - && ((IAEWrench) current.getItem()).canWrench(current, p, x, y, z)) { + && ((IAEWrench) current.getItem()).canWrench(current, entityplayer, x, y, z)) { dropBlockAsItem(worldObj, x, y, z, getDropWithNBT(worldObj, x, y, z)); worldObj.setBlockToAir(x, y, z); return true; } } - if (current != null) { FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current); TileCertusQuartzTank tank = (TileCertusQuartzTank) worldObj.getTileEntity(x, y, z); if (liquid != null) { int amountFilled = tank.fill(ForgeDirection.UNKNOWN, liquid, true); - - if (amountFilled != 0 && !p.capabilities.isCreativeMode) { + if (amountFilled != 0 && !entityplayer.capabilities.isCreativeMode && current.getItem() != null) { if (current.stackSize > 1) { - p.inventory.mainInventory[p.inventory.currentItem].stackSize -= 1; - p.inventory.addItemStackToInventory(current.getItem().getContainerItem(current)); + entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1; + entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItem(current)); } else { - p.inventory.mainInventory[p.inventory.currentItem] = current.getItem() + entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = current.getItem() .getContainerItem(current); } } - return true; - - // Handle empty containers } else { - FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid; if (available != null) { ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current); @@ -128,12 +149,13 @@ public class BlockCertusQuartzTank extends BlockTank implements IRegister= 500) { + ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj); + this.lastBeforeUpdate = current.copy(); + } else if (this.lastBeforeUpdate.amount < this.tank.getCapacity() + && current.amount == this.tank.getCapacity() + || this.lastBeforeUpdate.amount == this.tank.getCapacity() + && current.amount < this.tank.getCapacity()) { + ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj); + this.lastBeforeUpdate = current.copy(); + } + } else { + ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj); + this.lastBeforeUpdate = current.copy(); + } + } else if (this.lastBeforeUpdate != null) { + ChannelLoader.sendPacketToAllPlayers(getDescriptionPacket(), this.worldObj); + this.lastBeforeUpdate = null; + } + } + } + + public FluidStack drain(FluidStack fluid, boolean doDrain, boolean findMainTank) { + if (findMainTank) { + int yOff = 0; + TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord); + TileCertusQuartzTank mainTank = this; + while (true) { + if (offTE instanceof TileCertusQuartzTank) { + Fluid offFluid = ((TileCertusQuartzTank) offTE).getFluid(); + if (offFluid != null && offFluid == fluid.getFluid()) { + mainTank = (TileCertusQuartzTank) this.worldObj + .getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord); + yOff++; + offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord); + continue; + } + } + break; + } + + return mainTank != null ? mainTank.drain(fluid, doDrain, false) : null; + } + + FluidStack drained = this.tank.drain(fluid.amount, doDrain); + compareAndUpdate(); + + if (drained == null || drained.amount < fluid.amount) { + TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - 1, this.zCoord); + if (offTE instanceof TileCertusQuartzTank) { + TileCertusQuartzTank tank = (TileCertusQuartzTank) offTE; + FluidStack externallyDrained = tank.drain( + new FluidStack(fluid.getFluid(), fluid.amount - (drained != null ? drained.amount : 0)), + doDrain, + false); + + if (externallyDrained != null) return new FluidStack( + fluid.getFluid(), + (drained != null ? drained.amount : 0) + externallyDrained.amount); + else return drained; + } + } + + return drained; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (this.tank.getFluid() == null || resource == null || resource.getFluid() != this.tank.getFluid().getFluid()) + return null; + + return drain(resource, doDrain, true); + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if (this.tank.getFluid() == null) return null; + + return drain(from, new FluidStack(this.tank.getFluid(), maxDrain), doDrain); + } + + public int fill(FluidStack fluid, boolean doFill, boolean findMainTank) { + if (findMainTank) { + int yOff = 0; + TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord); + TileCertusQuartzTank mainTank = this; + while (true) { + if (offTE instanceof TileCertusQuartzTank) { + Fluid offFluid = ((TileCertusQuartzTank) offTE).getFluid(); + if (offFluid == null || offFluid == fluid.getFluid()) { + mainTank = (TileCertusQuartzTank) this.worldObj + .getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord); + yOff++; + offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord); + continue; + } + } + break; + } + + return mainTank != null ? mainTank.fill(fluid, doFill, false) : 0; + } + + int filled = this.tank.fill(fluid, doFill); + compareAndUpdate(); + + if (filled < fluid.amount) { + TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + 1, this.zCoord); + if (offTE instanceof TileCertusQuartzTank) { + TileCertusQuartzTank tank = (TileCertusQuartzTank) offTE; + return filled + tank.fill(new FluidStack(fluid.getFluid(), fluid.amount - filled), doFill, false); + } + } + + return filled; + } + + /* IFluidHandler */ + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (resource == null || this.tank.getFluid() != null && resource.getFluid() != this.tank.getFluid().getFluid()) + return 0; + return fill(resource, doFill, true); + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbtTag = new NBTTagCompound(); + writeToNBT(nbtTag); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag); + } + + public Fluid getFluid() { + FluidStack tankFluid = this.tank.getFluid(); + return tankFluid != null && tankFluid.amount > 0 ? tankFluid.getFluid() : null; + } + + public Fluid getRenderFluid() { + return this.tank.getFluid() != null ? this.tank.getFluid().getFluid() : null; + } + + public float getRenderScale() { + return (float) this.tank.getFluidAmount() / this.tank.getCapacity(); + } + + public FluidTankInfo[] getTankInfo(boolean goToMainTank) { + if (!goToMainTank) return new FluidTankInfo[] { this.tank.getInfo() }; + + int amount = 0, capacity = 0; + Fluid fluid = null; + + int yOff = 0; + TileEntity offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord); + TileCertusQuartzTank mainTank; + while (true) { + if (offTE instanceof TileCertusQuartzTank) { + if (((TileCertusQuartzTank) offTE).getFluid() == null + || ((TileCertusQuartzTank) offTE).getFluid() == getFluid()) { + yOff++; + offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord - yOff, this.zCoord); + continue; + } + } + break; + } + + yOff = 0; + offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord); + while (true) { + if (offTE instanceof TileCertusQuartzTank) { + mainTank = (TileCertusQuartzTank) offTE; + if (mainTank.getFluid() == null || mainTank.getFluid() == getFluid()) { + FluidTankInfo info = mainTank.getTankInfo(false)[0]; + if (info != null) { + capacity += info.capacity; + if (info.fluid != null) { + amount += info.fluid.amount; + if (info.fluid.getFluid() != null) fluid = info.fluid.getFluid(); + } + } + yOff++; + offTE = this.worldObj.getTileEntity(this.xCoord, this.yCoord + yOff, this.zCoord); + continue; + } + } + break; + } + + return new FluidTankInfo[] { + new FluidTankInfo(fluid != null ? new FluidStack(fluid, amount) : null, capacity) }; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return getTankInfo(true); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) { + this.worldObj.markBlockRangeForRenderUpdate( + this.xCoord, + this.yCoord, + this.zCoord, + this.xCoord, + this.yCoord, + this.zCoord); + readFromNBT(packet.func_148857_g()); + } + + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); + readFromNBTWithoutCoords(tag); } public void readFromNBTWithoutCoords(NBTTagCompound tag) { this.tank.readFromNBT(tag); } - public void writeToNBT(NBTTagCompound data) { - super.writeToNBT(data); - writeToNBTWithoutCoords(data); - } - - public void setCapacity() { - this.tank.setCapacity(CAPACITY); + @Override + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); + writeToNBTWithoutCoords(tag); } public void writeToNBTWithoutCoords(NBTTagCompound tag) { diff --git a/src/main/java/com/glodblock/github/loader/ChannelLoader.java b/src/main/java/com/glodblock/github/loader/ChannelLoader.java index 1ecdaa0a..198bd0ff 100644 --- a/src/main/java/com/glodblock/github/loader/ChannelLoader.java +++ b/src/main/java/com/glodblock/github/loader/ChannelLoader.java @@ -1,5 +1,9 @@ package com.glodblock.github.loader; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.Packet; +import net.minecraft.world.World; + import com.glodblock.github.FluidCraft; import com.glodblock.github.network.*; import cpw.mods.fml.relauncher.Side; @@ -47,4 +51,12 @@ public class ChannelLoader implements Runnable { FluidCraft.proxy.netHandler .registerMessage(new SPacketSetItemAmount.Handler(), SPacketSetItemAmount.class, id++, Side.CLIENT); } + + public static void sendPacketToAllPlayers(Packet packet, World world) { + for (Object player : world.playerEntities) { + if (player instanceof EntityPlayerMP) { + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(packet); + } + } + } } diff --git a/src/main/java/com/glodblock/github/util/FluidSorters.java b/src/main/java/com/glodblock/github/util/FluidSorters.java index bc48429a..c6577697 100644 --- a/src/main/java/com/glodblock/github/util/FluidSorters.java +++ b/src/main/java/com/glodblock/github/util/FluidSorters.java @@ -38,15 +38,11 @@ public class FluidSorters { } }; - public static final Comparator CONFIG_BASED_SORT_BY_NAME = new Comparator() { - - @Override - public int compare(final IAEItemStack o1, final IAEItemStack o2) { - if (getDirection() == SortDir.ASCENDING) { - return Platform.getItemDisplayName(o1).compareToIgnoreCase(Platform.getItemDisplayName(o2)); - } - return Platform.getItemDisplayName(o2).compareToIgnoreCase(Platform.getItemDisplayName(o1)); + public static final Comparator CONFIG_BASED_SORT_BY_NAME = (o1, o2) -> { + if (getDirection() == SortDir.ASCENDING) { + return Platform.getItemDisplayName(o1).compareToIgnoreCase(Platform.getItemDisplayName(o2)); } + return Platform.getItemDisplayName(o2).compareToIgnoreCase(Platform.getItemDisplayName(o1)); }; public static final Comparator CONFIG_BASED_SORT_BY_SIZE = new Comparator() { @@ -89,33 +85,15 @@ public class FluidSorters { } public static int compareInt(final int a, final int b) { - if (a == b) { - return 0; - } - if (a < b) { - return -1; - } - return 1; + return Integer.compare(a, b); } public static int compareLong(final long a, final long b) { - if (a == b) { - return 0; - } - if (a < b) { - return -1; - } - return 1; + return Long.compare(a, b); } public static int compareDouble(final double a, final double b) { - if (a == b) { - return 0; - } - if (a < b) { - return -1; - } - return 1; + return Double.compare(a, b); } private static SortDir getDirection() { diff --git a/src/main/java/com/glodblock/github/util/RenderUtil.java b/src/main/java/com/glodblock/github/util/RenderUtil.java index c5a58544..49edf57e 100644 --- a/src/main/java/com/glodblock/github/util/RenderUtil.java +++ b/src/main/java/com/glodblock/github/util/RenderUtil.java @@ -72,4 +72,11 @@ public final class RenderUtil { public static List listFormattedStringToWidth(String str) { return Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(str, 150); } + + public static void setGLColorFromInt(int color) { + float red = (color >> 16 & 255) / 255.0F; + float green = (color >> 8 & 255) / 255.0F; + float blue = (color & 255) / 255.0F; + GL11.glColor4f(red, green, blue, 1.0F); + } } diff --git a/src/main/java/com/glodblock/github/util/Util.java b/src/main/java/com/glodblock/github/util/Util.java index 84863459..75996c79 100644 --- a/src/main/java/com/glodblock/github/util/Util.java +++ b/src/main/java/com/glodblock/github/util/Util.java @@ -218,6 +218,10 @@ public final class Util { } } + public static int clamp(int value, int min, int max) { + return value < min ? min : (Math.min(value, max)); + } + public static class FluidUtil { public static IAEFluidStack createAEFluidStack(Fluid fluid) { diff --git a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/bottom.png b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/bottom.png index 68881f61..692f9b79 100644 Binary files a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/bottom.png and b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/bottom.png differ diff --git a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/cube.png b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/cube.png new file mode 100644 index 00000000..98855b1a Binary files /dev/null and b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/cube.png differ diff --git a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/map.png b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/map.png new file mode 100644 index 00000000..e02664e5 Binary files /dev/null and b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/map.png differ diff --git a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side.png b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side.png index 3d8bd0e6..86bff610 100644 Binary files a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side.png and b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side.png differ diff --git a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_bottom.png b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_bottom.png new file mode 100644 index 00000000..c8a86bb9 Binary files /dev/null and b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_bottom.png differ diff --git a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_mid.png b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_mid.png new file mode 100644 index 00000000..1c5d2b44 Binary files /dev/null and b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_mid.png differ diff --git a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_stacked.png b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_stacked.png deleted file mode 100644 index 804526ef..00000000 Binary files a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_stacked.png and /dev/null differ diff --git a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_top.png b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_top.png new file mode 100644 index 00000000..f4b9ea0a Binary files /dev/null and b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/side_top.png differ diff --git a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/top.png b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/top.png index b8306590..602bfa55 100644 Binary files a/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/top.png and b/src/main/resources/assets/ae2fc/textures/blocks/certus_quartz_tank/top.png differ