mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-16 01:54:59 +00:00
1st commit
This commit is contained in:
1 parent
bedb2c25e1
commit
b13bd463a0
16 files changed
+1025
-6
No files matched your search
@@ -9,18 +9,18 @@ import com.glodblock.github.client.gui.container.ContainerPatternValueAmount;
|
||||
import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
|
||||
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
|
||||
import com.glodblock.github.common.tile.TileSuperStoker;
|
||||
import com.glodblock.github.inventory.gui.GuiType;
|
||||
import com.glodblock.github.inventory.item.IWirelessTerminal;
|
||||
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import com.glodblock.github.network.CPacketPatternValueSet;
|
||||
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class GuiPatternValueAmount extends FCGuiAmount {
|
||||
|
||||
public GuiPatternValueAmount(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
|
||||
public GuiPatternValueAmount(final InventoryPlayer inventoryPlayer, final Object te) {
|
||||
super(new ContainerPatternValueAmount(inventoryPlayer, te));
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ public class GuiPatternValueAmount extends FCGuiAmount {
|
||||
} else if (target instanceof WirelessPatternTerminalInventory) {
|
||||
this.myIcon = ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack();
|
||||
this.originalGui = GuiType.WIRELESS_FLUID_PATTERN_TERMINAL;
|
||||
} else if (target instanceof TileSuperStoker) {
|
||||
this.myIcon = ItemAndBlockHolder.SUPER_STOKER.stack();
|
||||
this.originalGui = GuiType.GUI_SUPER_STOKER;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEStack;
|
||||
import com.glodblock.github.client.gui.container.ContainerFluidAutoFiller;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.inventory.slot.OptionalFluidSlotFake;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.gui.container.ContainerSuperStoker;
|
||||
import com.glodblock.github.common.tile.TileSuperStoker;
|
||||
import com.glodblock.github.network.CPacketInventoryAction;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.SlotFake;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
public class GuiSuperStoker extends AEBaseGui {
|
||||
|
||||
private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/superStoker.png");
|
||||
private final ContainerSuperStoker cont;
|
||||
private final TileSuperStoker tile;
|
||||
private Map<Integer, IAEStack<?>> list = new HashMap<>();
|
||||
|
||||
public GuiSuperStoker(InventoryPlayer ipl, TileSuperStoker tile) {
|
||||
super(new ContainerSuperStoker(ipl, tile));
|
||||
this.tile = tile;
|
||||
this.cont = (ContainerSuperStoker) inventorySlots;
|
||||
this.ySize = 251;
|
||||
this.xSize = 216;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int mouseButton) {
|
||||
if (mouseButton == 3) {
|
||||
if (slot instanceof SlotFake) {
|
||||
if (slot.getHasStack()) {
|
||||
InventoryAction action = InventoryAction.SET_PATTERN_VALUE;
|
||||
IAEItemStack stack = AEItemStack.create(slot.getStack());
|
||||
((AEBaseContainer) this.inventorySlots).setTargetStack(stack);
|
||||
for (int i = 0; i < this.inventorySlots.inventorySlots.size(); i++) {
|
||||
if (slot.equals(this.inventorySlots.inventorySlots.get(i))) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketInventoryAction(action, i, 0, stack));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void func_146977_a(Slot s) {
|
||||
if (s instanceof SlotFake) {
|
||||
this.drawFillStatus(s);
|
||||
}
|
||||
super.func_146977_a(s);
|
||||
}
|
||||
|
||||
private void drawFillStatus(Slot slotIn) {
|
||||
int offsetX = slotIn.xDisplayPosition - 8;
|
||||
int offsetY = slotIn.yDisplayPosition - 11;
|
||||
ItemStack itemstack = slotIn.getStack();
|
||||
int slotInt = slotIn.slotNumber;
|
||||
if (itemstack != null) {
|
||||
String s = "0%";
|
||||
if (slotInt > 0 && slotInt < 9) {
|
||||
IAEStack<?> aeStack = list.get(slotInt - 1);
|
||||
if (aeStack != null) s = (int) (((float) aeStack.getStackSize() / ItemFluidPacket.getFluidAmount(itemstack)) * 100) + "%";
|
||||
} else if (slotInt > 9 && slotInt < 73){
|
||||
IAEStack<?> aeStack = list.get(slotInt + 90);
|
||||
if (aeStack != null && itemstack.stackSize > 0) {
|
||||
long i = aeStack.getStackSize();
|
||||
s = (int) (((float) i / itemstack.stackSize) * 100) + "%";
|
||||
}
|
||||
}
|
||||
|
||||
float scale = 0.5f;
|
||||
float shiftX = 2;
|
||||
float shiftY = 1;
|
||||
final float inverseScaleFactor = 1.0f / scale;
|
||||
|
||||
final int X = (int) (((float) offsetX - shiftX
|
||||
+ 16.0f
|
||||
+ 1.0f
|
||||
- this.fontRendererObj.getStringWidth(s) * scale) * inverseScaleFactor);
|
||||
final int Y = (int) (((float) offsetY - shiftY + 16.0f - 7.0f * scale) * inverseScaleFactor);
|
||||
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
|
||||
GL11.glScaled(scale, scale, scale);
|
||||
this.fontRendererObj.drawStringWithShadow(s, X, Y, 16777215);
|
||||
GL11.glScaled(inverseScaleFactor, inverseScaleFactor, inverseScaleFactor);
|
||||
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
|
||||
this.bindTexture(TEX_BG);
|
||||
this.drawTexturedModalRect(offsetX, offsetY, 0, 0, xSize, ySize);
|
||||
}
|
||||
|
||||
public void update(Map<Integer, IAEStack<?>> map) {
|
||||
this.list = map;
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -4,7 +4,6 @@ import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
@@ -17,7 +16,7 @@ public class ContainerPatternValueAmount extends AEBaseContainer {
|
||||
@GuiSync(11)
|
||||
public int valueIndex;
|
||||
|
||||
public ContainerPatternValueAmount(final InventoryPlayer ip, final ITerminalHost te) {
|
||||
public ContainerPatternValueAmount(final InventoryPlayer ip, final Object te) {
|
||||
super(ip, te);
|
||||
this.patternValue = new SlotInaccessible(new AppEngInternalInventory(null, 1), 0, 34, 53);
|
||||
this.addSlotToContainer(patternValue);
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import com.glodblock.github.network.SPacketSuperStokerUpdate;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.common.item.ItemBasicFluidStorageCell;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.tile.TileSuperStoker;
|
||||
import com.glodblock.github.inventory.slot.OptionalFluidSlotFake;
|
||||
import com.glodblock.github.network.SPacketFluidUpdate;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.IOptionalSlotHost;
|
||||
import appeng.container.slot.SlotPatternOutputs;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.items.storage.ItemBasicStorageCell;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
public class ContainerSuperStoker extends AEBaseContainer implements IOptionalSlotHost {
|
||||
|
||||
private final TileSuperStoker tile;
|
||||
private IInventory configFluids;
|
||||
private IInventory configItems;
|
||||
private Map<Integer, IAEStack<?>> list;
|
||||
|
||||
public ContainerSuperStoker(InventoryPlayer ipl, TileSuperStoker tile) {
|
||||
super(ipl, tile);
|
||||
this.tile = tile;
|
||||
configFluids = tile.getConfigFluid();
|
||||
configItems = tile.getConfigItems();
|
||||
final IInventory cell = tile.getCell();
|
||||
|
||||
final int x = 8;
|
||||
final int fy = 8;
|
||||
|
||||
this.addSlotToContainer(
|
||||
new SlotRestrictedInput(
|
||||
SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL,
|
||||
cell,
|
||||
0,
|
||||
173,
|
||||
fy,
|
||||
this.getInventoryPlayer()));
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
addSlotToContainer(new OptionalFluidSlotFake(configFluids, this, i, x, fy, i, 0, 0));
|
||||
}
|
||||
|
||||
final int io = 29;
|
||||
for (int y = 0; y < 7; y++) {
|
||||
for (int ix = 0; ix < 9; ix++) {
|
||||
this.addSlotToContainer(new SlotPatternOutputs(configItems, this, y * 9 + ix, x, io, ix, y, y));
|
||||
}
|
||||
}
|
||||
|
||||
bindPlayerInventory(ipl, 0, 251 - 82);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
|
||||
if (slotId == 0 && player.inventory.getItemStack() == null && isConfigurated()) {
|
||||
return null;
|
||||
}
|
||||
return super.slotClick(slotId, clickedButton, mode, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSlotEnabled(int idx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
Map<Integer, IAEStack<?>> tmp = new HashMap<>();
|
||||
for (int i = 0; i < tile.getInternalFluid().getSlots(); i++) {
|
||||
tmp.put(i, tile.getInternalFluid().getFluidInSlot(i));
|
||||
}
|
||||
for (int i = 0; i < tile.getInternalInventory().getSizeInventory(); i++) {
|
||||
tmp.put(
|
||||
i + 100,
|
||||
tile.getInternalAEInventory().getAEStackInSlot(i));
|
||||
}
|
||||
for (final Object g : this.crafters) {
|
||||
if (g instanceof EntityPlayer) {
|
||||
FluidCraft.proxy.netHandler.sendTo(new SPacketSuperStokerUpdate(tmp), (EntityPlayerMP) g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isConfigurated() {
|
||||
for (int i = 0; i < configItems.getSizeInventory(); i++) {
|
||||
if (configItems.getStackInSlot(i) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < configFluids.getSizeInventory(); i++) {
|
||||
if (configFluids.getStackInSlot(i) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidForSlot(Slot s, ItemStack is) {
|
||||
if (s.slotNumber == 0 && s.getHasStack() && isConfigurated()) {
|
||||
long currentBytes = 0;
|
||||
long newBytes = 0;
|
||||
|
||||
if (s.getStack().getItem() instanceof ItemBasicStorageCell ibsc) {
|
||||
currentBytes = ibsc.getBytesLong(is);
|
||||
} else if (s.getStack().getItem() instanceof ItemBasicFluidStorageCell ibfsc) {
|
||||
currentBytes = ibfsc.getBytes(is);
|
||||
}
|
||||
|
||||
if (is.getItem() instanceof ItemBasicStorageCell ibsc) {
|
||||
newBytes = ibsc.getBytesLong(is);
|
||||
} else if (is.getItem() instanceof ItemBasicFluidStorageCell ibfsc) {
|
||||
newBytes = ibfsc.getBytes(is);
|
||||
}
|
||||
|
||||
if (currentBytes > newBytes) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.isValidForSlot(s, is);
|
||||
}
|
||||
|
||||
public TileSuperStoker getTile() {
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user