mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-17 02:45:08 +00:00
tank
This commit is contained in:
1 parent
99f8e98017
commit
482298021e
25 files changed
+1010
-174
No files matched your search
@@ -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";
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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<Fluid, int[]> flowingRenderCache = new HashMap<>();
|
||||
private static final Map<Fluid, int[]> 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<Fluid, int[]> 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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<String> toolTip,
|
||||
boolean advancedToolTips) {}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -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<BlockTank> {
|
||||
public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegister<BlockCertusQuartzTank> {
|
||||
|
||||
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<BlockT
|
||||
|
||||
if (liquid != null) {
|
||||
tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);
|
||||
if (!p.capabilities.isCreativeMode) {
|
||||
if (!entityplayer.capabilities.isCreativeMode) {
|
||||
if (current.stackSize == 1) {
|
||||
p.inventory.mainInventory[p.inventory.currentItem] = filled;
|
||||
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = filled;
|
||||
} else {
|
||||
p.inventory.mainInventory[p.inventory.currentItem].stackSize--;
|
||||
if (!p.inventory.addItemStackToInventory(filled)) p.entityDropItem(filled, 0);
|
||||
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize--;
|
||||
if (!entityplayer.inventory.addItemStackToInventory(filled))
|
||||
entityplayer.entityDropItem(filled, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -144,6 +166,41 @@ public class BlockCertusQuartzTank extends BlockTank implements IRegister<BlockT
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock) {
|
||||
if (!world.isRemote) {
|
||||
ChannelLoader.sendPacketToAllPlayers(world.getTileEntity(x, y, z).getDescriptionPacket(), world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
if (stack != null && stack.hasTagCompound()) {
|
||||
if (FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("tileEntity")) != null) list.add(
|
||||
FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("tileEntity")).amount
|
||||
+ "mB");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iconregister) {
|
||||
String folder = NameConst.RES_KEY + "certus_quartz_tank/";
|
||||
this.breakIcon = iconregister.registerIcon(folder + "cube");
|
||||
this.topIcon = iconregister.registerIcon(folder + "top");
|
||||
this.bottomIcon = iconregister.registerIcon(folder + "bottom");
|
||||
this.sideIcon = iconregister.registerIcon(folder + "side");
|
||||
this.sideMiddleIcon = iconregister.registerIcon(folder + "side_mid");
|
||||
this.sideTopIcon = iconregister.registerIcon(folder + "side_top");
|
||||
this.sideBottomIcon = iconregister.registerIcon(folder + "side_bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockCertusQuartzTank register() {
|
||||
GameRegistry.registerBlock(this, ItemCertusQuartzTank.class, NameConst.BLOCK_CERTUS_QUARTZ_TANK);
|
||||
@@ -151,8 +208,4 @@ public class BlockCertusQuartzTank extends BlockTank implements IRegister<BlockT
|
||||
setCreativeTab(FluidCraftingTabs.INSTANCE);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack stack() {
|
||||
return new ItemStack(this, 1);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,7 @@
|
||||
package com.glodblock.github.common.item;
|
||||
|
||||
import static com.glodblock.github.common.tile.TileCertusQuartzTank.CAPACITY;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
@@ -14,41 +9,24 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
import com.glodblock.github.common.tile.TileCertusQuartzTank;
|
||||
import com.glodblock.github.crossmod.waila.Tooltip;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
public class ItemCertusQuartzTank extends BaseItemBlockContainer implements IFluidContainerItem {
|
||||
|
||||
public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerItem {
|
||||
|
||||
private final String tagKey = "tank";
|
||||
|
||||
private final int capacity = CAPACITY;
|
||||
private final int capacity = 32000;
|
||||
|
||||
public ItemCertusQuartzTank(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
if (stack != null && stack.hasTagCompound()) {
|
||||
if (FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag(tagKey)) != null) {
|
||||
FluidStack fs = FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag(tagKey));
|
||||
list.add(Tooltip.fluidFormat(fs.getFluid().getLocalizedName(fs), fs.amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) {
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey(tagKey)
|
||||
|| container.stackTagCompound.getCompoundTag(tagKey).hasKey("Empty")) {
|
||||
if (container.stackSize != 1 || container.stackTagCompound == null
|
||||
|| !container.stackTagCompound.hasKey("tileEntity")
|
||||
|| container.stackTagCompound.getCompoundTag("tileEntity").hasKey("Empty")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag(tagKey));
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("tileEntity"));
|
||||
if (stack == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -57,7 +35,7 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
|
||||
stack.amount = Math.min(stack.amount, maxDrain);
|
||||
if (doDrain) {
|
||||
if (currentAmount == stack.amount) {
|
||||
container.stackTagCompound.removeTag(tagKey);
|
||||
container.stackTagCompound.removeTag("tileEntity");
|
||||
|
||||
if (container.stackTagCompound.hasNoTags()) {
|
||||
container.stackTagCompound = null;
|
||||
@@ -65,25 +43,26 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
|
||||
return stack;
|
||||
}
|
||||
|
||||
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag(tagKey);
|
||||
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("tileEntity");
|
||||
fluidTag.setInteger("Amount", currentAmount - stack.amount);
|
||||
container.stackTagCompound.setTag(tagKey, fluidTag);
|
||||
container.stackTagCompound.setTag("tileEntity", fluidTag);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ItemStack container, FluidStack resource, boolean doFill) {
|
||||
if (resource == null) {
|
||||
if (resource == null || container.stackSize != 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!doFill) {
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey(tagKey)) {
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("tileEntity")) {
|
||||
return Math.min(this.capacity, resource.amount);
|
||||
}
|
||||
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag(tagKey));
|
||||
FluidStack stack = FluidStack
|
||||
.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("tileEntity"));
|
||||
|
||||
if (stack == null) {
|
||||
return Math.min(this.capacity, resource.amount);
|
||||
@@ -100,21 +79,21 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
|
||||
container.stackTagCompound = new NBTTagCompound();
|
||||
}
|
||||
|
||||
if (!container.stackTagCompound.hasKey(tagKey)
|
||||
|| container.stackTagCompound.getCompoundTag(tagKey).hasKey("Empty")) {
|
||||
if (!container.stackTagCompound.hasKey("tileEntity")
|
||||
|| container.stackTagCompound.getCompoundTag("tileEntity").hasKey("Empty")) {
|
||||
NBTTagCompound fluidTag = resource.writeToNBT(new NBTTagCompound());
|
||||
|
||||
if (this.capacity < resource.amount) {
|
||||
fluidTag.setInteger("Amount", this.capacity);
|
||||
container.stackTagCompound.setTag(tagKey, fluidTag);
|
||||
container.stackTagCompound.setTag("tileEntity", fluidTag);
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
container.stackTagCompound.setTag(tagKey, fluidTag);
|
||||
container.stackTagCompound.setTag("tileEntity", fluidTag);
|
||||
return resource.amount;
|
||||
}
|
||||
|
||||
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag(tagKey);
|
||||
NBTTagCompound fluidTag = container.stackTagCompound.getCompoundTag("tileEntity");
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(fluidTag);
|
||||
|
||||
if (!stack.isFluidEqual(resource)) {
|
||||
@@ -129,7 +108,7 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
|
||||
stack.amount = this.capacity;
|
||||
}
|
||||
|
||||
container.stackTagCompound.setTag(tagKey, stack.writeToNBT(fluidTag));
|
||||
container.stackTagCompound.setTag("tileEntity", stack.writeToNBT(fluidTag));
|
||||
return filled;
|
||||
}
|
||||
|
||||
@@ -140,10 +119,10 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
|
||||
|
||||
@Override
|
||||
public FluidStack getFluid(ItemStack container) {
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey(tagKey)) {
|
||||
if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("tileEntity")) {
|
||||
return null;
|
||||
}
|
||||
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag(tagKey));
|
||||
return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("tileEntity"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,7 +138,8 @@ public class ItemCertusQuartzTank extends ItemBlock implements IFluidContainerIt
|
||||
}
|
||||
|
||||
if (stack != null && stack.hasTagCompound()) {
|
||||
((TileCertusQuartzTank) world.getTileEntity(x, y, z)).readFromNBTWithoutCoords(stack.getTagCompound());
|
||||
((TileCertusQuartzTank) world.getTileEntity(x, y, z))
|
||||
.readFromNBTWithoutCoords(stack.getTagCompound().getCompoundTag("tileEntity"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,36 +1,274 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.*;
|
||||
|
||||
import buildcraft.factory.TileTank;
|
||||
import com.glodblock.github.loader.ChannelLoader;
|
||||
|
||||
public class TileCertusQuartzTank extends TileTank {
|
||||
public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
|
||||
|
||||
public static final int CAPACITY = FluidContainerRegistry.BUCKET_VOLUME * 32;
|
||||
private FluidStack lastBeforeUpdate = null;
|
||||
public FluidTank tank = new FluidTank(32000) {
|
||||
|
||||
public TileCertusQuartzTank() {
|
||||
super();
|
||||
this.setCapacity();
|
||||
@Override
|
||||
public FluidTank readFromNBT(NBTTagCompound nbt) {
|
||||
if (!nbt.hasKey("Empty")) {
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(nbt);
|
||||
setFluid(fluid);
|
||||
} else {
|
||||
setFluid(null);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid) {
|
||||
return this.tank.getFluid() == null || this.tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
readFromNBTWithoutCoords(data);
|
||||
this.setCapacity();
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid) {
|
||||
return this.tank.getFluid() == null || this.tank.getFluid().getFluid() == fluid;
|
||||
}
|
||||
|
||||
public int getFluidLightLevel() {
|
||||
FluidStack tankFluid = tank.getFluid();
|
||||
return tankFluid == null || tankFluid.amount == 0 ? 0 : tankFluid.getFluid().getLuminosity(tankFluid);
|
||||
}
|
||||
|
||||
public void compareAndUpdate() {
|
||||
if (!this.worldObj.isRemote) {
|
||||
FluidStack current = this.tank.getFluid();
|
||||
if (current != null) {
|
||||
if (this.lastBeforeUpdate != null) {
|
||||
if (Math.abs(current.amount - this.lastBeforeUpdate.amount) >= 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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,15 +38,11 @@ public class FluidSorters {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Comparator<IAEItemStack> CONFIG_BASED_SORT_BY_NAME = new Comparator<IAEItemStack>() {
|
||||
|
||||
@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<IAEItemStack> 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<IAEItemStack> CONFIG_BASED_SORT_BY_SIZE = new Comparator<IAEItemStack>() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -72,4 +72,11 @@ public final class RenderUtil {
|
||||
public static List<String> 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);
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user