Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.8.98-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-944-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-959-GTNH:dev')
api('com.github.GTNewHorizons:waila:1.19.28:dev')
api("com.github.GTNewHorizons:GTNHLib:0.10.2:dev")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,101 +1,105 @@
package com.glodblock.github.client.gui;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Map;

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.ContainerSuperStockReplenisher;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileSuperStockReplenisher;

import appeng.api.storage.StorageName;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IAEStackType;
import appeng.client.gui.AEBaseGui;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotFake;
import appeng.client.gui.slots.VirtualMEPhantomSlot;
import appeng.client.gui.slots.VirtualMEPhantomSlotPrecise;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketVirtualSlot;
import appeng.util.item.AEItemStack;
import appeng.util.item.AEFluidStackType;
import appeng.util.item.AEItemStackType;

public class GuiSuperStockReplenisher extends AEBaseGui {

private static final ResourceLocation TEX_BG = FluidCraft.resource("textures/gui/superStockReplenisher.png");
private final DecimalFormat df = new DecimalFormat("#.#");
private Map<Integer, IAEStack<?>> list = new HashMap<>();
private final ContainerSuperStockReplenisher containerSuperStockReplenisher;

private final VirtualMEPhantomSlotPrecise[] configFluidsSlots = new VirtualMEPhantomSlotPrecise[9];
private final VirtualMEPhantomSlotPrecise[] configItemsSlots = new VirtualMEPhantomSlotPrecise[63];

public GuiSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) {
super(new ContainerSuperStockReplenisher(ipl, tile));

this.containerSuperStockReplenisher = (ContainerSuperStockReplenisher) 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()) {
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))) {
NetworkHandler.instance
.sendToServer(new PacketSwitchGuis(GuiBridge.GUI_PATTERN_VALUE_AMOUNT));
NetworkHandler.instance
.sendToServer(new PacketVirtualSlot(StorageName.CRAFTING_INPUT, i, stack));
}
}
return;
}
}
}
super.handleMouseClick(slot, slotIdx, ctrlDown, mouseButton);
public void initGui() {
super.initGui();
this.initSlots();
}

@Override
public void func_146977_a(Slot s) {
if (s instanceof SlotFake) {
this.drawFillStatus(s);
private void initSlots() {

final int xo = 8;
final int yo = 8;

for (int i = 0; i < 9; i++) {
VirtualMEPhantomSlotPrecise slot = new VirtualMEPhantomSlotPrecise(
xo + i * 18,
yo,
this.containerSuperStockReplenisher.configFluidsSlots,
i,
this::acceptType);
this.configFluidsSlots[i] = slot;
this.registerVirtualSlots(slot);
}

final int iyo = 29;
for (int y = 0; y < 7; y++) {
for (int ix = 0; ix < 9; ix++) {
VirtualMEPhantomSlotPrecise slot = new VirtualMEPhantomSlotPrecise(
xo + ix * 18,
iyo + y * 18,
this.containerSuperStockReplenisher.configItemsSlots,
y * 9 + ix,
this::acceptType);
this.configItemsSlots[y * 9 + ix] = slot;
this.registerVirtualSlots(slot);
}
}
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) {
private void drawFillStatus(VirtualMEPhantomSlotPrecise virtualSlot) {
final int offsetX = virtualSlot.getX() - 8;
final int offsetY = virtualSlot.getY() - 12;
final IAEStack<?> aes = virtualSlot.getAEStack();
final long stackSize = aes != null ? aes.getStackSize() : 0;
final int slotIndex = virtualSlot.getStorageName() == StorageName.NONE ? virtualSlot.getSlotIndex()
: virtualSlot.getSlotIndex() + 100;

if (stackSize != 0) {
String s = "0%";
if (slotInt > 0 && slotInt < 10) {
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) + "%";
}
}
IAEStack<?> aeStack = list.get(slotIndex);

if (aeStack != null) s = df.format((float) aeStack.getStackSize() / 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 + 10.0f) * inverseScaleFactor);
final int Y = (int) (((float) offsetY - shiftY + 16.0f - 7.0f * scale) * inverseScaleFactor);
final int X = (int) (((float) offsetX - shiftX + 10.0f) * inverseScaleFactor) + 1;
final int Y = (int) (((float) offsetY - shiftY + 16.0f - 7.0f * scale) * inverseScaleFactor) + 2;
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
GL11.glScaled(scale, scale, scale);
this.fontRendererObj.drawStringWithShadow(s, X, Y, 16777215);
Expand All @@ -104,9 +108,15 @@ private void drawFillStatus(Slot slotIn) {
}
}

private void drawVirtualSlots() {
for (VirtualMEPhantomSlotPrecise slot : this.configFluidsSlots) this.drawFillStatus(slot);
for (VirtualMEPhantomSlotPrecise slot : this.configItemsSlots) this.drawFillStatus(slot);
}

@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) {
fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, ySize - 94, 0x404040);
this.drawVirtualSlots();
}

@Override
Expand All @@ -118,4 +128,9 @@ public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) {
public void update(Map<Integer, IAEStack<?>> map) {
this.list = map;
}

private boolean acceptType(VirtualMEPhantomSlot slot, IAEStackType<?> type, int mouseButton) {
if (slot.getStorageName() == StorageName.NONE) return type == AEFluidStackType.FLUID_STACK_TYPE;
else return type == AEItemStackType.ITEM_STACK_TYPE;
}
}
Loading