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:
Aidan C. Brady 2014-01-16 22:49:48 -05:00
parent 0f06146292
commit af1ab186d9
4 changed files with 104 additions and 50 deletions

View file

@ -45,7 +45,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer
bindTexture(MekanismRenderer.getBlocksTexture());
if(data.height >= 2)
if(data.height >= 2 && tileEntity.waterTank.getCapacity() > 0)
{
Coord4D renderLoc = tileEntity.getRenderLocation();
@ -56,9 +56,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer
MekanismRenderer.glowOn(tileEntity.waterTank.getFluid().getFluid().getLuminosity());
DisplayInteger[] displayList = getListAndRender(data, tileEntity.waterTank.getFluid().getFluid());
GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.waterTank.getFluidAmount() / (float)tileEntity.getMaxWater())+0.3F));
displayList[getStages(data.height)-1].render();
displayList[(int)(((float)tileEntity.waterTank.getFluidAmount()/tileEntity.waterTank.getCapacity())*((float)getStages(data.height)-1))].render();
MekanismRenderer.glowOff();
@ -119,23 +117,44 @@ public class RenderSalinationController extends TileEntitySpecialRenderer
switch(data.side)
{
case NORTH:
/*toReturn.minX = 0 + .01;
toReturn.minX = 0 + .01;
toReturn.minY = 0 + .01;
toReturn.minZ = 0 + .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;
MekanismRenderer.renderObject(toReturn);*/
break;
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;
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;
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;
}
MekanismRenderer.renderObject(toReturn);
}
displays[i].endList();
@ -148,7 +167,7 @@ public class RenderSalinationController extends TileEntitySpecialRenderer
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)

View file

@ -211,6 +211,7 @@ public class Mekanism
//Block IDs
public static int basicBlockID;
public static int basicBlock2ID;
public static int machineBlockID;
public static int machineBlock2ID;
public static int oreBlockID;
@ -253,6 +254,7 @@ public class Mekanism
//Blocks
public static Block BasicBlock;
public static Block BasicBlock2;
public static Block MachineBlock;
public static Block MachineBlock2;
public static Block OreBlock;
@ -792,6 +794,7 @@ public class Mekanism
{
//Declarations
BasicBlock = new BlockBasic(basicBlockID).setUnlocalizedName("BasicBlock");
BasicBlock2 = new BlockBasic(basicBlock2ID).setUnlocalizedName("BasicBlock2");
MachineBlock = new BlockMachine(machineBlockID).setUnlocalizedName("MachineBlock");
MachineBlock2 = new BlockMachine(machineBlock2ID).setUnlocalizedName("MachineBlock2");
OreBlock = new BlockOre(oreBlockID).setUnlocalizedName("OreBlock");
@ -803,6 +806,7 @@ public class Mekanism
//Registrations
GameRegistry.registerBlock(BasicBlock, ItemBlockBasic.class, "BasicBlock");
GameRegistry.registerBlock(BasicBlock2, ItemBlockBasic.class, "BasicBlock2");
GameRegistry.registerBlock(MachineBlock, ItemBlockMachine.class, "MachineBlock");
GameRegistry.registerBlock(MachineBlock2, ItemBlockMachine.class, "MachineBlock2");
GameRegistry.registerBlock(OreBlock, ItemBlockOre.class, "OreBlock");

View file

@ -317,12 +317,11 @@ public class BlockBasic extends Block
if(metadata == 14)
{
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;
if(!entityplayer.isSneaking())
{
entityplayer.openGui(Mekanism.instance, 33, world, x, y, z);
return true;
}
}
if(world.isRemote)

View file

@ -16,6 +16,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
@ -24,6 +25,9 @@ import net.minecraftforge.fluids.FluidTank;
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 static final int MAX_BRINE = 10000;
@ -57,6 +61,8 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
public boolean cacheStructure = false;
public float prevScale;
public TileEntitySalinationController()
{
super("SalinationController");
@ -104,6 +110,15 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
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()
{
if(!structured || height < 3 || height > 18 || waterTank.getFluid() == null)
if(!structured || height < 3 || height > 18 || waterTank.getFluid() == null || getTempMultiplier() == 0)
{
return false;
}
@ -214,52 +229,55 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
}
}
if(FluidContainerRegistry.isFilledContainer(inventory[0]))
if(structured)
{
FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]);
if((waterTank.getFluid() == null && itemFluid.amount <= 10000) || waterTank.getFluid().amount+itemFluid.amount <= 10000)
if(FluidContainerRegistry.isFilledContainer(inventory[0]))
{
if(itemFluid.getFluid() != FluidRegistry.WATER || (waterTank.getFluid() != null && !waterTank.getFluid().isFluidEqual(itemFluid)))
FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]);
if((waterTank.getFluid() == null && itemFluid.amount <= getMaxWater()) || waterTank.getFluid().amount+itemFluid.amount <= getMaxWater())
{
return;
}
ItemStack containerItem = inventory[0].getItem().getContainerItemStack(inventory[0]);
boolean filled = false;
if(containerItem != null)
{
if(inventory[1] == null || (inventory[1].isItemEqual(containerItem) && inventory[1].stackSize+1 <= containerItem.getMaxStackSize()))
if(itemFluid.getFluid() != FluidRegistry.WATER || (waterTank.getFluid() != null && !waterTank.getFluid().isFluidEqual(itemFluid)))
{
inventory[0] = null;
return;
}
if(inventory[1] == null)
ItemStack containerItem = inventory[0].getItem().getContainerItemStack(inventory[0]);
boolean filled = false;
if(containerItem != null)
{
if(inventory[1] == null || (inventory[1].isItemEqual(containerItem) && inventory[1].stackSize+1 <= containerItem.getMaxStackSize()))
{
inventory[1] = containerItem;
inventory[0] = null;
if(inventory[1] == null)
{
inventory[1] = containerItem;
}
else {
inventory[1].stackSize++;
}
filled = true;
}
else {
inventory[1].stackSize++;
}
else {
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
{
inventory[0] = null;
}
filled = true;
}
}
else {
inventory[0].stackSize--;
if(inventory[0].stackSize == 0)
if(filled)
{
inventory[0] = null;
waterTank.fill(itemFluid, true);
}
filled = true;
}
if(filled)
{
waterTank.fill(itemFluid, true);
}
}
}
@ -272,7 +290,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
if(getTempMultiplier() == 0)
{
temperature = Math.max(0, getTemperature()-(incr*2));
temperature = Math.max(0, getTemperature()-(max/WARMUP));
}
else {
temperature = Math.min(max, getTemperature()+incr);
@ -670,6 +688,7 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
if(structured != prev)
{
waterTank.setCapacity(getMaxWater());
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
@ -744,6 +763,12 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
nbtTags.setBoolean("cacheStructure", structured);
}
@Override
public boolean canSetFacing(int side)
{
return side != 0 && side != 1;
}
public void clearStructure()
{
for(TileEntitySalinationTank tankPart : tankParts)
@ -754,4 +779,11 @@ public class TileEntitySalinationController extends TileEntitySalinationTank imp
tankParts.clear();
solars = new TileEntityAdvancedSolarGenerator[] {null, null, null, null};
}
@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox()
{
return INFINITE_EXTENT_AABB;
}
}