Finish Salination Controller rendering, start work on a separate Salination Controller block.
..this means a lot of extra work to get multiple-id-meta-handling working with BasicBlocks.
This commit is contained in:
parent
0f06146292
commit
af1ab186d9
4 changed files with 104 additions and 50 deletions
|
@ -45,7 +45,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer
|
||||||
|
|
||||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||||
|
|
||||||
if(data.height >= 2)
|
if(data.height >= 2 && tileEntity.waterTank.getCapacity() > 0)
|
||||||
{
|
{
|
||||||
Coord4D renderLoc = tileEntity.getRenderLocation();
|
Coord4D renderLoc = tileEntity.getRenderLocation();
|
||||||
|
|
||||||
|
@ -56,9 +56,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer
|
||||||
MekanismRenderer.glowOn(tileEntity.waterTank.getFluid().getFluid().getLuminosity());
|
MekanismRenderer.glowOn(tileEntity.waterTank.getFluid().getFluid().getLuminosity());
|
||||||
|
|
||||||
DisplayInteger[] displayList = getListAndRender(data, tileEntity.waterTank.getFluid().getFluid());
|
DisplayInteger[] displayList = getListAndRender(data, tileEntity.waterTank.getFluid().getFluid());
|
||||||
|
displayList[(int)(((float)tileEntity.waterTank.getFluidAmount()/tileEntity.waterTank.getCapacity())*((float)getStages(data.height)-1))].render();
|
||||||
GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.waterTank.getFluidAmount() / (float)tileEntity.getMaxWater())+0.3F));
|
|
||||||
displayList[getStages(data.height)-1].render();
|
|
||||||
|
|
||||||
MekanismRenderer.glowOff();
|
MekanismRenderer.glowOff();
|
||||||
|
|
||||||
|
@ -119,23 +117,44 @@ public class RenderSalinationController extends TileEntitySpecialRenderer
|
||||||
switch(data.side)
|
switch(data.side)
|
||||||
{
|
{
|
||||||
case NORTH:
|
case NORTH:
|
||||||
/*toReturn.minX = 0 + .01;
|
toReturn.minX = 0 + .01;
|
||||||
toReturn.minY = 0 + .01;
|
toReturn.minY = 0 + .01;
|
||||||
toReturn.minZ = 0 + .01;
|
toReturn.minZ = 0 + .01;
|
||||||
|
|
||||||
toReturn.maxX = 2 - .01;
|
toReturn.maxX = 2 - .01;
|
||||||
toReturn.maxY = ((float)i/(float)stages)*(data.height-2) - .01;
|
toReturn.maxY = ((float)i/(float)stages)*data.height - .01;
|
||||||
toReturn.maxZ = 2 - .01;
|
toReturn.maxZ = 2 - .01;
|
||||||
|
|
||||||
MekanismRenderer.renderObject(toReturn);*/
|
|
||||||
break;
|
break;
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
|
toReturn.minX = -1 + .01;
|
||||||
|
toReturn.minY = 0 + .01;
|
||||||
|
toReturn.minZ = -1 + .01;
|
||||||
|
|
||||||
|
toReturn.maxX = 1 - .01;
|
||||||
|
toReturn.maxY = ((float)i/(float)stages)*data.height - .01;
|
||||||
|
toReturn.maxZ = 1 - .01;
|
||||||
break;
|
break;
|
||||||
case WEST:
|
case WEST:
|
||||||
|
toReturn.minX = 0 + .01;
|
||||||
|
toReturn.minY = 0 + .01;
|
||||||
|
toReturn.minZ = -1 + .01;
|
||||||
|
|
||||||
|
toReturn.maxX = 2 - .01;
|
||||||
|
toReturn.maxY = ((float)i/(float)stages)*data.height - .01;
|
||||||
|
toReturn.maxZ = 1 - .01;
|
||||||
break;
|
break;
|
||||||
case EAST:
|
case EAST:
|
||||||
|
toReturn.minX = -1 + .01;
|
||||||
|
toReturn.minY = 0 + .01;
|
||||||
|
toReturn.minZ = 0 + .01;
|
||||||
|
|
||||||
|
toReturn.maxX = 1 - .01;
|
||||||
|
toReturn.maxY = ((float)i/(float)stages)*data.height - .01;
|
||||||
|
toReturn.maxZ = 2 - .01;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MekanismRenderer.renderObject(toReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
displays[i].endList();
|
displays[i].endList();
|
||||||
|
@ -148,7 +167,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer
|
||||||
|
|
||||||
private int getStages(int height)
|
private int getStages(int height)
|
||||||
{
|
{
|
||||||
return (height-2)*(TankUpdateProtocol.FLUID_PER_TANK/10);
|
return height*(TankUpdateProtocol.FLUID_PER_TANK/10);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getX(int x)
|
private double getX(int x)
|
||||||
|
|
|
@ -211,6 +211,7 @@ public class Mekanism
|
||||||
|
|
||||||
//Block IDs
|
//Block IDs
|
||||||
public static int basicBlockID;
|
public static int basicBlockID;
|
||||||
|
public static int basicBlock2ID;
|
||||||
public static int machineBlockID;
|
public static int machineBlockID;
|
||||||
public static int machineBlock2ID;
|
public static int machineBlock2ID;
|
||||||
public static int oreBlockID;
|
public static int oreBlockID;
|
||||||
|
@ -253,6 +254,7 @@ public class Mekanism
|
||||||
|
|
||||||
//Blocks
|
//Blocks
|
||||||
public static Block BasicBlock;
|
public static Block BasicBlock;
|
||||||
|
public static Block BasicBlock2;
|
||||||
public static Block MachineBlock;
|
public static Block MachineBlock;
|
||||||
public static Block MachineBlock2;
|
public static Block MachineBlock2;
|
||||||
public static Block OreBlock;
|
public static Block OreBlock;
|
||||||
|
@ -792,6 +794,7 @@ public class Mekanism
|
||||||
{
|
{
|
||||||
//Declarations
|
//Declarations
|
||||||
BasicBlock = new BlockBasic(basicBlockID).setUnlocalizedName("BasicBlock");
|
BasicBlock = new BlockBasic(basicBlockID).setUnlocalizedName("BasicBlock");
|
||||||
|
BasicBlock2 = new BlockBasic(basicBlock2ID).setUnlocalizedName("BasicBlock2");
|
||||||
MachineBlock = new BlockMachine(machineBlockID).setUnlocalizedName("MachineBlock");
|
MachineBlock = new BlockMachine(machineBlockID).setUnlocalizedName("MachineBlock");
|
||||||
MachineBlock2 = new BlockMachine(machineBlock2ID).setUnlocalizedName("MachineBlock2");
|
MachineBlock2 = new BlockMachine(machineBlock2ID).setUnlocalizedName("MachineBlock2");
|
||||||
OreBlock = new BlockOre(oreBlockID).setUnlocalizedName("OreBlock");
|
OreBlock = new BlockOre(oreBlockID).setUnlocalizedName("OreBlock");
|
||||||
|
@ -803,6 +806,7 @@ public class Mekanism
|
||||||
|
|
||||||
//Registrations
|
//Registrations
|
||||||
GameRegistry.registerBlock(BasicBlock, ItemBlockBasic.class, "BasicBlock");
|
GameRegistry.registerBlock(BasicBlock, ItemBlockBasic.class, "BasicBlock");
|
||||||
|
GameRegistry.registerBlock(BasicBlock2, ItemBlockBasic.class, "BasicBlock2");
|
||||||
GameRegistry.registerBlock(MachineBlock, ItemBlockMachine.class, "MachineBlock");
|
GameRegistry.registerBlock(MachineBlock, ItemBlockMachine.class, "MachineBlock");
|
||||||
GameRegistry.registerBlock(MachineBlock2, ItemBlockMachine.class, "MachineBlock2");
|
GameRegistry.registerBlock(MachineBlock2, ItemBlockMachine.class, "MachineBlock2");
|
||||||
GameRegistry.registerBlock(OreBlock, ItemBlockOre.class, "OreBlock");
|
GameRegistry.registerBlock(OreBlock, ItemBlockOre.class, "OreBlock");
|
||||||
|
|
|
@ -316,14 +316,13 @@ public class BlockBasic extends Block
|
||||||
}
|
}
|
||||||
|
|
||||||
if(metadata == 14)
|
if(metadata == 14)
|
||||||
|
{
|
||||||
|
if(!entityplayer.isSneaking())
|
||||||
{
|
{
|
||||||
entityplayer.openGui(Mekanism.instance, 33, world, x, y, z);
|
entityplayer.openGui(Mekanism.instance, 33, world, x, y, z);
|
||||||
TileEntitySalinationController controller = (TileEntitySalinationController)new Coord4D(x, y, z).getTileEntity(world);
|
|
||||||
//entityplayer.sendChatToPlayer(ChatMessageComponent.createFromText("Water Level: " + controller.waterTank.getFluidAmount()));
|
|
||||||
//entityplayer.sendChatToPlayer(ChatMessageComponent.createFromText("Brine Level: " + controller.brineTank.getFluidAmount()));
|
|
||||||
//entityplayer.sendChatToPlayer(ChatMessageComponent.createFromText("Can operate: " + controller.canOperate()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(world.isRemote)
|
if(world.isRemote)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
import net.minecraftforge.fluids.FluidRegistry;
|
||||||
|
@ -24,6 +25,9 @@ import net.minecraftforge.fluids.FluidTank;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class TileEntitySalinationController extends TileEntitySalinationTank implements IConfigurable
|
public class TileEntitySalinationController extends TileEntitySalinationTank implements IConfigurable
|
||||||
{
|
{
|
||||||
public static final int MAX_BRINE = 10000;
|
public static final int MAX_BRINE = 10000;
|
||||||
|
@ -57,6 +61,8 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
||||||
|
|
||||||
public boolean cacheStructure = false;
|
public boolean cacheStructure = false;
|
||||||
|
|
||||||
|
public float prevScale;
|
||||||
|
|
||||||
public TileEntitySalinationController()
|
public TileEntitySalinationController()
|
||||||
{
|
{
|
||||||
super("SalinationController");
|
super("SalinationController");
|
||||||
|
@ -104,6 +110,15 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
||||||
partialBrine %= 1;
|
partialBrine %= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(structured)
|
||||||
|
{
|
||||||
|
if(Math.abs((float)waterTank.getFluidAmount()/waterTank.getCapacity()-prevScale) > 0.01)
|
||||||
|
{
|
||||||
|
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this), 50D);
|
||||||
|
prevScale = (float)waterTank.getFluidAmount()/waterTank.getCapacity();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +171,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
||||||
|
|
||||||
public boolean canOperate()
|
public boolean canOperate()
|
||||||
{
|
{
|
||||||
if(!structured || height < 3 || height > 18 || waterTank.getFluid() == null)
|
if(!structured || height < 3 || height > 18 || waterTank.getFluid() == null || getTempMultiplier() == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -214,11 +229,13 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(structured)
|
||||||
|
{
|
||||||
if(FluidContainerRegistry.isFilledContainer(inventory[0]))
|
if(FluidContainerRegistry.isFilledContainer(inventory[0]))
|
||||||
{
|
{
|
||||||
FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]);
|
FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]);
|
||||||
|
|
||||||
if((waterTank.getFluid() == null && itemFluid.amount <= 10000) || waterTank.getFluid().amount+itemFluid.amount <= 10000)
|
if((waterTank.getFluid() == null && itemFluid.amount <= getMaxWater()) || waterTank.getFluid().amount+itemFluid.amount <= getMaxWater())
|
||||||
{
|
{
|
||||||
if(itemFluid.getFluid() != FluidRegistry.WATER || (waterTank.getFluid() != null && !waterTank.getFluid().isFluidEqual(itemFluid)))
|
if(itemFluid.getFluid() != FluidRegistry.WATER || (waterTank.getFluid() != null && !waterTank.getFluid().isFluidEqual(itemFluid)))
|
||||||
{
|
{
|
||||||
|
@ -264,6 +281,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateTemperature()
|
private void updateTemperature()
|
||||||
{
|
{
|
||||||
|
@ -272,7 +290,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
||||||
|
|
||||||
if(getTempMultiplier() == 0)
|
if(getTempMultiplier() == 0)
|
||||||
{
|
{
|
||||||
temperature = Math.max(0, getTemperature()-(incr*2));
|
temperature = Math.max(0, getTemperature()-(max/WARMUP));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
temperature = Math.min(max, getTemperature()+incr);
|
temperature = Math.min(max, getTemperature()+incr);
|
||||||
|
@ -670,6 +688,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
||||||
|
|
||||||
if(structured != prev)
|
if(structured != prev)
|
||||||
{
|
{
|
||||||
|
waterTank.setCapacity(getMaxWater());
|
||||||
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -744,6 +763,12 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
||||||
nbtTags.setBoolean("cacheStructure", structured);
|
nbtTags.setBoolean("cacheStructure", structured);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canSetFacing(int side)
|
||||||
|
{
|
||||||
|
return side != 0 && side != 1;
|
||||||
|
}
|
||||||
|
|
||||||
public void clearStructure()
|
public void clearStructure()
|
||||||
{
|
{
|
||||||
for(TileEntitySalinationTank tankPart : tankParts)
|
for(TileEntitySalinationTank tankPart : tankParts)
|
||||||
|
@ -754,4 +779,11 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
|
||||||
tankParts.clear();
|
tankParts.clear();
|
||||||
solars = new TileEntityAdvancedSolarGenerator[] {null, null, null, null};
|
solars = new TileEntityAdvancedSolarGenerator[] {null, null, null, null};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public AxisAlignedBB getRenderBoundingBox()
|
||||||
|
{
|
||||||
|
return INFINITE_EXTENT_AABB;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue