Fix for MDK

This commit is contained in:
Aidan Brady 2013-06-02 17:44:59 -04:00
parent c9729e978a
commit a2b6e7867a
13 changed files with 90 additions and 124 deletions

View file

@ -1,10 +1,8 @@
package mekanism.api;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import mekanism.common.Mekanism;
import net.minecraft.item.ItemStack;
/**

View file

@ -3,6 +3,7 @@ package mekanism.api;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
@ -11,6 +12,7 @@ public class Object3D
public int xCoord;
public int yCoord;
public int zCoord;
public int dimensionId;
public Object3D(int x, int y, int z)
@ -18,6 +20,7 @@ public class Object3D
xCoord = x;
yCoord = y;
zCoord = z;
dimensionId = 0;
}
@ -26,20 +29,21 @@ public class Object3D
xCoord = x;
yCoord = y;
zCoord = z;
dimensionId = dimension;
}
public int getMetadata(World world)
public int getMetadata(IBlockAccess world)
{
return world.getBlockMetadata(xCoord, yCoord, zCoord);
}
public int getBlockId(World world)
public int getBlockId(IBlockAccess world)
{
return world.getBlockId(xCoord, yCoord, zCoord);
}
public TileEntity getTileEntity(World world)
public TileEntity getTileEntity(IBlockAccess world)
{
return world.getBlockTileEntity(xCoord, yCoord, zCoord);
}
@ -84,7 +88,7 @@ public class Object3D
return (int)MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ);
}
public boolean sideVisible(ForgeDirection side, World world)
public boolean sideVisible(ForgeDirection side, IBlockAccess world)
{
return world.getBlockId(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ) == 0;
}
@ -109,4 +113,4 @@ public class Object3D
code = 31 * code + dimensionId;
return code;
}
}
}

View file

@ -3,6 +3,7 @@ package mekanism.client;
import mekanism.common.ContainerElectricPump;
import mekanism.common.TileEntityElectricPump;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.liquids.LiquidStack;
@ -44,6 +45,11 @@ public class GuiElectricPump extends GuiContainer
{
drawCreativeTabHoveringText(tileEntity.liquidTank.getLiquid() != null ? tileEntity.liquidTank.getLiquidName() + ": " + tileEntity.liquidTank.getLiquid().amount + "mB" : "Empty", xAxis, yAxis);
}
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
{
drawCreativeTabHoveringText(ElectricityDisplay.getDisplayShort(tileEntity.electricityStored, ElectricUnit.JOULES), xAxis, yAxis);
}
}
@Override

View file

@ -8,6 +8,7 @@ import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.ForgeDirection;
import org.lwjgl.opengl.GL11;
@ -33,10 +34,32 @@ public class MekanismRenderer
public double maxX;
public double maxY;
public double maxZ;
public boolean[] renderSides = new boolean[] {true, true, true, true, true, true};
public Block baseBlock = Block.sand;
public Icon texture = null;
public final void setBlockBounds(float xNeg, float yNeg, float zNeg, float xPos, float yPos, float zPos)
{
minX = xNeg;
minY = yNeg;
minZ = zNeg;
maxX = xPos;
maxY = yPos;
maxZ = zPos;
}
public void setSideRender(ForgeDirection side, boolean value)
{
renderSides[side.ordinal()] = value;
}
public boolean shouldSideRender(ForgeDirection side)
{
return renderSides[side.ordinal()];
}
public Icon getBlockTextureFromSide(int i)
{
@ -55,13 +78,8 @@ public class MekanismRenderer
}
}
public static void renderObject(Model3D object, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating)
public static void renderObject(Model3D object)
{
float f = 0.5F;
float f1 = 1.0F;
float f2 = 0.8F;
float f3 = 0.6F;
renderBlocks.renderMaxX = object.maxX;
renderBlocks.renderMinX = object.minX;
renderBlocks.renderMaxY = object.maxY;
@ -71,105 +89,40 @@ public class MekanismRenderer
renderBlocks.enableAO = false;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
if(doTessellating)
if(object.shouldSideRender(ForgeDirection.DOWN))
{
tessellator.startDrawingQuads();
renderBlocks.renderFaceYNeg(null, 0, 0, 0, object.getBlockTextureFromSide(0));
}
float f4 = 0, f5 = 0;
if(doLight)
if(object.shouldSideRender(ForgeDirection.UP))
{
f4 = object.getBlockBrightness(blockAccess, i, j, k);
f5 = object.getBlockBrightness(blockAccess, i, j, k);
if(f5 < f4)
{
f5 = f4;
}
tessellator.setColorOpaque_F(f * f5, f * f5, f * f5);
renderBlocks.renderFaceYPos(null, 0, 0, 0, object.getBlockTextureFromSide(1));
}
renderBlocks.renderFaceYNeg(null, 0, 0, 0, object.getBlockTextureFromSide(0));
if(doLight)
if(object.shouldSideRender(ForgeDirection.NORTH))
{
f5 = object.getBlockBrightness(blockAccess, i, j, k);
if(f5 < f4)
{
f5 = f4;
}
tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
renderBlocks.renderFaceZNeg(null, 0, 0, 0, object.getBlockTextureFromSide(2));
}
renderBlocks.renderFaceYPos(null, 0, 0, 0, object.getBlockTextureFromSide(1));
if(doLight)
if(object.shouldSideRender(ForgeDirection.SOUTH))
{
f5 = object.getBlockBrightness(blockAccess, i, j, k);
if(f5 < f4)
{
f5 = f4;
}
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
renderBlocks.renderFaceZPos(null, 0, 0, 0, object.getBlockTextureFromSide(3));
}
renderBlocks.renderFaceZNeg(null, 0, 0, 0, object.getBlockTextureFromSide(2));
if(doLight)
if(object.shouldSideRender(ForgeDirection.WEST))
{
f5 = object.getBlockBrightness(blockAccess, i, j, k);
if(f5 < f4)
{
f5 = f4;
}
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
renderBlocks.renderFaceXNeg(null, 0, 0, 0, object.getBlockTextureFromSide(4));
}
renderBlocks.renderFaceZPos(null, 0, 0, 0, object.getBlockTextureFromSide(3));
if(doLight)
if(object.shouldSideRender(ForgeDirection.EAST))
{
f5 = object.getBlockBrightness(blockAccess, i, j, k);
if(f5 < f4)
{
f5 = f4;
}
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
}
renderBlocks.renderFaceXNeg(null, 0, 0, 0, object.getBlockTextureFromSide(4));
if(doLight)
{
f5 = object.getBlockBrightness(blockAccess, i, j, k);
if(f5 < f4)
{
f5 = f4;
}
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
}
renderBlocks.renderFaceXPos(null, 0, 0, 0, object.getBlockTextureFromSide(5));
if(doTessellating)
{
tessellator.draw();
renderBlocks.renderFaceXPos(null, 0, 0, 0, object.getBlockTextureFromSide(5));
}
tessellator.draw();
}
public static void glowOn()

View file

@ -222,7 +222,7 @@ public class RenderConfigurableMachine extends TileEntitySpecialRenderer
}
}
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
return display;

View file

@ -133,7 +133,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
toReturn.maxY = ((float)i/(float)stages)*(data.height-2) - .01;
toReturn.maxZ = data.width-2 - .01;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -245,7 +245,7 @@ public class RenderDynamicTank extends TileEntitySpecialRenderer
}
}
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
return display;

View file

@ -185,7 +185,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.7 - offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -206,7 +206,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 + offset;
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -227,7 +227,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
toReturn.maxY = 1.0;
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -248,7 +248,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.3 + offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -269,7 +269,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 1.0;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -290,7 +290,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.7 - offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -311,7 +311,7 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.7 - offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}

View file

@ -137,7 +137,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.7 - offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -158,7 +158,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 + offset;
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -179,7 +179,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
toReturn.maxY = 1.0;
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -200,7 +200,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.3 + offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -221,7 +221,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 1.0;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -242,7 +242,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.7 - offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -263,7 +263,7 @@ public class RenderPressurizedTube extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.7 - offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}

View file

@ -153,7 +153,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.7 - offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -174,7 +174,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 + offset;
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -195,7 +195,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
toReturn.maxY = 1.0;
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -216,7 +216,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.3 + offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -237,7 +237,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 1.0;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -258,7 +258,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.7 - offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}
@ -279,7 +279,7 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
toReturn.maxZ = 0.7 - offset;
MekanismRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
MekanismRenderer.renderObject(toReturn);
GL11.glEndList();
}

View file

@ -104,23 +104,23 @@ public class BlockGasTank extends BlockContainer
{
TileEntityContainerBlock tileEntity = (TileEntityContainerBlock)world.getBlockTileEntity(x, y, z);
if (tileEntity != null)
if(tileEntity != null)
{
for (int i = 0; i < tileEntity.getSizeInventory(); ++i)
for(int i = 0; i < tileEntity.getSizeInventory(); ++i)
{
ItemStack slotStack = tileEntity.getStackInSlot(i);
if (slotStack != null)
if(slotStack != null)
{
float xRandom = machineRand.nextFloat() * 0.8F + 0.1F;
float yRandom = machineRand.nextFloat() * 0.8F + 0.1F;
float zRandom = machineRand.nextFloat() * 0.8F + 0.1F;
while (slotStack.stackSize > 0)
while(slotStack.stackSize > 0)
{
int j = machineRand.nextInt(21) + 10;
if (j > slotStack.stackSize)
if(j > slotStack.stackSize)
{
j = slotStack.stackSize;
}
@ -128,7 +128,7 @@ public class BlockGasTank extends BlockContainer
slotStack.stackSize -= j;
EntityItem item = new EntityItem(world, (double)((float)x + xRandom), (double)((float)y + yRandom), (double)((float)z + zRandom), new ItemStack(slotStack.itemID, j, slotStack.getItemDamage()));
if (slotStack.hasTagCompound())
if(slotStack.hasTagCompound())
{
item.getEntityItem().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy());
}

View file

@ -45,6 +45,7 @@ public class BlockOre extends Block
case 0:
return icons[0];
}
return null;
}

View file

@ -51,6 +51,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
@Override
public void onUpdate()
{
System.out.println(worldObj.isRemote + " " + (liquidTank.getLiquid() != null ? liquidTank.getLiquid().amount : "ASDF"));
ChargeUtils.discharge(2, this);
if(inventory[0] != null)
@ -298,8 +299,8 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
if(liquidTank.getLiquid() != null)
{
data.add(1);
data.add(liquidTank.getLiquid().amount);
data.add(liquidTank.getLiquid().itemID);
data.add(liquidTank.getLiquid().amount);
data.add(liquidTank.getLiquid().itemMeta);
}
else {

View file

@ -249,8 +249,11 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS
public void handlePacketData(ByteArrayDataInput dataStream)
{
super.handlePacketData(dataStream);
gasStored = dataStream.readInt();
gasType = EnumGas.getFromName(dataStream.readUTF());
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
@Override