*Electric Chest item-based close animation now occurs in entity form.
*Made liquids render in Mechanical Pipes. *Made energy render in Universal Cable. *Fixed electric pump not outputting it's liquid. *Made Heat Generator only accept lava as a liquid fuel source. *Migrated Heat Generator to use LiquidTank instead of LiquidSlot. *Client-integrated transfer protocols.
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 15 KiB |
BIN
bin/minecraft/mods/mekanism/textures/items/LiquidEnergy.png
Normal file
After Width: | Height: | Size: 17 KiB |
32
bin/minecraft/mods/mekanism/textures/items/LiquidEnergy.txt
Normal file
|
@ -0,0 +1,32 @@
|
|||
0*2
|
||||
1*2
|
||||
2*2
|
||||
3*2
|
||||
4*2
|
||||
5*2
|
||||
6*2
|
||||
7*2
|
||||
8*2
|
||||
9*2
|
||||
10*2
|
||||
11*2
|
||||
12*2
|
||||
13*2
|
||||
14*2
|
||||
15*2
|
||||
16*2
|
||||
17*2
|
||||
18*2
|
||||
19*2
|
||||
20*2
|
||||
21*2
|
||||
22*2
|
||||
23*2
|
||||
24*2
|
||||
25*2
|
||||
26*2
|
||||
27*2
|
||||
28*2
|
||||
29*2
|
||||
30*2
|
||||
31*2
|
|
@ -73,6 +73,7 @@ public class BlockVector
|
|||
code = 31 * code + xCoord;
|
||||
code = 31 * code + yCoord;
|
||||
code = 31 * code + zCoord;
|
||||
code = 31 * code + dimensionId;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package mekanism.api;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
/**
|
||||
* Implement this in your TileEntity class if the block can transfer liquid as a Mechanical Pipe.
|
||||
|
@ -14,4 +15,10 @@ public interface IMechanicalPipe
|
|||
* @return if the pipe can transfer liquids
|
||||
*/
|
||||
public boolean canTransferLiquids(TileEntity fromTile);
|
||||
|
||||
/**
|
||||
* Called when liquid is transferred through this pipe.
|
||||
* @param liquidStack - the liquid transferred
|
||||
*/
|
||||
public void onTransfer(LiquidStack liquidStack);
|
||||
}
|
||||
|
|
|
@ -14,4 +14,9 @@ public interface IUniversalCable
|
|||
* @return if the cable can transfer energy
|
||||
*/
|
||||
public boolean canTransferEnergy(TileEntity fromTile);
|
||||
|
||||
/**
|
||||
* Called when energy is transferred through this cable.
|
||||
*/
|
||||
public void onTransfer();
|
||||
}
|
||||
|
|
161
src/minecraft/mekanism/client/ObjectRenderer.java
Normal file
|
@ -0,0 +1,161 @@
|
|||
package mekanism.client;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class ObjectRenderer
|
||||
{
|
||||
private static RenderBlocks renderBlocks = new RenderBlocks();
|
||||
|
||||
public static class Object3D
|
||||
{
|
||||
public double minX;
|
||||
public double minY;
|
||||
public double minZ;
|
||||
public double maxX;
|
||||
public double maxY;
|
||||
public double maxZ;
|
||||
|
||||
public int lightValue;
|
||||
|
||||
public Block baseBlock = Block.sand;
|
||||
|
||||
public Icon texture = null;
|
||||
|
||||
public Icon getBlockTextureFromSide(int i)
|
||||
{
|
||||
if(texture == null)
|
||||
{
|
||||
return baseBlock.getBlockTextureFromSide(i);
|
||||
}
|
||||
else {
|
||||
return texture;
|
||||
}
|
||||
}
|
||||
|
||||
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k)
|
||||
{
|
||||
return baseBlock.getBlockBrightness(iblockaccess, i, j, k);
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderObject(Object3D object, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating)
|
||||
{
|
||||
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;
|
||||
renderBlocks.renderMinY = object.minY;
|
||||
renderBlocks.renderMaxZ = object.maxZ;
|
||||
renderBlocks.renderMinZ = object.minZ;
|
||||
|
||||
renderBlocks.enableAO = false;
|
||||
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
if(doTessellating)
|
||||
{
|
||||
tessellator.startDrawingQuads();
|
||||
}
|
||||
|
||||
float f4 = 0, f5 = 0;
|
||||
|
||||
if(doLight)
|
||||
{
|
||||
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.renderBottomFace(null, 0, 0, 0, object.getBlockTextureFromSide(0));
|
||||
|
||||
if(doLight)
|
||||
{
|
||||
f5 = object.getBlockBrightness(blockAccess, i, j, k);
|
||||
|
||||
if(f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
|
||||
tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderTopFace(null, 0, 0, 0, object.getBlockTextureFromSide(1));
|
||||
|
||||
if(doLight)
|
||||
{
|
||||
f5 = object.getBlockBrightness(blockAccess, i, j, k);
|
||||
|
||||
if(f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
|
||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderEastFace(null, 0, 0, 0, object.getBlockTextureFromSide(2));
|
||||
|
||||
if(doLight)
|
||||
{
|
||||
f5 = object.getBlockBrightness(blockAccess, i, j, k);
|
||||
|
||||
if(f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
|
||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderWestFace(null, 0, 0, 0, object.getBlockTextureFromSide(3));
|
||||
|
||||
if(doLight)
|
||||
{
|
||||
f5 = object.getBlockBrightness(blockAccess, i, j, k);
|
||||
|
||||
if(f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
|
||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderNorthFace(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.renderSouthFace(null, 0, 0, 0, object.getBlockTextureFromSide(5));
|
||||
|
||||
if(doTessellating)
|
||||
{
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,21 @@
|
|||
package mekanism.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mekanism.client.ObjectRenderer.Object3D;
|
||||
import mekanism.common.CableUtils;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PipeUtils;
|
||||
import mekanism.common.TileEntityMechanicalPipe;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.ITankContainer;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -21,6 +28,12 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
{
|
||||
private ModelTransmitter model = new ModelTransmitter();
|
||||
|
||||
private HashMap<ForgeDirection, HashMap<LiquidStack, int[]>> cachedLiquids = new HashMap<ForgeDirection, HashMap<LiquidStack, int[]>>();
|
||||
|
||||
private static final int stages = 40;
|
||||
|
||||
private static final double offset = 0.015;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
|
@ -76,5 +89,210 @@ public class RenderMechanicalPipe extends TileEntitySpecialRenderer
|
|||
|
||||
model.Center.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(tileEntity.liquidScale > 0 && tileEntity.refLiquid != null)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(2896);
|
||||
bindTextureByName(tileEntity.refLiquid.getTextureSheet());
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectable[i])
|
||||
{
|
||||
int[] displayList = getListAndRender(ForgeDirection.getOrientation(i), tileEntity.refLiquid, tileEntity.worldObj);
|
||||
GL11.glCallList(displayList[Math.max(3, (int)((float)tileEntity.liquidScale*(stages-1)))]);
|
||||
}
|
||||
}
|
||||
|
||||
int[] displayList = getListAndRender(ForgeDirection.UNKNOWN, tileEntity.refLiquid, tileEntity.worldObj);
|
||||
GL11.glCallList(displayList[Math.max(3, (int)((float)tileEntity.liquidScale*(stages-1)))]);
|
||||
|
||||
GL11.glEnable(2896);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private int[] getListAndRender(ForgeDirection side, LiquidStack stack, World world)
|
||||
{
|
||||
if(cachedLiquids.containsKey(side) && cachedLiquids.get(side).containsKey(stack))
|
||||
{
|
||||
return cachedLiquids.get(side).get(stack);
|
||||
}
|
||||
|
||||
Object3D toReturn = new Object3D();
|
||||
toReturn.baseBlock = Block.waterStill;
|
||||
toReturn.texture = stack.getRenderingIcon();
|
||||
|
||||
if(stack.itemID < Block.blocksList.length && Block.blocksList[stack.itemID] != null)
|
||||
{
|
||||
toReturn.baseBlock = Block.blocksList[stack.itemID];
|
||||
}
|
||||
|
||||
int[] displays = new int[stages];
|
||||
|
||||
if(cachedLiquids.containsKey(side))
|
||||
{
|
||||
cachedLiquids.get(side).put(stack, displays);
|
||||
}
|
||||
else {
|
||||
HashMap<LiquidStack, int[]> map = new HashMap<LiquidStack, int[]>();
|
||||
map.put(stack, displays);
|
||||
cachedLiquids.put(side, map);
|
||||
}
|
||||
|
||||
switch(side)
|
||||
{
|
||||
case UNKNOWN:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case DOWN:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
toReturn.minY = 0.0;
|
||||
toReturn.minZ = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
|
||||
toReturn.maxX = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
toReturn.maxY = 0.3 + offset;
|
||||
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case UP:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
toReturn.minY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.minZ = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
|
||||
toReturn.maxX = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
toReturn.maxY = 1.0;
|
||||
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case NORTH:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.0;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.3 + offset;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case SOUTH:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.7 - offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 1.0;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case WEST:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.0;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.3 + offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case EAST:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.7 - offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 1.0;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
package mekanism.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mekanism.client.ObjectRenderer.Object3D;
|
||||
import mekanism.common.CableUtils;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.TileEntityUniversalCable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.liquids.LiquidContainerRegistry;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
@ -18,6 +26,12 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
|
|||
{
|
||||
private ModelTransmitter model = new ModelTransmitter();
|
||||
|
||||
private HashMap<ForgeDirection, int[]> cachedLiquids = new HashMap<ForgeDirection, int[]>();
|
||||
|
||||
private static final int stages = 40;
|
||||
|
||||
private static final double offset = 0.015;
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
|
||||
{
|
||||
|
@ -77,5 +91,197 @@ public class RenderUniversalCable extends TileEntitySpecialRenderer
|
|||
|
||||
model.Center.render(0.0625F);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(tileEntity.liquidScale > 0)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDisable(2896);
|
||||
bindTextureByName("/mods/mekanism/textures/items/LiquidEnergy.png");
|
||||
GL11.glTranslatef((float)x, (float)y, (float)z);
|
||||
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectable[i])
|
||||
{
|
||||
int[] displayList = getListAndRender(ForgeDirection.getOrientation(i), tileEntity.worldObj);
|
||||
GL11.glCallList(displayList[Math.max(3, (int)((float)tileEntity.liquidScale*(stages-1)))]);
|
||||
}
|
||||
}
|
||||
|
||||
int[] displayList = getListAndRender(ForgeDirection.UNKNOWN, tileEntity.worldObj);
|
||||
GL11.glCallList(displayList[Math.max(3, (int)((float)tileEntity.liquidScale*(stages-1)))]);
|
||||
|
||||
GL11.glEnable(2896);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
private int[] getListAndRender(ForgeDirection side, World world)
|
||||
{
|
||||
if(cachedLiquids.containsKey(side))
|
||||
{
|
||||
return cachedLiquids.get(side);
|
||||
}
|
||||
|
||||
Object3D toReturn = new Object3D();
|
||||
toReturn.baseBlock = Block.waterStill;
|
||||
toReturn.texture = Mekanism.LiquidEnergy.getIconFromDamage(0);
|
||||
|
||||
int[] displays = new int[stages];
|
||||
|
||||
cachedLiquids.put(side, displays);
|
||||
|
||||
switch(side)
|
||||
{
|
||||
case UNKNOWN:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case DOWN:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
toReturn.minY = 0.0;
|
||||
toReturn.minZ = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
|
||||
toReturn.maxX = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
toReturn.maxY = 0.3 + offset;
|
||||
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case UP:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
toReturn.minY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.minZ = 0.5 + offset - ((float)i / (float)100)/2;
|
||||
|
||||
toReturn.maxX = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
toReturn.maxY = 1.0;
|
||||
toReturn.maxZ = 0.5 - offset + ((float)i / (float)100)/2;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case NORTH:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.0;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.3 + offset;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case SOUTH:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.3 + offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.7 - offset;
|
||||
|
||||
toReturn.maxX = 0.7 - offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 1.0;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case WEST:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.0;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 0.3 + offset;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
case EAST:
|
||||
{
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(displays[i], 4864);
|
||||
|
||||
toReturn.minX = 0.7 - offset;
|
||||
toReturn.minY = 0.3 + offset;
|
||||
toReturn.minZ = 0.3 + offset;
|
||||
|
||||
toReturn.maxX = 1.0;
|
||||
toReturn.maxY = 0.3 - offset + ((float)i / (float)100);
|
||||
toReturn.maxZ = 0.7 - offset;
|
||||
|
||||
ObjectRenderer.renderObject(toReturn, world, 0, 0, 0, false, true);
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public class SoundHandler
|
|||
|
||||
/**
|
||||
* Create and return an instance of a Sound.
|
||||
* @param tileEntity -- the holder of this sound.
|
||||
* @param tileEntity - the holder of this sound.
|
||||
* @return Sound instance
|
||||
*/
|
||||
public void register(TileEntity tileEntity)
|
||||
|
|
|
@ -47,6 +47,31 @@ public class BlockTransmitter extends Block
|
|||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightValue(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if(tileEntity instanceof TileEntityMechanicalPipe)
|
||||
{
|
||||
TileEntityMechanicalPipe mechanicalPipe = (TileEntityMechanicalPipe)tileEntity;
|
||||
|
||||
if(mechanicalPipe.refLiquid != null)
|
||||
{
|
||||
if(mechanicalPipe.refLiquid.itemID == Block.lavaStill.blockID)
|
||||
{
|
||||
return (int)(mechanicalPipe.liquidScale*16F);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(tileEntity instanceof TileEntityUniversalCable)
|
||||
{
|
||||
return (int)(((TileEntityUniversalCable)tileEntity).liquidScale*16F);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)
|
||||
{
|
||||
|
|
|
@ -4,11 +4,10 @@ import java.util.EnumSet;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public class CommonTickHandler implements ITickHandler
|
||||
public class CommonPlayerTickHandler implements ITickHandler
|
||||
{
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
|
@ -91,6 +90,6 @@ public class CommonTickHandler implements ITickHandler
|
|||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return "MekanismCommon";
|
||||
return "MekanismCommonPlayer";
|
||||
}
|
||||
}
|
|
@ -104,7 +104,8 @@ public class CommonProxy
|
|||
*/
|
||||
public void loadUtilities()
|
||||
{
|
||||
TickRegistry.registerTickHandler(new CommonTickHandler(), Side.SERVER);
|
||||
TickRegistry.registerTickHandler(new CommonPlayerTickHandler(), Side.SERVER);
|
||||
TickRegistry.registerTickHandler(new CommonWorldTickHandler(), Side.SERVER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
60
src/minecraft/mekanism/common/CommonWorldTickHandler.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package mekanism.common;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.ITickHandler;
|
||||
import cpw.mods.fml.common.TickType;
|
||||
|
||||
public class CommonWorldTickHandler implements ITickHandler
|
||||
{
|
||||
@Override
|
||||
public void tickStart(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickEnd(EnumSet<TickType> type, Object... tickData)
|
||||
{
|
||||
if(tickData[0] instanceof World)
|
||||
{
|
||||
World world = (World)tickData[0];
|
||||
|
||||
for(Object obj : world.loadedEntityList)
|
||||
{
|
||||
if(obj instanceof EntityItem)
|
||||
{
|
||||
EntityItem item = (EntityItem)obj;
|
||||
|
||||
if(item.getEntityItem() != null)
|
||||
{
|
||||
ItemStack itemStack = item.getEntityItem();
|
||||
|
||||
if(itemStack.getItem() instanceof IElectricChest)
|
||||
{
|
||||
if(((IElectricChest)itemStack.getItem()).isElectricChest(itemStack))
|
||||
{
|
||||
itemStack.getItem().onUpdate(itemStack, world, null, 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<TickType> ticks()
|
||||
{
|
||||
return EnumSet.of(TickType.WORLD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel()
|
||||
{
|
||||
return "MekanismCommonWorld";
|
||||
}
|
||||
}
|
|
@ -8,13 +8,14 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import universalelectricity.core.block.IElectricityStorage;
|
||||
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import mekanism.api.IStrictEnergyAcceptor;
|
||||
import mekanism.api.IUniversalCable;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.block.IElectricityStorage;
|
||||
import buildcraft.api.power.IPowerReceptor;
|
||||
|
||||
public class EnergyTransferProtocol
|
||||
{
|
||||
|
@ -115,7 +116,10 @@ public class EnergyTransferProtocol
|
|||
}
|
||||
}
|
||||
|
||||
iteratedCables.add(tile);
|
||||
if(!iteratedCables.contains(tile))
|
||||
{
|
||||
iteratedCables.add(tile);
|
||||
}
|
||||
|
||||
TileEntity[] tubes = CableUtils.getConnectedCables(tile);
|
||||
|
||||
|
@ -139,41 +143,60 @@ public class EnergyTransferProtocol
|
|||
{
|
||||
loopThrough(pointer);
|
||||
|
||||
boolean fill = FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
|
||||
Collections.shuffle(availableAcceptors);
|
||||
|
||||
if(!availableAcceptors.isEmpty())
|
||||
if(fill)
|
||||
{
|
||||
int divider = availableAcceptors.size();
|
||||
double remaining = energyToSend % divider;
|
||||
double currentRemaining = remaining;
|
||||
double sending = (energyToSend-remaining)/divider;
|
||||
|
||||
for(TileEntity acceptor : availableAcceptors)
|
||||
if(!availableAcceptors.isEmpty())
|
||||
{
|
||||
double currentSending = sending;
|
||||
int divider = availableAcceptors.size();
|
||||
double remaining = energyToSend % divider;
|
||||
double currentRemaining = remaining;
|
||||
double sending = (energyToSend-remaining)/divider;
|
||||
|
||||
if(currentRemaining > 0)
|
||||
for(TileEntity acceptor : availableAcceptors)
|
||||
{
|
||||
currentSending += (currentRemaining/divider);
|
||||
currentRemaining -= (currentRemaining/divider);
|
||||
double currentSending = sending;
|
||||
|
||||
if(currentRemaining > 0)
|
||||
{
|
||||
currentSending += (currentRemaining/divider);
|
||||
currentRemaining -= (currentRemaining/divider);
|
||||
}
|
||||
|
||||
if(acceptor instanceof IStrictEnergyAcceptor)
|
||||
{
|
||||
energyToSend -= (currentSending - ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(currentSending));
|
||||
}
|
||||
else if(acceptor instanceof IEnergySink)
|
||||
{
|
||||
double toSend = Math.min(currentSending, (((IEnergySink)acceptor).getMaxSafeInput()*Mekanism.FROM_IC2));
|
||||
energyToSend -= (toSend - (((IEnergySink)acceptor).injectEnergy(MekanismUtils.toIC2Direction(acceptorDirections.get(acceptor).getOpposite()), (int)(toSend*Mekanism.TO_IC2))*Mekanism.FROM_IC2));
|
||||
}
|
||||
else if(acceptor instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
|
||||
{
|
||||
IPowerReceptor receptor = (IPowerReceptor)acceptor;
|
||||
double electricityNeeded = Math.min(receptor.powerRequest(acceptorDirections.get(acceptor).getOpposite()), receptor.getPowerProvider().getMaxEnergyStored() - receptor.getPowerProvider().getEnergyStored())*Mekanism.FROM_BC;
|
||||
float transferEnergy = (float)Math.min(electricityNeeded, currentSending);
|
||||
receptor.getPowerProvider().receiveEnergy((float)(transferEnergy*Mekanism.TO_BC), acceptorDirections.get(acceptor).getOpposite());
|
||||
energyToSend -= transferEnergy;
|
||||
}
|
||||
}
|
||||
|
||||
if(acceptor instanceof IStrictEnergyAcceptor)
|
||||
}
|
||||
}
|
||||
else {
|
||||
double needed = neededEnergy();
|
||||
|
||||
if(needed > 0 && energyToSend > 0)
|
||||
{
|
||||
for(TileEntity tileEntity : iteratedCables)
|
||||
{
|
||||
energyToSend -= (currentSending - ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(currentSending));
|
||||
}
|
||||
else if(acceptor instanceof IEnergySink)
|
||||
{
|
||||
double toSend = Math.min(currentSending, (((IEnergySink)acceptor).getMaxSafeInput()*Mekanism.FROM_IC2));
|
||||
energyToSend -= (toSend - (((IEnergySink)acceptor).injectEnergy(MekanismUtils.toIC2Direction(acceptorDirections.get(acceptor).getOpposite()), (int)(toSend*Mekanism.TO_IC2))*Mekanism.FROM_IC2));
|
||||
}
|
||||
else if(acceptor instanceof IPowerReceptor && Mekanism.hooks.BuildCraftLoaded)
|
||||
{
|
||||
IPowerReceptor receptor = (IPowerReceptor)acceptor;
|
||||
double electricityNeeded = Math.min(receptor.powerRequest(acceptorDirections.get(acceptor).getOpposite()), receptor.getPowerProvider().getMaxEnergyStored() - receptor.getPowerProvider().getEnergyStored())*Mekanism.FROM_BC;
|
||||
float transferEnergy = (float)Math.min(electricityNeeded, currentSending);
|
||||
receptor.getPowerProvider().receiveEnergy((float)(transferEnergy*Mekanism.TO_BC), acceptorDirections.get(acceptor).getOpposite());
|
||||
energyToSend -= transferEnergy;
|
||||
if(tileEntity instanceof IUniversalCable)
|
||||
{
|
||||
((IUniversalCable)tileEntity).onTransfer();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import mekanism.api.GasTransmission;
|
||||
import mekanism.api.IGasAcceptor;
|
||||
import mekanism.api.IGasStorage;
|
||||
|
@ -148,6 +150,7 @@ public class LiquidTransferProtocol
|
|||
{
|
||||
loopThrough(pointer);
|
||||
|
||||
boolean fill = FMLCommonHandler.instance().getEffectiveSide().isServer();
|
||||
Collections.shuffle(availableAcceptors);
|
||||
|
||||
int liquidSent = 0;
|
||||
|
@ -184,7 +187,7 @@ public class LiquidTransferProtocol
|
|||
tankRemaining--;
|
||||
}
|
||||
|
||||
liquidSent += acceptor.fill(acceptorDirections.get(acceptor), new LiquidStack(liquidToSend.itemID, tankCurrentSending, liquidToSend.itemMeta), true);
|
||||
liquidSent += acceptor.fill(acceptorDirections.get(acceptor), new LiquidStack(liquidToSend.itemID, tankCurrentSending, liquidToSend.itemMeta), fill);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -192,12 +195,27 @@ public class LiquidTransferProtocol
|
|||
{
|
||||
ILiquidTank tank = acceptor.getTank(acceptorDirections.get(acceptor), liquidToSend);
|
||||
|
||||
liquidSent += acceptor.fill(acceptorDirections.get(acceptor), new LiquidStack(liquidToSend.itemID, currentSending, liquidToSend.itemMeta), true);
|
||||
liquidSent += acceptor.fill(acceptorDirections.get(acceptor), new LiquidStack(liquidToSend.itemID, currentSending, liquidToSend.itemMeta), fill);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!fill && liquidSent > 0)
|
||||
{
|
||||
for(TileEntity tileEntity : iteratedPipes)
|
||||
{
|
||||
if(tileEntity instanceof IMechanicalPipe)
|
||||
{
|
||||
LiquidStack sendStack = liquidToSend.copy();
|
||||
sendStack.amount = liquidSent;
|
||||
((IMechanicalPipe)tileEntity).onTransfer(sendStack);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return liquidSent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,6 +126,7 @@ public class Mekanism
|
|||
public static Item PortableTeleporter;
|
||||
public static Item TeleportationCore;
|
||||
public static Item Configurator;
|
||||
public static Item LiquidEnergy;
|
||||
|
||||
//Blocks
|
||||
public static Block BasicBlock;
|
||||
|
@ -310,6 +311,9 @@ public class Mekanism
|
|||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 13), new Object[] {
|
||||
"SGS", "CcC", "SSS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), Block.glass, Character.valueOf('C'), Block.chest, Character.valueOf('c'), ControlCircuit
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(Transmitter, 8, 2), new Object[] {
|
||||
"O O", Character.valueOf('O'), "ingotOsmium"
|
||||
}));
|
||||
|
||||
//Factory Recipes
|
||||
CraftingManager.getInstance().getRecipeList().add(new FactoryRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, RecipeType.SMELTING), new Object[] {
|
||||
|
@ -426,6 +430,7 @@ public class Mekanism
|
|||
LanguageRegistry.addName(PortableTeleporter, "Portable Teleporter");
|
||||
LanguageRegistry.addName(TeleportationCore, "Teleportation Core");
|
||||
LanguageRegistry.addName(Configurator, "Configurator");
|
||||
LanguageRegistry.addName(LiquidEnergy, "Liquid Energy");
|
||||
|
||||
//Localization for BasicBlock
|
||||
LanguageRegistry.instance().addStringLocalization("tile.BasicBlock.OsmiumBlock.name", "Osmium Block");
|
||||
|
@ -527,7 +532,7 @@ public class Mekanism
|
|||
EnergyTablet = (ItemEnergized) new ItemEnergized(configuration.getItem("EnergyTablet", 11206).getInt(), 1000000, 120).setUnlocalizedName("EnergyTablet");
|
||||
SpeedUpgrade = new ItemMachineUpgrade(configuration.getItem("SpeedUpgrade", 11207).getInt(), 0, 150).setUnlocalizedName("SpeedUpgrade");
|
||||
EnergyUpgrade = new ItemMachineUpgrade(configuration.getItem("EnergyUpgrade", 11208).getInt(), 1000, 0).setUnlocalizedName("EnergyUpgrade");
|
||||
//FREE ID 11209
|
||||
LiquidEnergy = new ItemMekanism(configuration.getItem("LiquidEnergy", 11209).getInt()).setUnlocalizedName("LiquidEnergy").setCreativeTab(null);
|
||||
AtomicDisassembler = (ItemAtomicDisassembler) new ItemAtomicDisassembler(configuration.getItem("AtomicDisassembler", 11210).getInt()).setUnlocalizedName("AtomicDisassembler");
|
||||
AtomicCore = new ItemMekanism(configuration.getItem("AtomicCore", 11211).getInt()).setUnlocalizedName("AtomicCore");
|
||||
EnrichedAlloy = new ItemMekanism(configuration.getItem("EnrichedAlloy", 11212).getInt()).setUnlocalizedName("EnrichedAlloy");
|
||||
|
@ -556,6 +561,7 @@ public class Mekanism
|
|||
GameRegistry.registerItem(EnergyTablet, "EnergyTablet");
|
||||
GameRegistry.registerItem(SpeedUpgrade, "SpeedUpgrade");
|
||||
GameRegistry.registerItem(EnergyUpgrade, "EnergyUpgrade");
|
||||
GameRegistry.registerItem(LiquidEnergy, "LiquidEnergy");
|
||||
GameRegistry.registerItem(AtomicDisassembler, "AtomicDisassembler");
|
||||
GameRegistry.registerItem(AtomicCore, "AtomicCore");
|
||||
GameRegistry.registerItem(EnrichedAlloy, "EnrichedAlloy");
|
||||
|
|
|
@ -34,6 +34,10 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
/** BuildCraft power provider. */
|
||||
public IPowerProvider powerProvider;
|
||||
|
||||
public boolean prevFull;
|
||||
|
||||
public boolean prevEmpty;
|
||||
|
||||
/**
|
||||
* The base of all blocks that deal with electricity. It has a facing state, initialized state,
|
||||
* and a current amount of stored energy.
|
||||
|
@ -69,6 +73,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
{
|
||||
ElectricityPack electricityPack = ElectricityNetworkHelper.consumeFromMultipleSides(this, getConsumingSides(), getRequest());
|
||||
setJoules(getJoules()+electricityPack.getWatts());
|
||||
|
||||
if(prevFull != (getMaxEnergy() == getEnergy()) || prevEmpty != (getEnergy() == 0))
|
||||
{
|
||||
PacketHandler.sendTileEntityPacketToClients(this, 50, getNetworkedData(new ArrayList()));
|
||||
}
|
||||
|
||||
prevFull = getMaxEnergy() == getEnergy();
|
||||
prevEmpty = getEnergy() == 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
|||
/** Random for this pump */
|
||||
public Random random = new Random();
|
||||
|
||||
public boolean prevEmpty;
|
||||
|
||||
public TileEntityElectricPump()
|
||||
{
|
||||
super("Electric Pump", 10000);
|
||||
|
@ -60,8 +62,6 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
|||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
ChargeUtils.discharge(2, this);
|
||||
|
||||
if(inventory[0] != null)
|
||||
|
@ -110,14 +110,28 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
|||
if(suck(true))
|
||||
{
|
||||
clean(true);
|
||||
PacketHandler.sendTileEntityPacketToClients(this, 50, getNetworkedData(new ArrayList()));
|
||||
}
|
||||
else {
|
||||
clean(true);
|
||||
cleaningNodes.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*if(liquidTank.getLiquid() != null)
|
||||
super.onUpdate();
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(prevEmpty != (liquidTank.getLiquid() == null || liquidTank.getLiquid().amount == 0))
|
||||
{
|
||||
PacketHandler.sendTileEntityPacketToClients(this, 50, getNetworkedData(new ArrayList()));
|
||||
}
|
||||
|
||||
prevEmpty = liquidTank.getLiquid() == null;
|
||||
}
|
||||
|
||||
if(liquidTank.getLiquid() != null)
|
||||
{
|
||||
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
|
@ -133,7 +147,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
|||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
public boolean suck(boolean take)
|
||||
|
|
|
@ -67,17 +67,19 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
|
|||
ChargeUtils.charge(0, this);
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(facing));
|
||||
|
||||
if(electricityStored > 0)
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(facing));
|
||||
|
||||
if(electricityStored > 0)
|
||||
if(tileEntity instanceof IUniversalCable)
|
||||
{
|
||||
if(tileEntity instanceof IUniversalCable)
|
||||
{
|
||||
setJoules(electricityStored - (Math.min(electricityStored, tier.OUTPUT) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, tier.OUTPUT), this, ForgeDirection.getOrientation(facing))));
|
||||
}
|
||||
else if((tileEntity instanceof IEnergyConductor || tileEntity instanceof IEnergyAcceptor) && Mekanism.hooks.IC2Loaded)
|
||||
setJoules(electricityStored - (Math.min(electricityStored, tier.OUTPUT) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, tier.OUTPUT), this, ForgeDirection.getOrientation(facing))));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if((tileEntity instanceof IEnergyConductor || tileEntity instanceof IEnergyAcceptor) && Mekanism.hooks.IC2Loaded)
|
||||
{
|
||||
if(electricityStored >= tier.OUTPUT)
|
||||
{
|
||||
|
@ -95,40 +97,40 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
|
|||
setJoules(electricityStored - transferEnergy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && tileEntity instanceof IConductor)
|
||||
{
|
||||
ForgeDirection outputDirection = ForgeDirection.getOrientation(facing);
|
||||
ArrayList<IElectricityNetwork> inputNetworks = new ArrayList<IElectricityNetwork>();
|
||||
|
||||
if(tileEntity instanceof IConductor)
|
||||
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
ForgeDirection outputDirection = ForgeDirection.getOrientation(facing);
|
||||
ArrayList<IElectricityNetwork> inputNetworks = new ArrayList<IElectricityNetwork>();
|
||||
|
||||
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
if(direction != outputDirection)
|
||||
{
|
||||
if(direction != outputDirection)
|
||||
IElectricityNetwork network = ElectricityNetworkHelper.getNetworkFromTileEntity(VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), direction), direction);
|
||||
if(network != null)
|
||||
{
|
||||
IElectricityNetwork network = ElectricityNetworkHelper.getNetworkFromTileEntity(VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), direction), direction);
|
||||
if(network != null)
|
||||
{
|
||||
inputNetworks.add(network);
|
||||
}
|
||||
inputNetworks.add(network);
|
||||
}
|
||||
}
|
||||
|
||||
TileEntity outputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), outputDirection);
|
||||
}
|
||||
|
||||
TileEntity outputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), outputDirection);
|
||||
|
||||
IElectricityNetwork outputNetwork = ElectricityNetworkHelper.getNetworkFromTileEntity(outputTile, outputDirection);
|
||||
IElectricityNetwork outputNetwork = ElectricityNetworkHelper.getNetworkFromTileEntity(outputTile, outputDirection);
|
||||
|
||||
if(outputNetwork != null && !inputNetworks.contains(outputNetwork))
|
||||
if(outputNetwork != null && !inputNetworks.contains(outputNetwork))
|
||||
{
|
||||
double outputWatts = Math.min(outputNetwork.getRequest().getWatts(), Math.min(getJoules(), 10000));
|
||||
|
||||
if(getJoules() > 0 && outputWatts > 0 && getJoules()-outputWatts >= 0)
|
||||
{
|
||||
double outputWatts = Math.min(outputNetwork.getRequest().getWatts(), Math.min(getJoules(), 10000));
|
||||
|
||||
if(getJoules() > 0 && outputWatts > 0 && getJoules()-outputWatts >= 0)
|
||||
{
|
||||
outputNetwork.startProducing(this, Math.min(outputWatts, getJoules()) / getVoltage(), getVoltage());
|
||||
setJoules(electricityStored - outputWatts);
|
||||
}
|
||||
else {
|
||||
outputNetwork.stopProducing(this);
|
||||
}
|
||||
outputNetwork.startProducing(this, Math.min(outputWatts, getJoules()) / getVoltage(), getVoltage());
|
||||
setJoules(electricityStored - outputWatts);
|
||||
}
|
||||
else {
|
||||
outputNetwork.stopProducing(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,18 +25,58 @@ public class TileEntityMechanicalPipe extends TileEntity implements IMechanicalP
|
|||
{
|
||||
public LiquidTank dummyTank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
|
||||
|
||||
public LiquidStack refLiquid = null;
|
||||
|
||||
public boolean isActive = false;
|
||||
|
||||
public float liquidScale;
|
||||
|
||||
public float prevRoundedScale;
|
||||
|
||||
@Override
|
||||
public boolean canTransferLiquids(TileEntity fromTile)
|
||||
{
|
||||
return worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransfer(LiquidStack liquidStack)
|
||||
{
|
||||
if(liquidStack.isLiquidEqual(refLiquid))
|
||||
{
|
||||
liquidScale = Math.min(1, liquidScale+((float)liquidStack.amount/(float)3000));
|
||||
}
|
||||
else if(refLiquid == null)
|
||||
{
|
||||
refLiquid = liquidStack.copy();
|
||||
liquidScale += Math.min(1, (float)liquidStack.amount/(float)3000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(!worldObj.isRemote && isActive)
|
||||
if(liquidScale > 0)
|
||||
{
|
||||
liquidScale -= .01;
|
||||
}
|
||||
else {
|
||||
refLiquid = null;
|
||||
}
|
||||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
float roundedScale = liquidScale*16F;
|
||||
|
||||
if(roundedScale != prevRoundedScale)
|
||||
{
|
||||
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
prevRoundedScale = roundedScale;
|
||||
}
|
||||
|
||||
if(isActive)
|
||||
{
|
||||
ITankContainer[] connectedAcceptors = PipeUtils.getConnectedAcceptors(this);
|
||||
|
||||
|
@ -60,7 +100,7 @@ public class TileEntityMechanicalPipe extends TileEntity implements IMechanicalP
|
|||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return isActive;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,6 +20,10 @@ public class TileEntityUniversalCable extends TileEntity implements IUniversalCa
|
|||
{
|
||||
public CablePowerProvider powerProvider;
|
||||
|
||||
public float liquidScale;
|
||||
|
||||
public float prevRoundedScale;
|
||||
|
||||
public TileEntityUniversalCable()
|
||||
{
|
||||
if(PowerFramework.currentFramework != null)
|
||||
|
@ -29,16 +33,43 @@ public class TileEntityUniversalCable extends TileEntity implements IUniversalCa
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(liquidScale > 0)
|
||||
{
|
||||
liquidScale -= .01;
|
||||
}
|
||||
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
float roundedScale = liquidScale*16F;
|
||||
|
||||
if(roundedScale != prevRoundedScale)
|
||||
{
|
||||
worldObj.updateAllLightTypes(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
prevRoundedScale = roundedScale;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTransferEnergy(TileEntity fromTile)
|
||||
{
|
||||
return worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransfer()
|
||||
{
|
||||
liquidScale = Math.min(1, liquidScale+.02F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate()
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -33,7 +33,7 @@ public class GuiHeatGenerator extends GuiContainer
|
|||
fontRenderer.drawString(tileEntity.fullName, 45, 6, 0x404040);
|
||||
fontRenderer.drawString("Inventory", 8, (ySize - 96) + 2, 0x404040);
|
||||
fontRenderer.drawString(ElectricityDisplay.getDisplayShort(tileEntity.electricityStored, ElectricUnit.JOULES), 51, 26, 0x00CD00);
|
||||
fontRenderer.drawString("Fuel: " + tileEntity.fuelSlot.liquidStored, 51, 35, 0x00CD00);
|
||||
fontRenderer.drawString("Fuel: " + (tileEntity.lavaTank.getLiquid() != null ? tileEntity.lavaTank.getLiquid().amount : 0), 51, 35, 0x00CD00);
|
||||
fontRenderer.drawString(tileEntity.getVoltage() + "v", 51, 44, 0x00CD00);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import mekanism.common.ISustainedTank;
|
|||
import mekanism.common.LiquidSlot;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismUtils;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.RecipeHandler;
|
||||
import mekanism.common.TileEntityElectricBlock;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -64,6 +65,12 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
|
||||
/** Type type of gas this block is dumping. */
|
||||
public EnumGas dumpType;
|
||||
|
||||
/** Previous tank full state. */
|
||||
public boolean prevTankFull;
|
||||
|
||||
/** Previous tank empty state. */
|
||||
public boolean prevTankEmpty;
|
||||
|
||||
public TileEntityElectrolyticSeparator()
|
||||
{
|
||||
|
@ -205,6 +212,17 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
setGas(dumpType, (getGas(dumpType) - 8));
|
||||
spawnParticle();
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(prevTankFull != (waterTank.getLiquid() != null && waterTank.getLiquid().amount == waterTank.getCapacity()) || prevTankEmpty != (waterTank.getLiquid() == null || waterTank.getLiquid().amount == 0))
|
||||
{
|
||||
PacketHandler.sendTileEntityPacketToClients(this, 50, getNetworkedData(new ArrayList()));
|
||||
}
|
||||
|
||||
prevTankFull = waterTank.getLiquid() != null && waterTank.getLiquid().amount == waterTank.getCapacity();
|
||||
prevTankEmpty = waterTank.getLiquid() == null;
|
||||
}
|
||||
}
|
||||
|
||||
public void spawnParticle()
|
||||
|
|
|
@ -84,17 +84,19 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
|
|||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(facing));
|
||||
|
||||
if(electricityStored > 0)
|
||||
{
|
||||
TileEntity tileEntity = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), ForgeDirection.getOrientation(facing));
|
||||
|
||||
if(electricityStored > 0)
|
||||
if(tileEntity instanceof IUniversalCable)
|
||||
{
|
||||
if(tileEntity instanceof IUniversalCable)
|
||||
{
|
||||
setJoules(electricityStored - (Math.min(electricityStored, output) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, output), this, ForgeDirection.getOrientation(facing))));
|
||||
}
|
||||
else if((tileEntity instanceof IEnergyConductor || tileEntity instanceof IEnergyAcceptor) && Mekanism.hooks.IC2Loaded)
|
||||
setJoules(electricityStored - (Math.min(electricityStored, output) - CableUtils.emitEnergyToNetwork(Math.min(electricityStored, output), this, ForgeDirection.getOrientation(facing))));
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if((tileEntity instanceof IEnergyConductor || tileEntity instanceof IEnergyAcceptor) && Mekanism.hooks.IC2Loaded)
|
||||
{
|
||||
if(electricityStored >= output)
|
||||
{
|
||||
|
@ -112,26 +114,26 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem
|
|||
setJoules(electricityStored - transferEnergy);
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity instanceof IConductor)
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && tileEntity instanceof IConductor)
|
||||
{
|
||||
ForgeDirection outputDirection = ForgeDirection.getOrientation(facing);
|
||||
TileEntity outputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), outputDirection);
|
||||
|
||||
IElectricityNetwork outputNetwork = ElectricityNetworkHelper.getNetworkFromTileEntity(outputTile, outputDirection);
|
||||
|
||||
if(outputNetwork != null)
|
||||
{
|
||||
ForgeDirection outputDirection = ForgeDirection.getOrientation(facing);
|
||||
TileEntity outputTile = VectorHelper.getTileEntityFromSide(worldObj, new Vector3(this), outputDirection);
|
||||
double outputWatts = Math.min(outputNetwork.getRequest().getWatts(), Math.min(getJoules(), 10000));
|
||||
|
||||
IElectricityNetwork outputNetwork = ElectricityNetworkHelper.getNetworkFromTileEntity(outputTile, outputDirection);
|
||||
|
||||
if(outputNetwork != null)
|
||||
if(getJoules() > 0 && outputWatts > 0 && getJoules()-outputWatts >= 0)
|
||||
{
|
||||
double outputWatts = Math.min(outputNetwork.getRequest().getWatts(), Math.min(getJoules(), 10000));
|
||||
|
||||
if(getJoules() > 0 && outputWatts > 0 && getJoules()-outputWatts >= 0)
|
||||
{
|
||||
outputNetwork.startProducing(this, outputWatts / getVoltage(), getVoltage());
|
||||
setJoules(electricityStored - outputWatts);
|
||||
}
|
||||
else {
|
||||
outputNetwork.stopProducing(this);
|
||||
}
|
||||
outputNetwork.startProducing(this, outputWatts / getVoltage(), getVoltage());
|
||||
setJoules(electricityStored - outputWatts);
|
||||
}
|
||||
else {
|
||||
outputNetwork.stopProducing(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import mekanism.common.ChargeUtils;
|
|||
import mekanism.common.LiquidSlot;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismUtils;
|
||||
import mekanism.common.PacketHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -31,26 +32,21 @@ import dan200.computer.api.IComputerAccess;
|
|||
public class TileEntityHeatGenerator extends TileEntityGenerator implements ITankContainer
|
||||
{
|
||||
/** The LiquidSlot fuel instance for this generator. */
|
||||
public LiquidSlot fuelSlot = new LiquidSlot(24000, Mekanism.hooks.BuildCraftFuelID);
|
||||
public LiquidTank lavaTank = new LiquidTank(24000);
|
||||
|
||||
/** The amount of electricity this machine can produce with a unit of fuel. */
|
||||
public final int GENERATION = 80;
|
||||
|
||||
/** All the liquid fuels this generator runs on. */
|
||||
public static Map<Integer, Integer> fuels = new HashMap<Integer, Integer>();
|
||||
/** Previous tank full state. */
|
||||
public boolean prevTankFull;
|
||||
|
||||
/** Previous tank empty state. */
|
||||
public boolean prevTankEmpty;
|
||||
|
||||
public TileEntityHeatGenerator()
|
||||
{
|
||||
super("Heat Generator", 160000, 160);
|
||||
inventory = new ItemStack[2];
|
||||
|
||||
fuels.put(Block.lavaStill.blockID, 1);
|
||||
|
||||
if(Mekanism.hooks.BuildCraftLoaded)
|
||||
{
|
||||
fuels.put(Mekanism.hooks.BuildCraftFuelID, 16);
|
||||
fuels.put(Mekanism.hooks.BuildCraftOilID, 4);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,45 +60,35 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
{
|
||||
LiquidStack liquid = LiquidContainerRegistry.getLiquidForFilledItem(inventory[0]);
|
||||
|
||||
if(liquid != null)
|
||||
if(liquid != null && liquid.itemID == Block.lavaStill.blockID)
|
||||
{
|
||||
if(fuels.containsKey(liquid.itemID))
|
||||
if(lavaTank.getLiquid() == null || lavaTank.getLiquid().amount+liquid.amount <= lavaTank.getCapacity())
|
||||
{
|
||||
int liquidToAdd = liquid.amount*fuels.get(liquid.itemID);
|
||||
lavaTank.fill(liquid, true);
|
||||
|
||||
if(fuelSlot.liquidStored+liquidToAdd <= fuelSlot.MAX_LIQUID)
|
||||
if(inventory[0].isItemEqual(new ItemStack(Item.bucketLava)))
|
||||
{
|
||||
fuelSlot.setLiquid(fuelSlot.liquidStored+liquidToAdd);
|
||||
if(LiquidContainerRegistry.isBucket(inventory[0]))
|
||||
inventory[0] = new ItemStack(Item.bucketEmpty);
|
||||
}
|
||||
else {
|
||||
inventory[0].stackSize--;
|
||||
|
||||
if(inventory[0].stackSize == 0)
|
||||
{
|
||||
inventory[0] = new ItemStack(Item.bucketEmpty);
|
||||
}
|
||||
else {
|
||||
inventory[0].stackSize--;
|
||||
|
||||
if(inventory[0].stackSize == 0)
|
||||
{
|
||||
inventory[0] = null;
|
||||
}
|
||||
inventory[0] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int fuel = getFuel(inventory[0]);
|
||||
ItemStack prevStack = inventory[0].copy();
|
||||
if(fuel > 0)
|
||||
{
|
||||
int fuelNeeded = fuelSlot.MAX_LIQUID - fuelSlot.liquidStored;
|
||||
int fuelNeeded = lavaTank.getCapacity() - (lavaTank.getLiquid() != null ? lavaTank.getLiquid().amount : 0);
|
||||
if(fuel <= fuelNeeded)
|
||||
{
|
||||
fuelSlot.liquidStored += fuel;
|
||||
lavaTank.fill(new LiquidStack(Block.lavaStill.blockID, fuel), true);
|
||||
inventory[0].stackSize--;
|
||||
|
||||
if(prevStack.isItemEqual(new ItemStack(Item.bucketLava)))
|
||||
{
|
||||
inventory[0] = new ItemStack(Item.bucketEmpty);
|
||||
}
|
||||
}
|
||||
|
||||
if(inventory[0].stackSize == 0)
|
||||
|
@ -121,7 +107,8 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
{
|
||||
setActive(true);
|
||||
}
|
||||
fuelSlot.setLiquid(fuelSlot.liquidStored - 10);
|
||||
|
||||
lavaTank.drain(10, true);
|
||||
setJoules(electricityStored + GENERATION);
|
||||
}
|
||||
else {
|
||||
|
@ -130,6 +117,17 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(prevTankFull != (lavaTank.getLiquid() != null && lavaTank.getLiquid().amount == lavaTank.getCapacity()) || prevTankEmpty != (lavaTank.getLiquid() == null || lavaTank.getLiquid().amount == 0))
|
||||
{
|
||||
PacketHandler.sendTileEntityPacketToClients(this, 50, getNetworkedData(new ArrayList()));
|
||||
}
|
||||
|
||||
prevTankFull = lavaTank.getLiquid() != null && lavaTank.getLiquid().amount == lavaTank.getCapacity();
|
||||
prevTankEmpty = lavaTank.getLiquid() == null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,7 +135,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
{
|
||||
if(slotID == 0)
|
||||
{
|
||||
return getFuel(itemstack) > 0 || (LiquidContainerRegistry.getLiquidForFilledItem(itemstack) != null && fuels.containsKey(LiquidContainerRegistry.getLiquidForFilledItem(itemstack).itemID));
|
||||
return getFuel(itemstack) > 0 || (LiquidContainerRegistry.getLiquidForFilledItem(itemstack) != null && LiquidContainerRegistry.getLiquidForFilledItem(itemstack).itemID == Block.lavaStill.blockID);
|
||||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
|
@ -151,7 +149,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
@Override
|
||||
public boolean canOperate()
|
||||
{
|
||||
return electricityStored < MAX_ELECTRICITY && fuelSlot.liquidStored > 0;
|
||||
return electricityStored < MAX_ELECTRICITY && lavaTank.getLiquid() != null && lavaTank.getLiquid().amount >= 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,7 +157,10 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
{
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
fuelSlot.liquidStored = nbtTags.getInteger("fuelStored");
|
||||
if(nbtTags.hasKey("lavaTank"))
|
||||
{
|
||||
lavaTank.readFromNBT(nbtTags.getCompoundTag("lavaTank"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -167,7 +168,10 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
{
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("fuelStored", fuelSlot.liquidStored);
|
||||
if(lavaTank.getLiquid() != null)
|
||||
{
|
||||
nbtTags.setTag("lavaTank", lavaTank.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -248,21 +252,34 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
*/
|
||||
public int getScaledFuelLevel(int i)
|
||||
{
|
||||
return fuelSlot.liquidStored*i / fuelSlot.MAX_LIQUID;
|
||||
return (lavaTank.getLiquid() != null ? lavaTank.getLiquid().amount : 0)*i / lavaTank.getCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
fuelSlot.liquidStored = dataStream.readInt();
|
||||
|
||||
int amount = dataStream.readInt();
|
||||
if(amount != 0)
|
||||
{
|
||||
lavaTank.setLiquid(new LiquidStack(Block.lavaStill.blockID, amount, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
data.add(fuelSlot.liquidStored);
|
||||
|
||||
if(lavaTank.getLiquid() != null)
|
||||
{
|
||||
data.add(lavaTank.getLiquid().amount);
|
||||
}
|
||||
else {
|
||||
data.add(0);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -286,9 +303,9 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
case 3:
|
||||
return new Object[] {(MAX_ELECTRICITY-electricityStored)};
|
||||
case 4:
|
||||
return new Object[] {fuelSlot.liquidStored};
|
||||
return new Object[] {lavaTank.getLiquid() != null ? lavaTank.getLiquid().amount : 0};
|
||||
case 5:
|
||||
return new Object[] {fuelSlot.MAX_LIQUID-fuelSlot.liquidStored};
|
||||
return new Object[] {lavaTank.getCapacity()-(lavaTank.getLiquid() != null ? lavaTank.getLiquid().amount : 0)};
|
||||
default:
|
||||
System.err.println("[Mekanism] Attempted to call unknown method with computer ID " + computer.getID());
|
||||
return null;
|
||||
|
@ -298,26 +315,9 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
@Override
|
||||
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if(fuels.containsKey(resource.itemID) && from != ForgeDirection.getOrientation(facing))
|
||||
if(from != ForgeDirection.getOrientation(facing))
|
||||
{
|
||||
int fuelTransfer = 0;
|
||||
int fuelNeeded = fuelSlot.MAX_LIQUID - fuelSlot.liquidStored;
|
||||
int attemptTransfer = resource.amount*fuels.get(resource.itemID);
|
||||
|
||||
if(attemptTransfer <= fuelNeeded)
|
||||
{
|
||||
fuelTransfer = attemptTransfer;
|
||||
}
|
||||
else {
|
||||
fuelTransfer = fuelNeeded;
|
||||
}
|
||||
|
||||
if(doFill)
|
||||
{
|
||||
fuelSlot.setLiquid(fuelSlot.liquidStored + fuelTransfer);
|
||||
}
|
||||
|
||||
return fuelTransfer/fuels.get(resource.itemID);
|
||||
return fill(0, resource, doFill);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -326,6 +326,11 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
@Override
|
||||
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
|
||||
{
|
||||
if(resource.itemID == Block.lavaStill.blockID && tankIndex == 0)
|
||||
{
|
||||
return lavaTank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -344,12 +349,12 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan
|
|||
@Override
|
||||
public ILiquidTank[] getTanks(ForgeDirection direction)
|
||||
{
|
||||
return new ILiquidTank[] {new LiquidTank(fuelSlot.liquidID, fuelSlot.liquidStored, fuelSlot.MAX_LIQUID)};
|
||||
return new ILiquidTank[] {lavaTank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
|
||||
{
|
||||
return null;
|
||||
return lavaTank;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public class NEIMekanismConfig implements IConfigureNEI
|
|||
API.setGuiOffset(GuiMetallurgicInfuser.class, 5, 15);
|
||||
|
||||
API.hideItem(Mekanism.boundingBlockID);
|
||||
API.hideItem(Mekanism.LiquidEnergy.itemID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|