Portable Tanks are polished as far as I can see! Also added a few missing localizations.

This commit is contained in:
Aidan C. Brady 2014-06-19 02:34:49 +02:00
parent d7b0899f38
commit 55937cd7d4
5 changed files with 116 additions and 9 deletions

View file

@ -33,6 +33,7 @@ import mekanism.common.network.PacketPortableTankState.PortableTankStateMessage;
import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage; import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage;
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket; import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage; import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.StackUtils; import mekanism.common.util.StackUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -235,7 +236,7 @@ public class ClientTickHandler
{ {
item.setState(stack, (byte)(item.getState(stack) < 3 ? item.getState(stack)+1 : 0)); item.setState(stack, (byte)(item.getState(stack) < 3 ? item.getState(stack)+1 : 0));
Mekanism.packetHandler.sendToServer(new ConfiguratorStateMessage(item.getState(stack))); Mekanism.packetHandler.sendToServer(new ConfiguratorStateMessage(item.getState(stack)));
mc.thePlayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Configure State: " + item.getColor(item.getState(stack)) + item.getStateDisplay(item.getState(stack)))); mc.thePlayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.configureState") + ": " + item.getColor(item.getState(stack)) + item.getStateDisplay(item.getState(stack))));
lastTickUpdate = true; lastTickUpdate = true;
} }
} }
@ -253,7 +254,7 @@ public class ClientTickHandler
{ {
item.setFireState(stack, !item.getFireState(stack)); item.setFireState(stack, !item.getFireState(stack));
Mekanism.packetHandler.sendToServer(new ElectricBowStateMessage(item.getFireState(stack))); Mekanism.packetHandler.sendToServer(new ElectricBowStateMessage(item.getFireState(stack)));
mc.thePlayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Fire Mode: " + (item.getFireState(stack) ? (EnumColor.DARK_GREEN + "ON") : (EnumColor.DARK_RED + "OFF")))); mc.thePlayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.fireMode") + ": " + (item.getFireState(stack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.transYesNo(item.getFireState(stack))));
lastTickUpdate = true; lastTickUpdate = true;
} }
} }
@ -273,7 +274,7 @@ public class ClientTickHandler
{ {
item.setBucketMode(stack, !item.getBucketMode(stack)); item.setBucketMode(stack, !item.getBucketMode(stack));
Mekanism.packetHandler.sendToServer(new PortableTankStateMessage(item.getBucketMode(stack))); Mekanism.packetHandler.sendToServer(new PortableTankStateMessage(item.getBucketMode(stack)));
mc.thePlayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + "Bucket Mode: " + (item.getBucketMode(stack) ? (EnumColor.DARK_GREEN + "ON") : (EnumColor.DARK_RED + "OFF")))); mc.thePlayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + MekanismUtils.localize("tooltip.portableTank.bucketMode") + ": " + (item.getBucketMode(stack) ? (EnumColor.DARK_GREEN + "ON") : (EnumColor.DARK_RED + "OFF"))));
lastTickUpdate = true; lastTickUpdate = true;
} }
} }

View file

