Fixed all stuff with fluid slots
Closes #84 and closes #100 P.S yay closed issue #100!!! <3
This commit is contained in:
parent
50785bb041
commit
9f3ac38c40
13 changed files with 78 additions and 152 deletions
|
@ -123,7 +123,6 @@ public enum GT_Items implements IItemContainer {
|
||||||
Upgrade_Transformer,
|
Upgrade_Transformer,
|
||||||
Upgrade_Battery,
|
Upgrade_Battery,
|
||||||
McGuffium_239,
|
McGuffium_239,
|
||||||
Display_Fluid,
|
|
||||||
NC_SensorCard,
|
NC_SensorCard,
|
||||||
NC_SensorKit,
|
NC_SensorKit,
|
||||||
Tool_Mortar_Iron,
|
Tool_Mortar_Iron,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package gregtechmod.api.gui;
|
package gregtechmod.api.gui;
|
||||||
|
|
||||||
import gregtechmod.api.interfaces.IGregTechTileEntity;
|
import gregtechmod.api.interfaces.IGregTechTileEntity;
|
||||||
import gregtechmod.api.interfaces.IMetaTileEntity;
|
|
||||||
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank;
|
|
||||||
import gregtechmod.api.util.GT_Log;
|
import gregtechmod.api.util.GT_Log;
|
||||||
import gregtechmod.api.util.GT_Utility;
|
import gregtechmod.api.util.GT_Utility;
|
||||||
import gregtechmod.common.network.GT_NetworkHandler;
|
import gregtechmod.common.network.GT_NetworkHandler;
|
||||||
|
@ -32,11 +30,15 @@ public class GT_Container extends Container {
|
||||||
public IGregTechTileEntity mTileEntity;
|
public IGregTechTileEntity mTileEntity;
|
||||||
public InventoryPlayer mPlayerInventory;
|
public InventoryPlayer mPlayerInventory;
|
||||||
public List<GT_FluidSlot> fluidSlots;
|
public List<GT_FluidSlot> fluidSlots;
|
||||||
|
public List<FluidStack> fluidInventory;
|
||||||
|
|
||||||
|
protected int updateTimer;
|
||||||
|
|
||||||
public GT_Container(InventoryPlayer aPlayerInventory, IGregTechTileEntity aTileEntityInventory) {
|
public GT_Container(InventoryPlayer aPlayerInventory, IGregTechTileEntity aTileEntityInventory) {
|
||||||
mTileEntity = aTileEntityInventory;
|
mTileEntity = aTileEntityInventory;
|
||||||
mPlayerInventory = aPlayerInventory;
|
mPlayerInventory = aPlayerInventory;
|
||||||
fluidSlots = new ArrayList<>();
|
fluidSlots = new ArrayList<>();
|
||||||
|
fluidInventory = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +50,7 @@ public class GT_Container extends Container {
|
||||||
|
|
||||||
public void addFluidSlot(GT_FluidSlot slot) {
|
public void addFluidSlot(GT_FluidSlot slot) {
|
||||||
addSlotToContainer(slot);
|
addSlotToContainer(slot);
|
||||||
|
fluidInventory.add(null);
|
||||||
fluidSlots.add(slot);
|
fluidSlots.add(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +121,10 @@ public class GT_Container extends Container {
|
||||||
aSlot = (Slot) inventorySlots.get(aSlotIndex);
|
aSlot = (Slot) inventorySlots.get(aSlotIndex);
|
||||||
|
|
||||||
if (aSlot == null || aSlot instanceof GT_Slot_Holo) return null;
|
if (aSlot == null || aSlot instanceof GT_Slot_Holo) return null;
|
||||||
if (aSlot instanceof GT_FluidSlot) if(((GT_FluidSlot)aSlot).onClick(aMouseclick, aShifthold, aPlayer)) return null;
|
if (aSlot instanceof GT_FluidSlot) if(((GT_FluidSlot)aSlot).onClick(aMouseclick, aShifthold, aPlayer)) {
|
||||||
|
mTileEntity.decrStackSize(-1, 0); // Some shitcode here, this IS a problem from anywhre already p.s marking inventory dirty to recipe check
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!(aSlot instanceof GT_Slot_Armor)) if (aSlotIndex < getAllSlotCount()) if (aSlotIndex < getSlotStartIndex() || aSlotIndex >= getSlotStartIndex() + getSlotCount()) return null;
|
if (!(aSlot instanceof GT_Slot_Armor)) if (aSlotIndex < getAllSlotCount()) if (aSlotIndex < getSlotStartIndex() || aSlotIndex >= getSlotStartIndex() + getSlotCount()) return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,16 +406,10 @@ public class GT_Container extends Container {
|
||||||
} else {
|
} else {
|
||||||
this.crafters.add(par1ICrafting);
|
this.crafters.add(par1ICrafting);
|
||||||
par1ICrafting.sendContainerAndContentsToPlayer(this, this.getInventory());
|
par1ICrafting.sendContainerAndContentsToPlayer(this, this.getInventory());
|
||||||
IMetaTileEntity mte = mTileEntity.getMetaTileEntity();
|
if (!fluidSlots.isEmpty()) {
|
||||||
if (!fluidSlots.isEmpty() && mte instanceof GT_MetaTileEntity_BasicTank) {
|
|
||||||
GT_MetaTileEntity_BasicTank mte1 = (GT_MetaTileEntity_BasicTank)mte;
|
|
||||||
Map<Integer, GT_FluidSlot> toUpdate = new HashMap<>();
|
Map<Integer, GT_FluidSlot> toUpdate = new HashMap<>();
|
||||||
for (int i = 0; i < fluidSlots.size(); ++i) {
|
for (int i = 0; i < fluidSlots.size(); ++i)
|
||||||
GT_FluidSlot slot = fluidSlots.get(i);
|
toUpdate.put(i, fluidSlots.get(i));
|
||||||
slot.fluid = mte1.mFluid[i] == null ? null : mte1.mFluid[i].copy();
|
|
||||||
toUpdate.put(i, slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
GT_NetworkHandler.sendPacket(new FluidInventoryPacket(toUpdate, this.windowId), (EntityPlayerMP)par1ICrafting);
|
GT_NetworkHandler.sendPacket(new FluidInventoryPacket(toUpdate, this.windowId), (EntityPlayerMP)par1ICrafting);
|
||||||
}
|
}
|
||||||
this.detectAndSendChanges();
|
this.detectAndSendChanges();
|
||||||
|
@ -444,19 +444,16 @@ public class GT_Container extends Container {
|
||||||
try {
|
try {
|
||||||
super.detectAndSendChanges();
|
super.detectAndSendChanges();
|
||||||
|
|
||||||
IMetaTileEntity mte = mTileEntity.getMetaTileEntity();
|
if (!fluidSlots.isEmpty() && ++updateTimer % 2 == 0) { // Added timer to update only 10 times per second
|
||||||
if (!fluidSlots.isEmpty() && mte instanceof GT_MetaTileEntity_BasicTank) {
|
|
||||||
Map<Integer, GT_FluidSlot> toUpdate = new HashMap<>();
|
Map<Integer, GT_FluidSlot> toUpdate = new HashMap<>();
|
||||||
GT_MetaTileEntity_BasicTank tank = (GT_MetaTileEntity_BasicTank) mte;
|
|
||||||
|
|
||||||
for (int i = 0; i < fluidSlots.size(); ++i) {
|
for (int i = 0; i < fluidSlots.size(); ++i) {
|
||||||
GT_FluidSlot slot = fluidSlots.get(i);
|
GT_FluidSlot slot = fluidSlots.get(i);
|
||||||
FluidStack f1 = tank.mFluid[slot.fluidIdx];
|
FluidStack f1 = fluidInventory.get(i);
|
||||||
FluidStack f2 = slot.fluid;
|
FluidStack f2 = slot.getFluid();
|
||||||
|
|
||||||
if (!GT_Utility.areFluidStackSame(f1, f2)) {
|
if (!GT_Utility.areFluidStackSame(f1, f2)) {
|
||||||
f1 = f2 == null ? null : f2.copy();
|
f1 = f2 == null ? null : f2.copy();
|
||||||
tank.mFluid[slot.fluidIdx] = f1;
|
fluidInventory.set(i, f1);
|
||||||
toUpdate.put(i, slot);
|
toUpdate.put(i, slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine {
|
||||||
public void addSlots(InventoryPlayer aInventoryPlayer) {
|
public void addSlots(InventoryPlayer aInventoryPlayer) {
|
||||||
addSlotToContainer(new Slot(mTileEntity, 0, 80, 17));
|
addSlotToContainer(new Slot(mTileEntity, 0, 80, 17));
|
||||||
addSlotToContainer(new GT_Slot_Output(mTileEntity, 1, 80, 53));
|
addSlotToContainer(new GT_Slot_Output(mTileEntity, 1, 80, 53));
|
||||||
addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 59, 42));
|
GT_MetaTileEntity_BasicTank tank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity();
|
||||||
|
addFluidSlot(new GT_FluidSlot(mTileEntity, 2, 59, 42, 0, tank.canTankBeEmptied(), tank.canTankBeFilled()).setRenderAmount(false).setRenderOverlay(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SyncedField<Integer> mContent = new SyncedField<>("mContent", Integer.valueOf(0));
|
public SyncedField<Integer> mContent = new SyncedField<>("mContent", Integer.valueOf(0));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package gregtechmod.api.gui;
|
package gregtechmod.api.gui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
@ -10,7 +11,9 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import gregtechmod.api.GregTech_API;
|
import gregtechmod.api.GregTech_API;
|
||||||
import gregtechmod.api.interfaces.IGregTechTileEntity;
|
import gregtechmod.api.interfaces.IGregTechTileEntity;
|
||||||
|
import gregtechmod.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank;
|
||||||
import gregtechmod.api.util.GT_Utility;
|
import gregtechmod.api.util.GT_Utility;
|
||||||
|
import gregtechmod.api.util.ListAdapter;
|
||||||
import gregtechmod.common.render.GTRenderHelper;
|
import gregtechmod.common.render.GTRenderHelper;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.TextureMap;
|
import net.minecraft.client.renderer.texture.TextureMap;
|
||||||
|
@ -37,9 +40,11 @@ public class GT_FluidSlot extends Slot {
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
protected ResourceLocation customOverlay;
|
protected ResourceLocation customOverlay;
|
||||||
|
protected List<FluidStack> fluidInvenotry;
|
||||||
protected boolean renderOverlay;
|
protected boolean renderOverlay;
|
||||||
protected FluidStack fluid;
|
protected boolean renderAmount;
|
||||||
|
|
||||||
|
/** Index of internal mFluid array */
|
||||||
public final int fluidIdx;
|
public final int fluidIdx;
|
||||||
public final boolean canDrain;
|
public final boolean canDrain;
|
||||||
public final boolean canFill;
|
public final boolean canFill;
|
||||||
|
@ -51,15 +56,17 @@ public class GT_FluidSlot extends Slot {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GT_FluidSlot(IGregTechTileEntity te, int slotIndex, int x, int y, int fluidIdx) {
|
public GT_FluidSlot(IGregTechTileEntity te, int slotIndex, int x, int y, int fluidIdx) {
|
||||||
this(te, slotIndex, x, y, fluidIdx, true, true, true);
|
this(te, slotIndex, x, y, fluidIdx, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GT_FluidSlot(IGregTechTileEntity te, int slotIndex, int x, int y, int fluidIdx, boolean canDrain, boolean canFill, boolean renderOverlay) {
|
public GT_FluidSlot(IGregTechTileEntity te, int slotIndex, int x, int y, int fluidIdx, boolean canDrain, boolean canFill) {
|
||||||
super(te, slotIndex, x, y);
|
super(te, slotIndex, x, y);
|
||||||
this.fluidIdx = fluidIdx;
|
this.fluidIdx = fluidIdx;
|
||||||
this.canDrain = canDrain;
|
this.canDrain = canDrain;
|
||||||
this.canFill = canFill;
|
this.canFill = canFill;
|
||||||
this.renderOverlay = renderOverlay;
|
this.renderOverlay = true;
|
||||||
|
this.renderAmount = true;
|
||||||
|
this.fluidInvenotry = new ListAdapter<>(((GT_MetaTileEntity_BasicTank)te.getMetaTileEntity()).mFluid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -105,6 +112,7 @@ public class GT_FluidSlot extends Slot {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fluid render
|
// Fluid render
|
||||||
|
FluidStack fluid = getFluid();
|
||||||
if (GT_Utility.isFluidStackValid(fluid)) {
|
if (GT_Utility.isFluidStackValid(fluid)) {
|
||||||
IIcon text = fluid.getFluid().getIcon(fluid);
|
IIcon text = fluid.getFluid().getIcon(fluid);
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
|
@ -113,10 +121,12 @@ public class GT_FluidSlot extends Slot {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Amount render
|
// Amount render
|
||||||
|
if (renderAmount) {
|
||||||
int amount = fluid.amount / 1000;
|
int amount = fluid.amount / 1000;
|
||||||
if (amount > 0)
|
if (amount > 0)
|
||||||
GTRenderHelper.drawStackAmount(posX, posY, 0xFFFFFF, Integer.toString(amount));
|
GTRenderHelper.drawStackAmount(posX, posY, 0xFFFFFF, Integer.toString(amount));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isMouseOver)
|
if (isMouseOver)
|
||||||
GTRenderHelper.drawSlotDim(posX, posY, 51, 16, 16);
|
GTRenderHelper.drawSlotDim(posX, posY, 51, 16, 16);
|
||||||
|
@ -138,30 +148,31 @@ public class GT_FluidSlot extends Slot {
|
||||||
|
|
||||||
if (GT_Utility.isStackValid(held)) {
|
if (GT_Utility.isStackValid(held)) {
|
||||||
FluidStack fluid = GT_Utility.getFluidForFilledItem(held);
|
FluidStack fluid = GT_Utility.getFluidForFilledItem(held);
|
||||||
|
FluidStack fluidInv = getFluid();
|
||||||
int amount;
|
int amount;
|
||||||
if (mouseClick == 1 && canDrain && fluid != null) { // Fill (Right click to fill container with liquid)
|
if (mouseClick == 1 && canDrain && fluid != null) { // Fill (Right click to fill container with liquid)
|
||||||
amount = Math.min(getSpace(), fluid.amount);
|
amount = Math.min(getSpace(), fluid.amount);
|
||||||
if (amount > 0) {
|
if (amount > 0) {
|
||||||
if (this.fluid == null) { // Fill empty slot
|
if (!GT_Utility.isFluidStackValid(fluidInv)) { // Fill empty slot
|
||||||
FluidStack actual = fluid.copy();
|
FluidStack actual = fluid.copy();
|
||||||
actual.amount = amount;
|
actual.amount = amount;
|
||||||
|
|
||||||
if (this.useFluidContainer(inv, held, amount)) {
|
if (this.useFluidContainer(inv, held, amount)) {
|
||||||
this.fluid = actual;
|
setFluid(actual);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (this.fluid.isFluidEqual(fluid)) { // Add fluid if same
|
} else if (fluidInv.isFluidEqual(fluid)) { // Add fluid if same
|
||||||
if (this.useFluidContainer(inv, held, amount)) {
|
if (this.useFluidContainer(inv, held, amount)) {
|
||||||
this.fluid.amount += amount;
|
fluidInv.amount += amount;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mouseClick == 0 && canFill && this.fluid != null) { // Epmty (Left click to drain liquid from container)
|
} else if (mouseClick == 0 && canFill && GT_Utility.isFluidStackValid(fluidInv)) { // Epmty (Left click to drain liquid from container)
|
||||||
if ((amount = this.tryFill(inv, held, this.fluid.copy())) > 0) {
|
if ((amount = this.tryFill(inv, held, fluidInv.copy())) > 0) {
|
||||||
this.fluid.amount -= amount;
|
fluidInv.amount -= amount;
|
||||||
if (this.fluid.amount <= 0)
|
if (fluidInv.amount <= 0)
|
||||||
this.fluid = null;
|
setFluid(null);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -243,9 +254,17 @@ public class GT_FluidSlot extends Slot {
|
||||||
* @return free space to fill
|
* @return free space to fill
|
||||||
*/
|
*/
|
||||||
protected int getSpace() {
|
protected int getSpace() {
|
||||||
int availableSpace = this.getSlotStackLimit() * 1000;
|
IGregTechTileEntity te = (IGregTechTileEntity)inventory;
|
||||||
if (this.fluid != null)
|
int availableSpace = 0;
|
||||||
availableSpace -= this.fluid.amount;
|
|
||||||
|
if (te.getMetaTileEntity() instanceof GT_MetaTileEntity_BasicTank) {
|
||||||
|
availableSpace = ((GT_MetaTileEntity_BasicTank)te.getMetaTileEntity()).getCapacity();
|
||||||
|
} else
|
||||||
|
availableSpace = this.getSlotStackLimit() * 1000;
|
||||||
|
|
||||||
|
FluidStack fluid = getFluid();
|
||||||
|
if (GT_Utility.isFluidStackValid(fluid))
|
||||||
|
availableSpace -= fluid.amount;
|
||||||
return availableSpace;
|
return availableSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +277,15 @@ public class GT_FluidSlot extends Slot {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable or enable amount string rendering
|
||||||
|
* Default value set to true
|
||||||
|
*/
|
||||||
|
public GT_FluidSlot setRenderAmount(boolean value) {
|
||||||
|
this.renderAmount = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set render overlay image
|
* Set render overlay image
|
||||||
* @param overlay
|
* @param overlay
|
||||||
|
@ -270,10 +298,10 @@ public class GT_FluidSlot extends Slot {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FluidStack getFluid() {
|
public FluidStack getFluid() {
|
||||||
return fluid;
|
return fluidInvenotry.get(fluidIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFluid(FluidStack fluid) {
|
public void setFluid(FluidStack fluid) {
|
||||||
this.fluid = fluid;
|
fluidInvenotry.set(fluidIdx, fluid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
import net.minecraft.util.EnumChatFormatting;
|
import net.minecraft.util.EnumChatFormatting;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
|
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
|
||||||
|
@ -41,9 +42,10 @@ public class GT_GUIContainer extends GuiContainer {
|
||||||
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
|
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
|
||||||
{
|
{
|
||||||
List<String> tooltipData = Lists.newArrayList();
|
List<String> tooltipData = Lists.newArrayList();
|
||||||
if (slot.fluid != null) {
|
FluidStack fluid = slot.getFluid();
|
||||||
tooltipData.add(slot.fluid.getLocalizedName());
|
if (GT_Utility.isFluidStackValid(fluid)) {
|
||||||
tooltipData.add(EnumChatFormatting.GRAY + I18n.format("metatileentity.fluid.amount", GT_Utility.parseNumberToString(slot.fluid.amount)));
|
tooltipData.add(fluid.getLocalizedName());
|
||||||
|
tooltipData.add(EnumChatFormatting.GRAY + I18n.format("metatileentity.fluid.amount", GT_Utility.parseNumberToString(fluid.amount)));
|
||||||
} else {
|
} else {
|
||||||
tooltipData.add(I18n.format("metatileentity.fluid.empty"));
|
tooltipData.add(I18n.format("metatileentity.fluid.empty"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,6 @@ import net.minecraftforge.fluids.FluidStack;
|
||||||
public abstract class BasicFluidWorkable extends GT_MetaTileEntity_BasicTank implements IRecipeWorkable {
|
public abstract class BasicFluidWorkable extends GT_MetaTileEntity_BasicTank implements IRecipeWorkable {
|
||||||
protected RecipeLogic recipeLogic;
|
protected RecipeLogic recipeLogic;
|
||||||
|
|
||||||
public int MAX_FLUID_STACK = 16_000;
|
|
||||||
|
|
||||||
public BasicFluidWorkable(int aID, String aName, RecipeMap<?> recipeMap) {
|
public BasicFluidWorkable(int aID, String aName, RecipeMap<?> recipeMap) {
|
||||||
super(aID, aName);
|
super(aID, aName);
|
||||||
initRecipeLogic(recipeMap);
|
initRecipeLogic(recipeMap);
|
||||||
|
@ -62,7 +60,7 @@ public abstract class BasicFluidWorkable extends GT_MetaTileEntity_BasicTank imp
|
||||||
|
|
||||||
@Override public int getInputSlot() {return 1;}
|
@Override public int getInputSlot() {return 1;}
|
||||||
@Override public int getOutputSlot() {return 2;}
|
@Override public int getOutputSlot() {return 2;}
|
||||||
@Override public int getStackDisplaySlot() {return 6;}
|
@Override public int getCapacity() {return 16_000;}
|
||||||
|
|
||||||
protected void initRecipeLogic(RecipeMap<?> recipeMap) {
|
protected void initRecipeLogic(RecipeMap<?> recipeMap) {
|
||||||
recipeLogic = new RecipeLogic(recipeMap, this);
|
recipeLogic = new RecipeLogic(recipeMap, this);
|
||||||
|
@ -135,7 +133,7 @@ public abstract class BasicFluidWorkable extends GT_MetaTileEntity_BasicTank imp
|
||||||
for (int i = 0; amount > 0 && i < fluidOutputs.size(); i++) {
|
for (int i = 0; amount > 0 && i < fluidOutputs.size(); i++) {
|
||||||
FluidStack stackInSlot = fluidOutputs.get(i);
|
FluidStack stackInSlot = fluidOutputs.get(i);
|
||||||
if (GT_Utility.isFluidStackValid(stackInSlot) && stackInSlot.isFluidEqual(fluid)) {
|
if (GT_Utility.isFluidStackValid(stackInSlot) && stackInSlot.isFluidEqual(fluid)) {
|
||||||
int tmp = Math.min(MAX_FLUID_STACK, stackInSlot.amount + fluid.amount);
|
int tmp = Math.min(getCapacity(), stackInSlot.amount + fluid.amount);
|
||||||
amount -= tmp - stackInSlot.amount;
|
amount -= tmp - stackInSlot.amount;
|
||||||
} else if (stackInSlot == null) amount = 0;
|
} else if (stackInSlot == null) amount = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,6 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends BasicFluidWorkabl
|
||||||
@Override public boolean canTankBeEmptied() {return getBaseMetaTileEntity().isAllowedToWork();}
|
@Override public boolean canTankBeEmptied() {return getBaseMetaTileEntity().isAllowedToWork();}
|
||||||
@Override public int getInputSlot() {return 0;}
|
@Override public int getInputSlot() {return 0;}
|
||||||
@Override public int getOutputSlot() {return 1;}
|
@Override public int getOutputSlot() {return 1;}
|
||||||
@Override public int getStackDisplaySlot() {return 2;}
|
|
||||||
@Override public List<ItemStack> getInputItems() { return new ListAdapter<>(mInventory, 0, 0); }
|
@Override public List<ItemStack> getInputItems() { return new ListAdapter<>(mInventory, 0, 0); }
|
||||||
@Override public List<ItemStack> getOutputItems() { return new ListAdapter<>(mInventory, 1, 1); }
|
@Override public List<ItemStack> getOutputItems() { return new ListAdapter<>(mInventory, 1, 1); }
|
||||||
@Override public boolean displaysItemStack() {return true;}
|
@Override public boolean displaysItemStack() {return true;}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package gregtechmod.api.metatileentity.implementations;
|
package gregtechmod.api.metatileentity.implementations;
|
||||||
|
|
||||||
import gregtechmod.api.enums.GT_Items;
|
|
||||||
import gregtechmod.api.metatileentity.MetaTileEntity;
|
import gregtechmod.api.metatileentity.MetaTileEntity;
|
||||||
import gregtechmod.api.util.GT_Utility;
|
import gregtechmod.api.util.GT_Utility;
|
||||||
|
|
||||||
|
@ -28,7 +27,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends MetaTileEntity {
|
||||||
|
|
||||||
@Override public boolean isSimpleMachine() {return false;}
|
@Override public boolean isSimpleMachine() {return false;}
|
||||||
@Override public boolean isValidSlot(int aIndex) {return aIndex < 2;}
|
@Override public boolean isValidSlot(int aIndex) {return aIndex < 2;}
|
||||||
@Override public int getInvSize() {return 3;}
|
@Override public int getInvSize() {return 2;}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveNBTData(NBTTagCompound aNBT) {
|
public void saveNBTData(NBTTagCompound aNBT) {
|
||||||
|
@ -59,7 +58,6 @@ public abstract class GT_MetaTileEntity_BasicTank extends MetaTileEntity {
|
||||||
public abstract boolean displaysStackSize();
|
public abstract boolean displaysStackSize();
|
||||||
public int getInputSlot() {return 0;}
|
public int getInputSlot() {return 0;}
|
||||||
public int getOutputSlot() {return 1;}
|
public int getOutputSlot() {return 1;}
|
||||||
public int getStackDisplaySlot() {return 2;}
|
|
||||||
|
|
||||||
public boolean isFluidInputAllowed(FluidStack aFluid) {return true;}
|
public boolean isFluidInputAllowed(FluidStack aFluid) {return true;}
|
||||||
public boolean isFluidChangingAllowed() {return true;}
|
public boolean isFluidChangingAllowed() {return true;}
|
||||||
|
@ -74,19 +72,6 @@ public abstract class GT_MetaTileEntity_BasicTank extends MetaTileEntity {
|
||||||
if (getBaseMetaTileEntity().isServerSide()) {
|
if (getBaseMetaTileEntity().isServerSide()) {
|
||||||
if (isFluidChangingAllowed() && mFluid[0] != null && mFluid[0].amount <= 0) mFluid[0] = null;
|
if (isFluidChangingAllowed() && mFluid[0] != null && mFluid[0].amount <= 0) mFluid[0] = null;
|
||||||
|
|
||||||
if (displaysItemStack()) {
|
|
||||||
if (getDrainableStack() != null) {
|
|
||||||
ItemStack fluidDisplay = GT_Items.Display_Fluid.getWithDamage(displaysStackSize()?Math.max(1, Math.min(getDrainableStack().amount/1000, 64)):1, getDrainableStack().getFluidID());;
|
|
||||||
NBTTagCompound data = new NBTTagCompound();
|
|
||||||
data.setInteger("amount", mFluid[0].amount);
|
|
||||||
fluidDisplay.setTagCompound(data);
|
|
||||||
mInventory[getStackDisplaySlot()] = fluidDisplay;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (GT_Items.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) mInventory[getStackDisplaySlot()] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doesEmptyContainers()) {
|
if (doesEmptyContainers()) {
|
||||||
FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()]);
|
FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()]);
|
||||||
if (tFluid != null && isFluidInputAllowed(tFluid)) {
|
if (tFluid != null && isFluidInputAllowed(tFluid)) {
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
package gregtechmod.common.items;
|
|
||||||
|
|
||||||
import gregtechmod.api.GregTech_API;
|
|
||||||
import gregtechmod.api.items.GT_Generic_Item;
|
|
||||||
import gregtechmod.api.util.GT_Utility;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.IIcon;
|
|
||||||
import net.minecraft.util.StatCollector;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidRegistry;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class GT_FluidDisplayItem extends GT_Generic_Item {
|
|
||||||
public GT_FluidDisplayItem(String aName) {
|
|
||||||
super(aName, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void registerIcons(IIconRegister aIconRegister) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IIcon getIconFromDamage(int aMeta) {
|
|
||||||
Fluid tFluid = FluidRegistry.getFluid(aMeta);
|
|
||||||
if (tFluid != null) {
|
|
||||||
return tFluid.getStillIcon();
|
|
||||||
}
|
|
||||||
return GregTech_API.FAIL_ICON;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSpriteNumber() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnlocalizedName(ItemStack aStack) {
|
|
||||||
if (aStack != null) {
|
|
||||||
Fluid tFluid = FluidRegistry.getFluid(aStack.getItemDamage());
|
|
||||||
if (tFluid != null) {
|
|
||||||
return tFluid.getUnlocalizedName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getItemStackDisplayName(ItemStack aStack) {
|
|
||||||
return StatCollector.translateToLocal(getUnlocalizedName(aStack));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List strs, boolean advMode) {
|
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
|
||||||
if (tag != null && tag.hasKey("amount")) {
|
|
||||||
int amount = tag.getInteger("amount");
|
|
||||||
strs.add(I18n.format("metatileentity.fluid.amount", GT_Utility.parseNumberToString(amount)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
@Override
|
|
||||||
public void getSubItems(Item var1, CreativeTabs aTab, List aList) {}
|
|
||||||
}
|
|
|
@ -21,7 +21,7 @@ public final class GT_PacketHandler implements IMessageHandler<GT_Packet, IMessa
|
||||||
@Override
|
@Override
|
||||||
public IMessage onMessage(GT_Packet message, MessageContext ctx) {
|
public IMessage onMessage(GT_Packet message, MessageContext ctx) {
|
||||||
if (GregTech_API.DEBUG_MODE && GregTech_API.SECONDARY_DEBUG_MODE) {
|
if (GregTech_API.DEBUG_MODE && GregTech_API.SECONDARY_DEBUG_MODE) {
|
||||||
GT_Log.log.info("Processing income packet " + message.getClass().getSimpleName() + " on side " + ctx.side);
|
GT_Log.log.info("Processing " + message.getClass().getSimpleName() + " on side " + ctx.side + " " + message.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
IMessage value = null;
|
IMessage value = null;
|
||||||
|
|
|
@ -39,8 +39,7 @@ public class GT_MetaTileEntity_Centrifuge extends BasicFluidWorkable {
|
||||||
|
|
||||||
@Override public int getInputSlot() {return 1;}
|
@Override public int getInputSlot() {return 1;}
|
||||||
@Override public int getOutputSlot() {return 2;}
|
@Override public int getOutputSlot() {return 2;}
|
||||||
@Override public int getStackDisplaySlot() {return 6;}
|
@Override public int getInvSize() {return 6;}
|
||||||
@Override public int getInvSize() {return 7;}
|
|
||||||
@Override public void onRightclick(EntityPlayer aPlayer) {getBaseMetaTileEntity().openGUI(aPlayer, 146);}
|
@Override public void onRightclick(EntityPlayer aPlayer) {getBaseMetaTileEntity().openGUI(aPlayer, 146);}
|
||||||
@Override public List<ItemStack> getInputItems() {return new ListAdapter<>(mInventory, 0, 1);}
|
@Override public List<ItemStack> getInputItems() {return new ListAdapter<>(mInventory, 0, 1);}
|
||||||
@Override public List<ItemStack> getOutputItems() {return new ListAdapter<>(mInventory, 2, 5);}
|
@Override public List<ItemStack> getOutputItems() {return new ListAdapter<>(mInventory, 2, 5);}
|
||||||
|
|
|
@ -23,10 +23,9 @@ public class GT_MetaTileEntity_Electrolyzer extends BasicFluidWorkable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int maxEUInput() {return 128;}
|
@Override public int maxEUInput() {return 128;}
|
||||||
@Override public int getInvSize() {return 7;}
|
@Override public int getInvSize() {return 6;}
|
||||||
@Override public int getInputSlot() {return 1;}
|
@Override public int getInputSlot() {return 1;}
|
||||||
@Override public int getOutputSlot() {return 2;}
|
@Override public int getOutputSlot() {return 2;}
|
||||||
@Override public int getStackDisplaySlot() {return 6;}
|
|
||||||
@Override public void onRightclick(EntityPlayer aPlayer) {getBaseMetaTileEntity().openGUI(aPlayer, 109);}
|
@Override public void onRightclick(EntityPlayer aPlayer) {getBaseMetaTileEntity().openGUI(aPlayer, 109);}
|
||||||
@Override public List<ItemStack> getInputItems() {return new ListAdapter<>(mInventory, 0, 1);}
|
@Override public List<ItemStack> getInputItems() {return new ListAdapter<>(mInventory, 0, 1);}
|
||||||
@Override public List<ItemStack> getOutputItems() {return new ListAdapter<>(mInventory, 2, 5);} // TODO electrolyzer fluid slot etc
|
@Override public List<ItemStack> getOutputItems() {return new ListAdapter<>(mInventory, 2, 5);} // TODO electrolyzer fluid slot etc
|
||||||
|
|
|
@ -35,7 +35,6 @@ import gregtechmod.api.util.GT_Utility;
|
||||||
import gregtechmod.common.items.GT_Dataorb_Item;
|
import gregtechmod.common.items.GT_Dataorb_Item;
|
||||||
import gregtechmod.common.items.GT_Debug_Item;
|
import gregtechmod.common.items.GT_Debug_Item;
|
||||||
import gregtechmod.common.items.GT_Destructopack_Item;
|
import gregtechmod.common.items.GT_Destructopack_Item;
|
||||||
import gregtechmod.common.items.GT_FluidDisplayItem;
|
|
||||||
import gregtechmod.common.items.GT_IntegratedCircuit_Item;
|
import gregtechmod.common.items.GT_IntegratedCircuit_Item;
|
||||||
import gregtechmod.common.items.GT_MetaGenerated_Item_01;
|
import gregtechmod.common.items.GT_MetaGenerated_Item_01;
|
||||||
import gregtechmod.common.items.GT_MetaGenerated_Item_02;
|
import gregtechmod.common.items.GT_MetaGenerated_Item_02;
|
||||||
|
@ -272,7 +271,7 @@ public class GT_ItemLoader implements Runnable {
|
||||||
GT_Items.Circuit_Integrated.set((GregTech_API.sItemList[10] = new GT_IntegratedCircuit_Item("GregTech_Integrated_Circuit")));
|
GT_Items.Circuit_Integrated.set((GregTech_API.sItemList[10] = new GT_IntegratedCircuit_Item("GregTech_Integrated_Circuit")));
|
||||||
|
|
||||||
GT_Log.log.info("Register Regular Items.");
|
GT_Log.log.info("Register Regular Items.");
|
||||||
GT_Items.Display_Fluid.set((GregTech_API.sItemList[15] = new GT_FluidDisplayItem("GregTech_FluidDisplay"))); // FIXME REMOVE
|
// GregTech_API.sItemList[15] is free
|
||||||
GT_Items.NC_SensorCard.set((GregTech_API.sItemList[16] = (GT_Generic_Item) GT_Utility.callConstructor("gregtechmod.common.items.GT_SensorCard_Item", 0, (Object) null, false, "GregTech_Sensorcard")));
|
GT_Items.NC_SensorCard.set((GregTech_API.sItemList[16] = (GT_Generic_Item) GT_Utility.callConstructor("gregtechmod.common.items.GT_SensorCard_Item", 0, (Object) null, false, "GregTech_Sensorcard")));
|
||||||
if (GregTech_API.sItemList[16] == null) {
|
if (GregTech_API.sItemList[16] == null) {
|
||||||
GT_Items.NC_SensorCard.set((GregTech_API.sItemList[16] = new GT_Generic_Item("GregTech_Sensorcard", "util.missIC2NC")));
|
GT_Items.NC_SensorCard.set((GregTech_API.sItemList[16] = new GT_Generic_Item("GregTech_Sensorcard", "util.missIC2NC")));
|
||||||
|
|
Loading…
Reference in a new issue