mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-10-25 20:32:20 +00:00
Change Fluid Amount Limit (#1029)
This commit is contained in:
1 parent
af6dba1269
commit
1fc824410b
6 files changed
+33
-45
No files matched your search
@@ -2,12 +2,12 @@ package codechicken.nei.item;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -49,7 +49,8 @@ public class FluidDisplayRenderer implements IItemRenderer {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glColor4f(red, green, blue, 1F);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
OpenGlHelper
|
||||
.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
@@ -64,17 +65,17 @@ public class FluidDisplayRenderer implements IItemRenderer {
|
||||
}
|
||||
|
||||
private void renderAmountOverlay(ItemStack item, ItemFluidDisplay fluidDisplay) {
|
||||
final FluidStack fluidStack = fluidDisplay.getFluid(item);
|
||||
if (fluidStack == null || fluidStack.amount <= 0) {
|
||||
final long amount = fluidDisplay.getAmountLong(item);
|
||||
if (amount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
String amountString = "";
|
||||
|
||||
if (fluidStack.amount < 10_000) {
|
||||
amountString = String.valueOf(fluidStack.amount) + "L";
|
||||
if (amount < 10_000) {
|
||||
amountString = String.valueOf(amount) + "L";
|
||||
} else {
|
||||
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(fluidStack.amount) + "L";
|
||||
amountString = ReadableNumberConverter.INSTANCE.toWideReadableForm(amount) + "L";
|
||||
}
|
||||
|
||||
final FontRenderer fontRender = Minecraft.getMinecraft().fontRenderer;
|
||||
|
||||
@@ -49,27 +49,26 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
||||
}
|
||||
|
||||
public static ItemStack createStack(FluidStack fluidStack) {
|
||||
if (fluidStack == null || fluidStack.getFluid() == null) {
|
||||
return fluidStack == null ? null : createStack(fluidStack.getFluid(), fluidStack.amount);
|
||||
}
|
||||
|
||||
public static ItemStack createStack(Fluid fluid, long amount) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int fluidId;
|
||||
|
||||
try {
|
||||
fluidId = FluidRegistry.getFluidID(fluidStack.getFluid());
|
||||
fluidId = FluidRegistry.getFluidID(fluid);
|
||||
} catch (Exception e) {
|
||||
NEIClientConfig.logger.error("Failed to get fluid id for: " + fluidStack.getFluid().getName(), e);
|
||||
NEIClientConfig.logger.error("Failed to get fluid id for: " + fluid.getName(), e);
|
||||
return null;
|
||||
}
|
||||
|
||||
final ItemStack stack = new ItemStack(INSTANCE, 1, fluidId);
|
||||
final NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
|
||||
if (fluidStack.tag != null) {
|
||||
nbtTag.setTag("FluidTag", fluidStack.tag.copy());
|
||||
}
|
||||
|
||||
nbtTag.setInteger("neiFluidDisplayAmount", fluidStack.amount);
|
||||
nbtTag.setLong("neiFluidDisplayAmount", amount);
|
||||
stack.setTagCompound(nbtTag);
|
||||
return stack;
|
||||
}
|
||||
@@ -88,23 +87,25 @@ public class ItemFluidDisplay extends Item implements IFluidContainerItem {
|
||||
}
|
||||
|
||||
final NBTTagCompound nbTag = stack.getTagCompound();
|
||||
final FluidStack fluidStack = new FluidStack(fluid, nbTag.getInteger("neiFluidDisplayAmount"));
|
||||
|
||||
if (nbTag.hasKey("FluidTag")) {
|
||||
fluidStack.tag = nbTag.getCompoundTag("FluidTag");
|
||||
}
|
||||
final FluidStack fluidStack = new FluidStack(
|
||||
fluid,
|
||||
(int) Math.min(nbTag.getLong("neiFluidDisplayAmount"), Integer.MAX_VALUE));
|
||||
|
||||
return fluidStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity(ItemStack stack) {
|
||||
public long getAmountLong(ItemStack stack) {
|
||||
|
||||
if (stack == null || !(stack.getItem() instanceof ItemFluidDisplay) || !stack.hasTagCompound()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return stack.getTagCompound().getInteger("neiFluidDisplayAmount");
|
||||
return stack.getTagCompound().getLong("neiFluidDisplayAmount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity(ItemStack stack) {
|
||||
return (int) Math.min(getAmountLong(stack), Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -59,7 +59,7 @@ public class StackInfo {
|
||||
|
||||
if (nbtTag != null) {
|
||||
nbtTag = (NBTTagCompound) nbtTag.copy();
|
||||
nbtTag.setInteger("Count", (int) Math.max(Math.min(customCount, Integer.MAX_VALUE), 0));
|
||||
nbtTag.setLong("Count", Math.max(customCount, 0));
|
||||
return loadFromNBT(nbtTag);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ public class DefaultStackStringifyHandler implements IStackStringifyHandler {
|
||||
final ItemStack stack = ItemStack.loadItemStackFromNBT(nbtTag);
|
||||
|
||||
if (stack != null) {
|
||||
stack.stackSize = nbtTag.getInteger("Count");
|
||||
stack.stackSize = (int) Math.min(nbtTag.getLong("Count"), Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
return stack;
|
||||
|
||||
+3
-12
@@ -31,13 +31,10 @@ public class FluidDisplayStackStringifyHandler implements IStackStringifyHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
final long amount = ((ItemFluidDisplay) stack.getItem()).getAmountLong(stack);
|
||||
final NBTTagCompound nbTag = new NBTTagCompound();
|
||||
nbTag.setString(NBT_FLUID_NAME, fluidStack.getFluid().getName());
|
||||
nbTag.setInteger("Count", saveStackSize ? fluidStack.amount : 1);
|
||||
|
||||
if (fluidStack.tag != null) {
|
||||
nbTag.setTag("FluidTag", fluidStack.tag.copy());
|
||||
}
|
||||
nbTag.setLong("Count", saveStackSize ? amount : 1);
|
||||
|
||||
return nbTag;
|
||||
}
|
||||
@@ -55,13 +52,7 @@ public class FluidDisplayStackStringifyHandler implements IStackStringifyHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
final FluidStack fluidStack = new FluidStack(fluid, nbtTag.getInteger("Count"));
|
||||
|
||||
if (nbtTag.hasKey("FluidTag")) {
|
||||
fluidStack.tag = nbtTag.getCompoundTag("FluidTag");
|
||||
}
|
||||
|
||||
return ItemFluidDisplay.createStack(fluidStack);
|
||||
return ItemFluidDisplay.createStack(fluid, nbtTag.getLong("Count"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,10 +67,9 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
if (nbtTag.hasKey("gtFluidName")) {
|
||||
final String fluidName = nbtTag.getString("gtFluidName");
|
||||
final Fluid fluid = FluidRegistry.getFluid(fluidName);
|
||||
final int amount = nbtTag.getInteger("Count");
|
||||
|
||||
if (fluid != null) {
|
||||
return ItemFluidDisplay.createStack(new FluidStack(fluid, amount));
|
||||
return ItemFluidDisplay.createStack(fluid, nbtTag.getLong("Count"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,11 +97,7 @@ public class GTFluidStackStringifyHandler implements IStackStringifyHandler {
|
||||
Fluid fluid = FluidRegistry.getFluid(nbtTag.getString("Fluid").toLowerCase());
|
||||
|
||||
if (fluid != null) {
|
||||
FluidStack fluidStack = new FluidStack(fluid, stack.stackSize);
|
||||
if (nbtTag.hasKey("FluidTag")) {
|
||||
fluidStack.tag = nbtTag.getCompoundTag("FluidTag");
|
||||
}
|
||||
return fluidStack;
|
||||
return new FluidStack(fluid, stack.stackSize);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
|
||||
Reference in new issue
Block a user