@ -442,7 +442,7 @@ public class ItemRenderingHandler implements IItemRenderer
ItemBlockMachine itemMachine = (ItemBlockMachine)item.getItem(); ItemBlockMachine itemMachine = (ItemBlockMachine)item.getItem();
Fluid fluid = itemMachine.getFluidStack(item) != null ? itemMachine.getFluidStack(item).getFluid() : null; Fluid fluid = itemMachine.getFluidStack(item) != null ? itemMachine.getFluidStack(item).getFluid() : null;
portableTankRenderer.render(fluid, itemMachine.getPrevScale(item), false, -0.5, -0.5, -0.5); portableTankRenderer.render(fluid, itemMachine.getPrevScale(item), false, null, -0.5, -0.5, -0.5);
} }
else { else {
if(item.getItem() instanceof ItemBlockMachine) if(item.getItem() instanceof ItemBlockMachine)

View file

@ -24,6 +24,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class RenderPortableTank extends TileEntitySpecialRenderer public class RenderPortableTank extends TileEntitySpecialRenderer
{ {
private static Map<Fluid, DisplayInteger[]> cachedCenterFluids = new HashMap<Fluid, DisplayInteger[]>(); private static Map<Fluid, DisplayInteger[]> cachedCenterFluids = new HashMap<Fluid, DisplayInteger[]>();
private static Map<Fluid, DisplayInteger[]> cachedValveFluids = new HashMap<Fluid, DisplayInteger[]>();
private static int stages = 1400; private static int stages = 1400;
@ -38,10 +39,10 @@ public class RenderPortableTank extends TileEntitySpecialRenderer
private void renderAModelAt(TileEntityPortableTank tileEntity, double x, double y, double z, float partialTick) private void renderAModelAt(TileEntityPortableTank tileEntity, double x, double y, double z, float partialTick)
{ {
Fluid fluid = tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid() : null; Fluid fluid = tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid() : null;
render(fluid, tileEntity.prevScale, tileEntity.isActive, x, y, z); render(fluid, tileEntity.prevScale, tileEntity.isActive, tileEntity.valve > 0 ? tileEntity.valveFluid : null, x, y, z);
} }
public void render(Fluid fluid, float fluidScale, boolean active, double x, double y, double z) public void render(Fluid fluid, float fluidScale, boolean active, Fluid valveFluid, double x, double y, double z)
{ {
if(fluid != null && fluidScale > 0) if(fluid != null && fluidScale > 0)
{ {
@ -68,6 +69,24 @@ public class RenderPortableTank extends TileEntitySpecialRenderer
pop(); pop();
} }
if(valveFluid != null && !valveFluid.isGaseous())
{
push();
bindTexture(MekanismRenderer.getBlocksTexture());
GL11.glTranslated(x, y, z);
MekanismRenderer.glowOn(valveFluid.getLuminosity());
DisplayInteger[] valveList = getValveRender(valveFluid);
valveList[Math.min(stages-1, (int)(fluidScale*((float)stages-1)))].render();
MekanismRenderer.glowOff();
pop();
}
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F);
bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PortableTank" + (active ? "On" : "") + ".png")); bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PortableTank" + (active ? "On" : "") + ".png"));
@ -93,6 +112,47 @@ public class RenderPortableTank extends TileEntitySpecialRenderer
MekanismRenderer.blendOn(); MekanismRenderer.blendOn();
} }
private DisplayInteger[] getValveRender(Fluid fluid)
{
if(cachedValveFluids.containsKey(fluid))
{
return cachedValveFluids.get(fluid);
}
Model3D toReturn = new Model3D();
toReturn.baseBlock = Blocks.water;
toReturn.setTexture(fluid.getFlowingIcon());
DisplayInteger[] displays = new DisplayInteger[stages];
cachedValveFluids.put(fluid, displays);
MekanismRenderer.colorFluid(fluid);
for(int i = 0; i < stages; i++)
{
displays[i] = DisplayInteger.createAndStart();
if(fluid.getIcon() != null)
{
toReturn.minX = 0.3125 + .01;
toReturn.minY = 0.0625 + ((float)i/(float)stages)*0.875 + .01;
toReturn.minZ = 0.3125 + .01;
toReturn.maxX = 0.6875 - .01;
toReturn.maxY = 0.9375 - .01;
toReturn.maxZ = 0.6875 - .01;
MekanismRenderer.renderObject(toReturn);
}
GL11.glEndList();
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
return displays;
}
private DisplayInteger[] getListAndRender(Fluid fluid) private DisplayInteger[] getListAndRender(Fluid fluid)
{ {
if(cachedCenterFluids.containsKey(fluid)) if(cachedCenterFluids.containsKey(fluid))

View file

@ -21,6 +21,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
@ -40,6 +41,9 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
public int prevAmount; public int prevAmount;
public int valve;
public Fluid valveFluid;
public float prevScale; public float prevScale;
public TileEntityPortableTank() public TileEntityPortableTank()
@ -79,19 +83,32 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
} }
} }
else { else {
boolean needsPacket = false;
if(updateDelay > 0) if(updateDelay > 0)
{ {
updateDelay--; updateDelay--;
if(updateDelay == 0 && clientActive != isActive) if(updateDelay == 0 && clientActive != isActive)
{ {
Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50)); needsPacket = true;
}
}
if(valve > 0)
{
valve--;
if(valve == 0)
{
valveFluid = null;
needsPacket = true;
} }
} }
if(fluidTank.getFluidAmount() != prevAmount) if(fluidTank.getFluidAmount() != prevAmount)
{ {
Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50)); needsPacket = true;
} }
prevAmount = fluidTank.getFluidAmount(); prevAmount = fluidTank.getFluidAmount();
@ -105,6 +122,11 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
{ {
activeEmit(); activeEmit();
} }
if(needsPacket)
{
Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50));
}
} }
} }
@ -282,6 +304,15 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
super.handlePacketData(dataStream); super.handlePacketData(dataStream);
clientActive = dataStream.readBoolean(); clientActive = dataStream.readBoolean();
valve = dataStream.readInt();
if(valve > 0)
{
valveFluid = FluidRegistry.getFluid(dataStream.readInt());
}
else {
valveFluid = null;
}
if(dataStream.readInt() == 1) if(dataStream.readInt() == 1)
{ {
@ -305,6 +336,12 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
super.getNetworkedData(data); super.getNetworkedData(data);
data.add(isActive); data.add(isActive);
data.add(valve);
if(valve > 0)
{
data.add(valveFluid.getID());
}
if(fluidTank.getFluid() != null) if(fluidTank.getFluid() != null)
{ {
@ -370,7 +407,15 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
{ {
if(resource != null && canFill(from, resource.getFluid())) if(resource != null && canFill(from, resource.getFluid()))
{ {
return fluidTank.fill(resource, doFill); int filled = fluidTank.fill(resource, doFill);
if(filled > 0)
{
valve = 20;
valveFluid = resource.getFluid();
}
return filled;
} }
return 0; return 0;

View file

@ -470,6 +470,7 @@ tooltip.tile=Tile
tooltip.keysFound=Key(s) found tooltip.keysFound=Key(s) found
tooltip.noKey=No key tooltip.noKey=No key
tooltip.hp=HP tooltip.hp=HP
tooltip.configureState=Configure State
tooltip.portableTank.bucketMode=Bucket Mode tooltip.portableTank.bucketMode=Bucket Mode