Compare commits

..
Author SHA1 Message Date
Inphysible 1aba13e96f Make Fluid Cells storable in Item Cells again (#441) 2026-06-10 01:07:31 -04:00
Kogepan229 dd05ae29c1 Adapt to GUIColor changes (#439) 2026-06-04 16:06:19 +02:00
sisyphussy 44dfa4d551 Optimize Walrus (#437) 2026-05-29 16:51:11 +02:00
lc-1337 0a84d208f3 Renew Replenisher (#435) 2026-05-27 08:41:28 +02:00
lc-1337andMartin Robertz 4a030a52b6 adapt (#436)
Co-authored-by: Martin Robertz <[email protected]>
2026-05-21 16:14:17 +00:00
Kogepan229 ead0aff1ae Cleanup deps (#434) 2026-05-19 14:14:35 +00:00
Luca 04d80384b2 Fix crash when draining Certus Quartz Tank with Large Steel Fluid Cell (#438) 2026-05-16 19:51:40 -04:00
39 changed files with 363 additions and 1385 deletions

No files matched your search

+13 -19
View File
@@ -34,28 +34,22 @@
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.8.96-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-929-GTNH:dev')
api('com.github.GTNewHorizons:waila:1.19.25:dev')
api("com.github.GTNewHorizons:GTNHLib:0.9.62:dev")
api('com.github.GTNewHorizons:NotEnoughItems:2.8.100-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-971-GTNH:dev')
api('com.github.GTNewHorizons:waila:1.19.29:dev')
api("com.github.GTNewHorizons:GTNHLib:0.11.4:dev")
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.12.15:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.14-GTNH:dev')
compileOnly('com.github.GTNewHorizons:Baubles-Expanded:2.2.21-GTNH:dev')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.60:dev') {transitive = false}
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.35:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.19:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:5.2.62:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.52.495:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'AE2FluidCraft-Rework'
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
compileOnly('com.github.GTNewHorizons:ForestryMC:4.11.26:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.10.29:dev')
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.44-GTNH:dev') { transitive = false }
compileOnly('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
compileOnly('com.gregoriust.gregtech:gregtech_1.7.10:6.14.23:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:OpenComputers:1.12.39-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.7.48-GTNH:dev') { transitive = false }
compileOnly("org.jetbrains:annotations:26.1.0")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.4.2:dev")
runtimeOnlyNonPublishable("com.github.GTNewHorizons:WirelessCraftingTerminal:1.12.16:dev") {
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
}
@@ -241,12 +241,12 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
StatCollector.translateToLocal(NameConst.GUI_LEVEL_TERMINAL),
8,
6,
GuiColors.InterfaceTerminalTitle.getColor());
GuiColors.GuiTextColorGray.getColor());
fontRendererObj.drawString(
GuiText.inventory.getLocal(),
GuiLevelTerminal.offsetX + 2,
ySize - 96 + 3,
GuiColors.InterfaceTerminalInventory.getColor());
GuiColors.GuiTextColorGray.getColor());
if (!ModAndClassUtil.NEI && tooltipStack != null) {
renderToolTip(tooltipStack, mouseX, mouseY);
@@ -395,7 +395,7 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
int title;
int renderY = 0;
final int sectionBottom = viewY + section.getHeight() - 1;
final int fontColor = GuiColors.InterfaceTerminalInventory.getColor();
final int fontColor = GuiColors.GuiTextColorGray.getColor();
/*
* Render title
*/
@@ -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;
}
public void initGui() {
super.initGui();
this.initSlots();
}
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.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(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;
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) {
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);
@@ -104,9 +108,15 @@ public class GuiSuperStockReplenisher extends AEBaseGui {
}
}
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
@@ -118,4 +128,9 @@ public class GuiSuperStockReplenisher extends AEBaseGui {
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;
}
}
@@ -3,63 +3,57 @@ package com.glodblock.github.client.gui.container;
import java.util.HashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ICrafting;
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.FCBaseItemCell;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.common.tile.TileSuperStockReplenisher;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.slot.OptionalFluidSlotFake;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.SPacketSuperStockReplenisherUpdate;
import com.glodblock.github.util.FluidPrimaryGui;
import appeng.api.storage.StorageName;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.client.gui.implementations.GuiPatternItemRenamer;
import appeng.client.gui.implementations.GuiPatternValueAmount;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerOpenContext;
import appeng.container.PrimaryGui;
import appeng.container.interfaces.IVirtualSlotHolder;
import appeng.container.interfaces.IVirtualSlotSource;
import appeng.container.slot.IOptionalSlotHost;
import appeng.container.slot.SlotPatternOutputs;
import appeng.container.slot.SlotRestrictedInput;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketVirtualSlot;
import appeng.container.sync.SyncManager;
import appeng.container.sync.handlers.AEStackInventorySyncHandler;
import appeng.items.storage.ItemBasicStorageCell;
import appeng.tile.inventory.IAEStackInventory;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
public class ContainerSuperStockReplenisher extends AEBaseContainer
implements IOptionalSlotHost, IVirtualSlotHolder, IVirtualSlotSource {
public class ContainerSuperStockReplenisher extends AEBaseContainer implements IVirtualSlotSource {
private final TileSuperStockReplenisher tile;
private final IInventory configFluids;
private final IInventory configItems;
private int lastUpdated = 0;
private int lastUpdated = 1337;
private final IAEStackInventory configFluids;
public final AEStackInventorySyncHandler configFluidsSlots;
private final IAEStackInventory configItems;
public final AEStackInventorySyncHandler configItemsSlots;
public ContainerSuperStockReplenisher(InventoryPlayer ipl, TileSuperStockReplenisher tile) {
super(ipl, tile);
this.tile = tile;
configFluids = tile.getConfigFluid();
configItems = tile.getConfigItems();
this.configFluids = tile.getConfigFluids();
this.configItems = tile.getConfigItems();
final IInventory cell = tile.getCell();
final int x = 8;
final int fy = 8;
final SyncManager sm = this.getSyncManager();
this.configFluidsSlots = sm.root().aeStackInventory("fluidConfig", this.configFluids);
this.configItemsSlots = sm.root().aeStackInventory("itemConfig", this.configItems);
this.addSlotToContainer(
new SlotRestrictedInput(
@@ -67,56 +61,33 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer
cell,
0,
173,
fy,
8,
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;
}
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 addCraftingToCrafters(ICrafting p_75132_1_) {
super.addCraftingToCrafters(p_75132_1_);
lastUpdated = 24;
}
@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (Platform.isClient()) return;
if (lastUpdated > 20) {
lastUpdated = 0;
if (this.lastUpdated > 20) {
this.lastUpdated = 0;
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 < this.tile.getInternalFluid().getSlots(); i++) {
tmp.put(i, this.tile.getInternalFluid().getFluidInSlot(i));
}
for (int i = 0; i < tile.getInternalInventory().getSizeInventory(); i++) {
tmp.put(i + 100, AEItemStack.create(tile.getInternalInventory().getStackInSlot(i)));
for (int i = 0; i < this.tile.getInternalInventory().getSizeInventory(); i++) {
tmp.put(i + 100, AEItemStack.create(this.tile.getInternalInventory().getStackInSlot(i)));
}
for (final Object g : this.crafters) {
@@ -125,20 +96,16 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer
}
}
}
lastUpdated++;
this.lastUpdated++;
}
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;
}
}
for (int i = 0; i < this.configItems.getSizeInventory(); i++)
if (this.configItems.getAEStackInSlot(i) != null) return true;
for (int i = 0; i < this.configFluids.getSizeInventory(); i++)
if (this.configFluids.getAEStackInSlot(i) != null) return true;
return false;
}
@@ -167,10 +134,6 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer
return super.isValidForSlot(s, is);
}
public TileSuperStockReplenisher getTile() {
return tile;
}
@Override
public PrimaryGui createPrimaryGui() {
ContainerOpenContext context = getOpenContext();
@@ -181,40 +144,18 @@ public class ContainerSuperStockReplenisher extends AEBaseContainer
context.getSide());
}
@Override
public void receiveSlotStacks(StorageName invName, Int2ObjectMap<IAEStack<?>> slotStacks) {
var entry = slotStacks.int2ObjectEntrySet().iterator().next();
IAEStack<?> aes = entry.getValue();
int slotIndex = entry.getIntKey();
if (Platform.isServer()) {
for (ICrafting crafter : this.crafters) {
final EntityPlayerMP emp = (EntityPlayerMP) crafter;
NetworkHandler.instance.sendTo(new PacketVirtualSlot(invName, slotIndex, aes), emp);
}
} else {
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if (gs instanceof GuiPatternValueAmount gpva) {
gpva.update();
} else if (gs instanceof GuiPatternItemRenamer gpir) {
gpir.update();
}
}
}
@Override
public void updateVirtualSlot(StorageName invName, int slotId, IAEStack<?> aes) {
if (aes instanceof IAEItemStack ais) {
ItemStack newIs;
if (ais.getItem() instanceof ItemFluidPacket) {
newIs = ais.getItemStack();
newIs.stackSize = 1;
ItemFluidPacket.setFluidAmount(newIs, aes.getStackSize());
} else {
newIs = ais.getItemStack();
if (aes != null && aes.getStackSize() > Integer.MAX_VALUE) aes.setStackSize(Integer.MAX_VALUE);
switch (invName) {
case NONE -> {
this.configFluids.putAEStackInSlot(slotId, aes);
this.configFluidsSlots.markDirty();
}
case CONFIG -> {
this.configItems.putAEStackInSlot(slotId, aes);
this.configItemsSlots.markDirty();
}
this.inventorySlots.get(slotId).putStack(newIs);
}
}
}
@@ -1,25 +1,19 @@
package com.glodblock.github.client.render;
import net.minecraft.client.Minecraft;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tile.TileWalrus;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.proxy.ClientProxy;
import cpw.mods.fml.client.registry.ClientRegistry;
public class ItemWalrusRender implements IItemRenderer {
ResourceLocation textureWalrus = FluidCraft.resource("textures/blocks/walrus.png");
public ItemWalrusRender() {
ClientRegistry.bindTileEntitySpecialRenderer(TileWalrus.class, new RenderBlockWalrus());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.WALRUS), this);
@@ -32,7 +26,6 @@ public class ItemWalrusRender implements IItemRenderer {
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
GL11.glPushMatrix();
switch (type) {
case EQUIPPED_FIRST_PERSON -> {
@@ -42,7 +35,7 @@ public class ItemWalrusRender implements IItemRenderer {
case INVENTORY -> GL11.glTranslatef(-0.5F, -0.5F, -0.1F);
default -> {}
}
ClientProxy.getWalrusModel().renderAll();
WalrusRenderer.render();
GL11.glPopMatrix();
}
@@ -1,23 +1,16 @@
package com.glodblock.github.client.render;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.common.tile.TileWalrus;
import com.glodblock.github.proxy.ClientProxy;
public class RenderBlockWalrus extends TileEntitySpecialRenderer {
ResourceLocation textureWalrus = FluidCraft.resource("textures/blocks/walrus.png");
@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime) {
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
if (!(tileentity instanceof TileWalrus Tile)) return;
float scale = Tile.getWalrusScale();
GL11.glPushMatrix();
@@ -40,7 +33,7 @@ public class RenderBlockWalrus extends TileEntitySpecialRenderer {
break;
}
GL11.glScalef(scale, scale, scale);
ClientProxy.getWalrusModel().renderAll();
WalrusRenderer.render();
GL11.glPopMatrix();
}
}
@@ -0,0 +1,28 @@
package com.glodblock.github.client.render;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import com.glodblock.github.FluidCraft;
import com.gtnewhorizon.gtnhlib.client.model.wavefront.WavefrontVBOBuilder;
import com.gtnewhorizon.gtnhlib.client.renderer.vao.IVertexArrayObject;
public final class WalrusRenderer {
private static IVertexArrayObject walrus;
private static final ResourceLocation textureWalrus = FluidCraft.resource("textures/blocks/walrus.png");
public static void load() {
walrus = WavefrontVBOBuilder.compileToVBO(FluidCraft.resource("models/walrus.obj"));
}
public static void render() {
Minecraft.getMinecraft().renderEngine.bindTexture(textureWalrus);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
walrus.render();
}
}
@@ -1,6 +1,5 @@
package com.glodblock.github.common.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
@@ -47,15 +46,6 @@ public class BlockSuperStockReplenisher extends FCBaseBlock {
return false;
}
@Override
public void breakBlock(World w, int x, int y, int z, Block a, int b) {
final TileSuperStockReplenisher tss = this.getTileEntity(w, x, y, z);
if (tss != null) {
tss.fullRefund();
}
super.breakBlock(w, x, y, z, a, b);
}
@Override
public BlockSuperStockReplenisher register() {
GameRegistry.registerBlock(this, AEBaseItemBlock.class, NameConst.BLOCK_SUPER_STOCK_REPLENISHER);
@@ -52,7 +52,7 @@ public abstract class FCBaseItemCell extends AEBaseCell {
}
@Override
public int getTypeWeight() {
return 8 * 256;
public boolean storableInStorageCell() {
return true;
}
}
@@ -2,7 +2,7 @@ package com.glodblock.github.common.item;
import static com.glodblock.github.common.item.ItemWirelessUltraTerminal.MODE;
import static com.glodblock.github.loader.recipe.WirelessTerminalEnergyRecipe.getEnergyCard;
import static com.glodblock.github.loader.recipe.WirelessTerminalRecipe.getInfinityBoosterCard;
import static com.glodblock.github.loader.recipe.WirelessTerminalQuantumBridgeRecipe.getQuantumBridgeCard;
import static com.glodblock.github.util.Util.DimensionalCoordSide.hasEnergyCard;
import static com.glodblock.github.util.Util.hasInfinityBoosterCard;
@@ -48,15 +48,16 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
@Override
public ItemStack onItemRightClick(final ItemStack item, final World w, final EntityPlayer player) {
if (player.isSneaking()) return removeInfinityBoosterCard(player, item); // todo: doesn't work in universal
// terminal
if (player.isSneaking()) return removeQuantumBridgeCard(player, item); // todo: doesn't work in universal
// terminal
return super.onItemRightClick(item, w, player);
}
private ItemStack removeInfinityBoosterCard(final EntityPlayer player, ItemStack is) {
private ItemStack removeQuantumBridgeCard(final EntityPlayer player, ItemStack is) {
if (hasInfinityBoosterCard(is)) {
if (!player.inventory.addItemStackToInventory(getInfinityBoosterCard())) {
player.entityDropItem(getInfinityBoosterCard(), 0);
ItemStack quantumBridgeCardStack = getQuantumBridgeCard().copy();
if (!player.inventory.addItemStackToInventory(quantumBridgeCardStack)) {
player.entityDropItem(quantumBridgeCardStack, 0);
}
is.getTagCompound().setBoolean(infinityBoosterCard, false);
}
@@ -71,7 +72,7 @@ public class ItemBaseWirelessTerminal extends ToolWirelessTerminal implements II
if (GuiScreen.isCtrlKeyDown()) {
lines.add(NameConst.i18n(NameConst.TT_WIRELESS_INSTALLED));
if (hasInfinityBoosterCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getInfinityBoosterCard().getDisplayName());
lines.add(" " + EnumChatFormatting.GOLD + getQuantumBridgeCard().getDisplayName());
}
if (hasEnergyCard(stack)) {
lines.add(" " + EnumChatFormatting.GOLD + getEnergyCard().getDisplayName());
@@ -101,9 +101,4 @@ public class ItemPortableFluidCell extends AEBasePortableCell implements IRegist
public ItemStack stack() {
return new ItemStack(this, 1);
}
@Override
public int getTypeWeight() {
return 8 * 256;
}
}
@@ -167,15 +167,6 @@ public class ItemWirelessUltraTerminal extends ItemBaseWirelessTerminal
this.openGui(is, w, player, mode, Integer.MIN_VALUE);
}
public static boolean hasInfinityBoosterCard(EntityPlayer player) {
ImmutablePair<Integer, ItemStack> term = Util.getUltraWirelessTerm(player);
if (term == null) return false;
if (term.getRight().getItem() instanceof ItemWirelessUltraTerminal) {
return Util.hasInfinityBoosterCard(term.getRight());
}
return false;
}
@Override
public void onWornTick(ItemStack itemStack, EntityLivingBase entityLivingBase) {
if (Platform.isServer() && entityLivingBase instanceof EntityPlayer player) {
@@ -70,7 +70,8 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
return mainTank.drain(fluid, amount, doDrain, false);
}
if (this.getFluid() == null) {
Fluid currentFluid = this.getFluid();
if (currentFluid == null) {
return null;
}
@@ -84,10 +85,10 @@ public class TileCertusQuartzTank extends TileEntity implements IFluidHandler {
if (drained < amount) {
TileCertusQuartzTank tankBelow = this.getTankBelow();
if (tankBelow != null) {
FluidStack externallyDrained = tankBelow.drain(this.getFluid(), amount - drained, doDrain, false);
FluidStack externallyDrained = tankBelow.drain(currentFluid, amount - drained, doDrain, false);
if (externallyDrained != null) {
return new FluidStack(this.getFluid(), drained + externallyDrained.amount);
return new FluidStack(currentFluid, drained + externallyDrained.amount);
}
}
}
@@ -15,12 +15,16 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import org.jetbrains.annotations.Nullable;
import com.glodblock.github.common.item.FCBaseItemCell;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.AEFluidInventory;
import com.glodblock.github.inventory.IAEFluidInventory;
import com.glodblock.github.inventory.IAEFluidTank;
import com.gtnewhorizon.gtnhlib.item.ItemStackNBT;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.implementations.IPowerChannelState;
@@ -36,8 +40,10 @@ import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.StorageName;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.AECableType;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
@@ -47,28 +53,48 @@ import appeng.me.GridAccessException;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import appeng.tile.grid.AENetworkInvTile;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.BiggerAppEngInventory;
import appeng.tile.inventory.IAEStackInventory;
import appeng.tile.inventory.IIAEStackInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
import io.netty.buffer.ByteBuf;
public class TileSuperStockReplenisher extends AENetworkInvTile
implements IAEFluidInventory, IFluidHandler, IPowerChannelState, IGridTickable, ITerminalHost {
public class TileSuperStockReplenisher extends AENetworkInvTile implements IAEFluidInventory, IFluidHandler,
IPowerChannelState, IGridTickable, ITerminalHost, IIAEStackInventory {
private final AppEngInternalInventory cell = new AppEngInternalInventory(this, 1);
private final BiggerAppEngInventory invItems = new BiggerAppEngInventory(this, 63);
private final AEFluidInventory invFluids = new AEFluidInventory(this, 9, Integer.MAX_VALUE);
private final AppEngInternalAEInventory configFluids = new AppEngInternalAEInventory(this, 9);
private final AppEngInternalAEInventory configItems = new AppEngInternalAEInventory(this, 63);
private final IAEStackInventory configFluids = new IAEStackInventory(this, 9, StorageName.NONE) {
@Override
public void readFromNBT(@Nullable NBTTagCompound data, String name) {
super.readFromNBT(data, name);
for (int i = 0; i < this.getSizeInventory(); i++) {
final IAEStack<?> aes = this.getAEStackInSlot(i);
if (aes instanceof IAEItemStack ais && ais.getItem() instanceof ItemFluidPacket) {
final IAEFluidStack ifs = ItemFluidPacket.getFluidAEStack(ais);
if (ifs != null && ifs.getStackSize() > Integer.MAX_VALUE) ifs.setStackSize(Integer.MAX_VALUE);
this.putAEStackInSlot(i, ifs);
}
}
}
};
private final IAEStackInventory configItems = new IAEStackInventory(this, 63, StorageName.CONFIG);
private final BaseActionSource source;
private boolean isPowered;
private long totalBytes;
private long storedFluidCount;
private long storedItemCount;
private boolean needReCountStoredFluids = true;
private boolean needReCountStoredItems = true;
public TileSuperStockReplenisher() {
super(false);
getProxy().setIdlePowerUsage(4D);
@@ -78,18 +104,28 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
}
private TickRateModulation doWork() {
this.fletchFluids();
this.fletchItems();
this.needReCountStoredFluids = true;
this.needReCountStoredItems = true;
return TickRateModulation.SAME;
}
private void fletchFluids() {
for (int i = 0; i < 9; i++) {
IAEFluidStack invFluid = invFluids.getFluidInSlot(i);
IAEItemStack configFluid = configFluids.getAEStackInSlot(i);
if (configFluid != null) {
IAEFluidStack fs = AEFluidStack.create(ItemFluidPacket.getFluidStack(configFluid));
if (invFluid == null) requestFluid(fs, i);
else if (invFluid.equals(fs)) {
IAEStack<?> configFluid = configFluids.getAEStackInSlot(i);
if (configFluid instanceof IAEFluidStack fs) {
IAEFluidStack ifs = fs.copy();
if (invFluid == null) requestFluid(ifs, i);
else if (invFluid.equals(ifs)) {
long invSize = invFluid.getStackSize();
long confSize = fs.getStackSize();
long confSize = ifs.getStackSize();
if (invSize < confSize / 2f) {
fs.setStackSize(confSize - invSize);
requestFluid(fs, i);
ifs.setStackSize(confSize - invSize);
requestFluid(ifs, i);
} else if (invSize > confSize) {
returnFluid(i, invSize - confSize);
}
@@ -100,13 +136,14 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
returnFluid(i, Long.MAX_VALUE);
}
}
}
private void fletchItems() {
for (int i = 0; i < 63; i++) {
ItemStack invItem = invItems.getStackInSlot(i);
IAEItemStack configItem = configItems.getAEStackInSlot(i);
if (configItem != null) {
IAEItemStack is = configItem.copy();
IAEStack<?> configItem = configItems.getAEStackInSlot(i);
if (configItem instanceof IAEItemStack ais) {
IAEItemStack is = ais.copy();
if (invItem == null) requestItem(is, i);
else if (is.equals(invItem)) {
int confSize = (int) is.getStackSize();
@@ -123,8 +160,28 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
returnItem(i, Integer.MAX_VALUE);
}
}
}
return TickRateModulation.SAME;
private void countFluids() {
if (this.needReCountStoredFluids) {
this.needReCountStoredFluids = false;
this.storedFluidCount = 0;
for (int i = 0; i < this.invFluids.getSlots(); i++) {
final IAEFluidStack fs = this.invFluids.getFluidInSlot(i);
if (fs != null) this.storedFluidCount += fs.getStackSize();
}
}
}
private void countItems() {
if (this.needReCountStoredItems) {
this.needReCountStoredItems = false;
this.storedItemCount = 0;
for (int i = 0; i < this.invItems.getSizeInventory(); i++) {
final ItemStack is = this.invItems.getStackInSlot(i);
if (is != null) this.storedItemCount += is.stackSize;
}
}
}
private void returnFluid(int index, long amount) {
@@ -161,21 +218,23 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
is.stackSize = is.stackSize - amount;
is = is.copy();
is.stackSize = amount;
storedItemCount -= is.stackSize;
} else {
invItems.setInventorySlotContents(index, null);
}
this.storedItemCount -= is.stackSize;
IAEItemStack notInserted = this.getProxy().getStorage().getItemInventory()
.injectItems(AEItemStack.create(is), Actionable.MODULATE, this.source);
if (notInserted != null) {
ItemStack tempStack = invItems.getStackInSlot(index);
if (tempStack != null) {
tempStack.stackSize = tempStack.stackSize + (int) notInserted.getStackSize();
storedItemCount += notInserted.getStackSize();
saveChanges();
} else invItems.setInventorySlotContents(index, notInserted.getItemStack());
this.storedItemCount += notInserted.getStackSize();
}
} catch (final GridAccessException ignored) {}
}
@@ -191,10 +250,11 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
ItemStack tempStack = invItems.getStackInSlot(index);
if (tempStack != null) {
tempStack.stackSize = tempStack.stackSize + (int) extracted.getStackSize();
storedItemCount += extracted.getStackSize();
saveChanges();
} else invItems.setInventorySlotContents(index, extracted.getItemStack());
this.storedItemCount += extracted.getStackSize();
}
} catch (final GridAccessException ignored) {}
}
@@ -210,12 +270,12 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
return invItems;
}
public AppEngInternalAEInventory getConfigFluid() {
return configFluids;
public IAEStackInventory getConfigFluids() {
return this.configFluids;
}
public AppEngInternalAEInventory getConfigItems() {
return configItems;
public IAEStackInventory getConfigItems() {
return this.configItems;
}
public AppEngInternalInventory getCell() {
@@ -223,6 +283,9 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
}
public long getFreeBytes() {
this.countFluids();
this.countItems();
return totalBytes - (((storedItemCount + getUnusedItemCount()) / 8)
+ ((storedFluidCount + getUnusedFluidCount()) / 2048));
}
@@ -273,14 +336,6 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
totalBytes = 0;
getProxy().setIdlePowerUsage(4d);
}
} else if (inv == invItems) {
if (added != null) {
storedItemCount += added.stackSize;
}
if (removed != null) {
storedItemCount -= removed.stackSize;
}
}
}
case decreaseStackSize -> {
@@ -288,10 +343,6 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
totalBytes = 0;
getProxy().setIdlePowerUsage(4d);
}
if (inv == invItems) {
storedItemCount -= removed.stackSize;
}
}
case markDirty -> markDirty();
}
@@ -319,12 +370,26 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
@Override
public void getDrops(World w, int x, int y, int z, List<ItemStack> drops) {
this.fullRefund();
if (cell.getStackInSlot(0) != null) drops.add(cell.getStackInSlot(0));
final ItemStack container = AEApi.instance().definitions().items().itemMEStackPacket().maybeStack(1).get();
for (int i = 0; i < 9; i++) {
ItemStack ifp = ItemFluidPacket.newStack(invFluids.getFluidStackInSlot(i));
if (ifp != null) drops.add(ifp);
final FluidStack fs = this.invFluids.getFluidStackInSlot(i);
if (fs == null) continue;
final ItemStack temp = container.copy();
Platform.writeStackNBT(AEFluidStack.create(fs), ItemStackNBT.get(temp));
drops.add(temp);
}
for (int i = 0; i < 63; i++) {
final ItemStack is = this.invItems.getStackInSlot(i);
if (is == null) continue;
final ItemStack temp = container.copy();
Platform.writeStackNBT(AEItemStack.create(is), ItemStackNBT.get(temp));
drops.add(temp);
}
super.getDrops(w, x, y, z, drops);
}
@Override
@@ -339,16 +404,12 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
@Override
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) {
FluidStack fs = invFluids.drain(from, resource, doDrain);
if (doDrain && fs != null) storedFluidCount -= fs.amount;
return fs;
return invFluids.drain(from, resource, doDrain);
}
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
FluidStack fs = invFluids.drain(from, maxDrain, doDrain);
if (doDrain && fs != null) storedFluidCount -= fs.amount;
return fs;
return invFluids.drain(from, maxDrain, doDrain);
}
@Override
@@ -368,7 +429,7 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
@Override
public void onFluidInventoryChanged(IAEFluidTank inv, int slot) {
saveChanges();
this.markDirty();
}
@Override
@@ -396,8 +457,6 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
configFluids.readFromNBT(data, "configFluids");
cell.readFromNBT(data, "cellHolder");
totalBytes = data.getLong("totalBytes");
storedFluidCount = data.getLong("storedFluidCount");
storedItemCount = data.getLong("storedItemCount");
getProxy().setIdlePowerUsage(data.getDouble("powerDraw"));
}
@@ -409,8 +468,6 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
configFluids.writeToNBT(data, "configFluids");
cell.writeToNBT(data, "cellHolder");
data.setLong("totalBytes", totalBytes);
data.setLong("storedFluidCount", storedFluidCount);
data.setLong("storedItemCount", storedItemCount);
data.setDouble("powerDraw", getProxy().getIdlePowerUsage());
return data;
}
@@ -482,4 +539,18 @@ public class TileSuperStockReplenisher extends AENetworkInvTile
public IConfigManager getConfigManager() {
return null;
}
@Override
public void saveAEStackInv() {
this.markDirty();
}
@Override
public IAEStackInventory getAEInventoryByName(StorageName name) {
return switch (name) {
case NONE -> this.configFluids;
case CONFIG -> this.configItems;
default -> null;
};
}
}
@@ -1,7 +1,5 @@
package com.glodblock.github.crossmod.thaumcraft;
import javax.annotation.Nullable;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -9,13 +7,10 @@ import net.minecraft.nbt.NBTTagList;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.api.storage.data.AEStackTypeRegistry;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import cpw.mods.fml.common.Optional.Method;
import cpw.mods.fml.common.registry.GameRegistry;
import thaumcraft.api.aspects.Aspect;
import thaumicenergistics.common.items.ItemCraftingAspect;
import thaumicenergistics.common.storage.AEEssentiaStack;
public class ThaumicEnergisticsCrafting {
@@ -37,18 +32,23 @@ public class ThaumicEnergisticsCrafting {
}
public static IAEStack<?> convertItemAspectStack(IAEStack<?> stack) {
if (stack instanceof IAEItemStack ais && isAspectStack(ais.getItemStack())) {
Aspect aspect = getAspect(ais.getItemStack());
if (aspect == null) return stack;
if (AEStackTypeRegistry.getType("essentia") == null) return stack;
return new AEEssentiaStack(aspect, stack.getStackSize());
if (stack instanceof IAEItemStack ais && isAspectStack(ais.getItemStack())) {
String aspectTag = getAspectTag(ais.getItemStack());
if (aspectTag == null || aspectTag.isEmpty()) return stack;
NBTTagCompound tag = new NBTTagCompound();
tag.setString("StackType", "essentia");
tag.setString("AspectTag", aspectTag);
tag.setLong("Cnt", stack.getStackSize());
return IAEStack.fromNBTGeneric(tag);
} else {
return stack;
}
}
@Method(modid = "thaumicenergistics")
private static @Nullable Aspect getAspect(ItemStack stack) {
private static String getAspectTag(ItemStack stack) {
if (stack == null) return null;
if (stack.getItem() == neiAddonAspect) {
@@ -58,11 +58,14 @@ public class ThaumicEnergisticsCrafting {
String aspect = aspects.getCompoundTagAt(0).getString("key");
if (aspect.isEmpty()) return null;
return Aspect.getAspect(aspect);
return aspect;
}
if (stack.getItem() == thaumicEnergisticsAspect) {
return Aspect.getAspect(ItemCraftingAspect.getAspect(stack).getTag());
NBTTagCompound tag = stack.getTagCompound();
if (tag != null && tag.hasKey("Aspect")) {
return tag.getString("Aspect");
}
}
return null;
@@ -432,7 +432,10 @@ public class AEFluidInventory implements IAEFluidTank {
if (doFill) {
if (getFluid() == null) AEFluidInventory.this
.setFluidInSlot(this.slot, AEFluidStack.create(new FluidStack(resource.getFluid(), acc)));
else getFluid().amount += acc;
else {
getFluid().amount += acc;
AEFluidInventory.this.onContentChanged(this.slot);
}
}
return acc;
}
@@ -446,7 +449,10 @@ public class AEFluidInventory implements IAEFluidTank {
if (doDrain) {
if (amt == getFluid().amount) {
AEFluidInventory.this.setFluidInSlot(this.slot, null);
} else getFluid().amount -= amt;
} else {
getFluid().amount -= amt;
AEFluidInventory.this.onContentChanged(this.slot);
}
}
return remove;
}
@@ -175,8 +175,6 @@ public class RecipeLoader implements Runnable {
GameRegistry.findItem("appliedenergistics2", "item.ItemMultiMaterial"),
1,
43);
private static final ItemStack WCT_WIRELESS_TERM = GameRegistry
.findItemStack("ae2wct", "wirelessCraftingTerminal", 1);
public static final ItemStack BUCKET = new ItemStack(Items.bucket, 1);
public static final ItemStack IRON_BAR = new ItemStack(Blocks.iron_bars, 1);
public static final ItemStack AE2_ADVANCED_CARD = new ItemStack(
@@ -711,7 +709,8 @@ public class RecipeLoader implements Runnable {
}
ItemStack[] term = { AE2_WIRELESS_TERMINAL, WIRELESS_PATTERN_TERM.stack(), WIRELESS_INTERFACE_TERM.stack(),
WIRELESS_LEVEL_TERM.stack(), WCT_WIRELESS_TERM };
WIRELESS_LEVEL_TERM.stack(),
ModAndClassUtil.WCT ? GameRegistry.findItemStack("ae2wct", "wirelessCraftingTerminal", 1) : null };
GameRegistry.addShapelessRecipe(
WIRELESS_ULTRA_TERM.stack(),
Arrays.stream(term).filter(Objects::nonNull).toArray());
@@ -4,11 +4,13 @@ import com.glodblock.github.client.render.ItemCertusQuartzTankRender;
import com.glodblock.github.client.render.ItemDropRender;
import com.glodblock.github.client.render.ItemPacketRender;
import com.glodblock.github.client.render.ItemWalrusRender;
import com.glodblock.github.client.render.WalrusRenderer;
public class RenderLoader implements Runnable {
@Override
public void run() {
WalrusRenderer.load();
new ItemDropRender();
new ItemPacketRender();
new ItemWalrusRender();
@@ -9,35 +9,41 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.p455w0rd.wirelesscraftingterminal.items.ItemEnum;
import net.p455w0rd.wirelesscraftingterminal.items.ItemInfinityBooster;
import com.glodblock.github.common.item.ItemBaseWirelessTerminal;
import com.glodblock.github.util.ModAndClassUtil;
import appeng.util.Platform;
import cpw.mods.fml.common.registry.GameRegistry;
public class WirelessTerminalRecipe extends ShapelessRecipes {
private static final ItemStack infinityBoosterCard = ItemEnum.BOOSTER_CARD.getStack();
private static ItemStack infinityBoosterCard;
private final ItemStack installedTerm;
public WirelessTerminalRecipe(ItemStack term) {
super(term, Arrays.asList(term, infinityBoosterCard));
super(term, Arrays.asList(term, getInfinityBoosterCard()));
this.installedTerm = installInfinityBoosterCard(term);
}
@Override
public boolean matches(InventoryCrafting inv, World w) {
ItemStack term = inv.getStackInSlot(0);
ItemStack infinityBoosterCard = inv.getStackInSlot(1);
ItemStack card = inv.getStackInSlot(1);
ItemStack recipeCard = getInfinityBoosterCard();
return term != null && term.getItem() instanceof ItemBaseWirelessTerminal
&& !hasInfinityBoosterCard(term)
&& infinityBoosterCard != null
&& infinityBoosterCard.getItem() instanceof ItemInfinityBooster;
&& card != null
&& recipeCard != null
&& card.getItem() == recipeCard.getItem();
}
public static ItemStack getInfinityBoosterCard() {
return infinityBoosterCard.copy();
if (!ModAndClassUtil.WCT) return null;
if (infinityBoosterCard == null) {
infinityBoosterCard = GameRegistry.findItemStack("ae2wct", "infinityBoosterCard", 1);
}
return infinityBoosterCard == null ? null : infinityBoosterCard.copy();
}
@Override
@@ -1,52 +0,0 @@
package com.glodblock.github.nei;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.nei.object.OrderStack;
public class NEIUtils {
public static List<OrderStack<?>> compress(List<OrderStack<?>> list) {
List<OrderStack<?>> comp = new LinkedList<>();
for (OrderStack<?> orderStack : list) {
if (orderStack == null) continue;
if (orderStack.getStack() instanceof FluidStack) {
comp.add(orderStack);
continue;
}
ItemStack currentStack = (ItemStack) orderStack.getStack();
if (currentStack.stackSize == 0) continue;
boolean find = false;
for (OrderStack<?> storedStack : comp) {
if (storedStack == null || !(storedStack.getStack() instanceof ItemStack firstStack)) continue;
boolean areItemStackEqual = firstStack.isItemEqual(currentStack)
&& ItemStack.areItemStackTagsEqual(firstStack, currentStack);
if (areItemStackEqual
&& (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
find = true;
((ItemStack) storedStack.getStack()).stackSize = firstStack.stackSize + currentStack.stackSize;
}
}
if (!find) {
comp.add(orderStack);
}
}
return comp.stream().filter(Objects::nonNull).collect(Collectors.toList());
}
public static List<OrderStack<?>> clearNull(List<OrderStack<?>> list) {
AtomicInteger i = new AtomicInteger(0);
return list.stream().filter(Objects::nonNull)
.filter(
orderStack -> !(orderStack.getStack() != null && orderStack.getStack() instanceof ItemStack
&& ((ItemStack) orderStack.getStack()).stackSize == 0))
.peek(orderStack -> orderStack.setIndex(i.getAndIncrement())).collect(Collectors.toList());
}
}
@@ -1,22 +0,0 @@
package com.glodblock.github.nei.object;
import java.util.List;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
public interface IRecipeExtractor {
List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs);
List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs);
default List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
return getInputIngredients(rawInputs);
}
default List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe,
int index) {
return getOutputIngredients(rawOutputs);
}
}
@@ -1,6 +0,0 @@
package com.glodblock.github.nei.object;
public interface IRecipeExtractorLegacy extends IRecipeExtractor {
String getClassName();
}
@@ -1,10 +0,0 @@
package com.glodblock.github.nei.object;
public class IllegalOrderStackID extends RuntimeException {
private static final long serialVersionUID = -3782749325355674453L;
public IllegalOrderStackID(int id) {
super("Illegal type id: " + id);
}
}
@@ -1,146 +0,0 @@
package com.glodblock.github.nei.object;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import com.glodblock.github.util.Util;
import codechicken.nei.PositionedStack;
public class OrderStack<T> {
private T RealStack;
private int index;
private ItemStack[] items;
public static final int ITEM = 1;
public static final int FLUID = 2;
public static final int CUSTOM = 3;
public OrderStack(T stack, int order) {
if (stack == null || order < 0)
throw new IllegalArgumentException("Trying to create a null or negative order stack!");
this.RealStack = stack;
this.index = order;
}
public OrderStack(T stack, int order, ItemStack[] items) {
this(stack, order);
if (items.length > 1) {
this.items = items;
}
}
public void putStack(T stack) {
this.RealStack = stack;
}
public void putItems(ItemStack[] items) {
this.items = items;
}
public ItemStack[] getItems() {
return this.items;
}
public final void setIndex(int i) {
this.index = i;
}
public T getStack() {
return RealStack;
}
public int getIndex() {
return index;
}
public static OrderStack<ItemStack> pack(PositionedStack stack, int index) {
if (stack != null && stack.items != null && stack.items.length > 0) {
if (Items.feather.getDamage(stack.items[0]) == OreDictionary.WILDCARD_VALUE) {
ItemStack tmp = stack.items[0].copy();
tmp.setItemDamage(0);
return new OrderStack<>(tmp, index);
} else return new OrderStack<>(stack.items[0].copy(), index);
}
return null;
}
public static OrderStack<?> packFluid(PositionedStack stack, int index) {
if (stack != null && stack.items != null && stack.items.length > 0) {
FluidStack fluid = Util.getFluidFromItem(stack.items[0]);
if (fluid != null) return new OrderStack<>(fluid.copy(), index);
else return pack(stack, index);
}
return null;
}
protected void customNBTWriter(NBTTagCompound buf) {}
protected T customNBTReader(NBTTagCompound buf) {
return null;
}
public final void writeToNBT(NBTTagCompound buf) {
if (RealStack instanceof ItemStack) {
NBTTagCompound tmp = new NBTTagCompound();
tmp.setByte("t", (byte) ITEM);
Util.writeItemStackToNBT(((ItemStack) RealStack), tmp);
// replacement items
if (items != null) {
NBTTagList list = new NBTTagList();
for (ItemStack is : this.items) {
Util.writeItemStackToNBT(is, new NBTTagCompound());
}
tmp.setTag(index + ":", list);
}
buf.setTag(index + ":", tmp);
} else if (RealStack instanceof FluidStack) {
NBTTagCompound tmp = new NBTTagCompound();
tmp.setByte("t", (byte) FLUID);
((FluidStack) RealStack).writeToNBT(tmp);
buf.setTag(index + ":", tmp);
} else {
NBTTagCompound tmp = new NBTTagCompound();
tmp.setByte("t", (byte) CUSTOM);
customNBTWriter(tmp);
buf.setTag(index + ":", tmp);
}
}
public static OrderStack<?> readFromNBT(NBTTagCompound buf, @Nullable OrderStack<?> dummy, int index) {
if (!buf.hasKey(index + ":")) return null;
NBTTagCompound info = buf.getCompoundTag(index + ":");
byte id = info.getByte("t");
switch (id) {
case ITEM -> {
List<ItemStack> list = new ArrayList<>();
if (info.hasKey(index + ":")) {
NBTTagList items = info.getTagList(index + ":", 10);
for (int x = 0; x < items.tagCount(); x++) {
final NBTTagCompound item = items.getCompoundTagAt(x);
list.add(Util.loadItemStackFromNBT(item));
}
}
return new OrderStack<>(Util.loadItemStackFromNBT(info), index, list.toArray(new ItemStack[0]));
}
case FLUID -> {
return new OrderStack<>(FluidStack.loadFluidStackFromNBT(info), index);
}
case CUSTOM -> {
if (dummy == null) throw new IllegalOrderStackID(id);
return new OrderStack<>(dummy.customNBTReader(buf), index);
}
default -> throw new IllegalOrderStackID(id);
}
}
}
@@ -1,123 +0,0 @@
package com.glodblock.github.nei.recipes;
import java.util.Collection;
import com.glodblock.github.nei.recipes.extractor.AvaritiaRecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.EnderIORecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.ForestryRecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.GTPPRecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.GregTech5RecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.GregTech6RecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.IndustrialCraftRecipeExtractor;
import com.glodblock.github.nei.recipes.extractor.VanillaRecipeExtractor;
import com.glodblock.github.util.ModAndClassUtil;
import forestry.factory.recipes.nei.NEIHandlerBottler;
import forestry.factory.recipes.nei.NEIHandlerCarpenter;
import forestry.factory.recipes.nei.NEIHandlerCentrifuge;
import forestry.factory.recipes.nei.NEIHandlerFabricator;
import forestry.factory.recipes.nei.NEIHandlerFermenter;
import forestry.factory.recipes.nei.NEIHandlerMoistener;
import forestry.factory.recipes.nei.NEIHandlerSqueezer;
import forestry.factory.recipes.nei.NEIHandlerStill;
import gregapi.recipes.Recipe;
public class DefaultExtractorLoader implements Runnable {
@Override
public void run() {
FluidRecipe.addRecipeMap("smelting", new VanillaRecipeExtractor(false));
FluidRecipe.addRecipeMap("brewing", new VanillaRecipeExtractor(false));
FluidRecipe.addRecipeMap("crafting", new VanillaRecipeExtractor(true));
FluidRecipe.addRecipeMap("crafting2x2", new VanillaRecipeExtractor(true));
if (ModAndClassUtil.GT5) {
try {
Class<?> recipeMapClazz = Class.forName("gregtech.api.util.GTRecipe$GT_Recipe_Map");
Collection<?> sMappings = (Collection<?>) recipeMapClazz.getDeclaredField("sMappings").get(null);
for (Object tMap : sMappings) {
String mNEIName = (String) recipeMapClazz.getDeclaredField("mNEIName").get(tMap);
FluidRecipe.addRecipeMap(
mNEIName,
new GregTech5RecipeExtractor(
mNEIName.equals("gt.recipe.scanner")
|| mNEIName.equals("gt.recipe.fakeAssemblylineProcess")));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
if (ModAndClassUtil.GT6) {
for (Recipe.RecipeMap tMap : Recipe.RecipeMap.RECIPE_MAPS.values()) {
FluidRecipe.addRecipeMap(tMap.mNameNEI, new GregTech6RecipeExtractor(tMap));
}
}
if (ModAndClassUtil.GTPP && !ModAndClassUtil.GT5NH) {
try {
Class<?> gtRecipeMapClazz = Class.forName("gregtech.api.util.GT_Recipe$GT_Recipe_Map");
Class<?> gtppRecipeMapClazz = Class.forName("gregtech.api.util.GTPP_Recipe$GTPP_Recipe_Map_Internal");
Collection<?> sMappingsEx = (Collection<?>) gtppRecipeMapClazz.getDeclaredField("sMappingsEx")
.get(null);
for (Object gtppMap : sMappingsEx) {
boolean mNEIAllowed = gtRecipeMapClazz.getDeclaredField("mNEIAllowed").getBoolean(gtppMap);
if (mNEIAllowed) {
String mNEIName = (String) gtRecipeMapClazz.getDeclaredField("mNEIName").get(gtppMap);
FluidRecipe.addRecipeMap(mNEIName, new GTPPRecipeExtractor());
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
if (ModAndClassUtil.EIO) {
FluidRecipe.addRecipeMap("EIOEnchanter", new EnderIORecipeExtractor());
FluidRecipe.addRecipeMap("EnderIOAlloySmelter", new EnderIORecipeExtractor());
FluidRecipe.addRecipeMap("EnderIOSagMill", new EnderIORecipeExtractor());
FluidRecipe.addRecipeMap("EnderIOSliceAndSplice", new EnderIORecipeExtractor());
FluidRecipe.addRecipeMap("EnderIOSoulBinder", new EnderIORecipeExtractor());
FluidRecipe.addRecipeMap("EnderIOVat", new EnderIORecipeExtractor());
}
if (ModAndClassUtil.AVARITIA) {
FluidRecipe.addRecipeMap("extreme", new AvaritiaRecipeExtractor());
}
if (ModAndClassUtil.FTR) {
// GTNH
FluidRecipe.addRecipeMap("forestry.bottler", new ForestryRecipeExtractor(new NEIHandlerBottler()));
FluidRecipe.addRecipeMap("forestry.carpenter", new ForestryRecipeExtractor(new NEIHandlerCarpenter()));
FluidRecipe.addRecipeMap("forestry.centrifuge", new ForestryRecipeExtractor(new NEIHandlerCentrifuge()));
FluidRecipe.addRecipeMap("forestry.fabricator", new ForestryRecipeExtractor(new NEIHandlerFabricator()));
FluidRecipe.addRecipeMap("forestry.fermenter", new ForestryRecipeExtractor(new NEIHandlerFermenter()));
FluidRecipe.addRecipeMap("forestry.moistener", new ForestryRecipeExtractor(new NEIHandlerMoistener()));
FluidRecipe.addRecipeMap("forestry.squeezer", new ForestryRecipeExtractor(new NEIHandlerSqueezer()));
FluidRecipe.addRecipeMap("forestry.still", new ForestryRecipeExtractor(new NEIHandlerStill()));
// LEGACY
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerBottler()));
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerCarpenter()));
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerCentrifuge()));
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerFabricator()));
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerFermenter()));
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerMoistener()));
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerSqueezer()));
FluidRecipe.addRecipeMap(null, new ForestryRecipeExtractor(new NEIHandlerStill()));
}
if (ModAndClassUtil.IC2) {
FluidRecipe.addRecipeMap("blastfurnace", new IndustrialCraftRecipeExtractor());
FluidRecipe.addRecipeMap("BlockCutter", new IndustrialCraftRecipeExtractor());
FluidRecipe.addRecipeMap("centrifuge", new IndustrialCraftRecipeExtractor());
FluidRecipe.addRecipeMap("compressor", new IndustrialCraftRecipeExtractor());
FluidRecipe.addRecipeMap("extractor", new IndustrialCraftRecipeExtractor());
FluidRecipe.addRecipeMap("fluidcanner", new IndustrialCraftRecipeExtractor());
FluidRecipe.addRecipeMap("macerator", new IndustrialCraftRecipeExtractor());
FluidRecipe.addRecipeMap("metalformer", new IndustrialCraftRecipeExtractor());
FluidRecipe.addRecipeMap("oreWashing", new IndustrialCraftRecipeExtractor());
FluidRecipe.addRecipeMap("solidcanner", new IndustrialCraftRecipeExtractor());
}
}
}
@@ -1,108 +0,0 @@
package com.glodblock.github.nei.recipes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.nei.object.IRecipeExtractor;
import com.glodblock.github.nei.object.IRecipeExtractorLegacy;
import com.glodblock.github.nei.object.OrderStack;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import codechicken.nei.recipe.TemplateRecipeHandler;
public final class FluidRecipe {
private static final HashMap<String, IRecipeExtractor> IdentifierMap = new HashMap<>();
private static final HashMap<String, IRecipeExtractor> IdentifierMapLegacy = new HashMap<>();
public static void addRecipeMap(String recipeIdentifier, IRecipeExtractor extractor) {
IdentifierMap.put(recipeIdentifier, extractor);
if (recipeIdentifier == null && extractor instanceof IRecipeExtractorLegacy) {
IdentifierMapLegacy.put(((IRecipeExtractorLegacy) extractor).getClassName(), extractor);
}
}
public static List<OrderStack<?>> getPackageInputs(IRecipeHandler recipe, int index, boolean priority) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
if (tRecipe == null) return new ArrayList<>();
if (!IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return getDefaultPackageInputs(tRecipe, index);
if (tRecipe.getOverlayIdentifier() == null) return getPackageInputsLegacy(recipe, index);
IRecipeExtractor extractor = IdentifierMap.get(tRecipe.getOverlayIdentifier());
if (extractor == null) return new ArrayList<>();
List<PositionedStack> tmp = new ArrayList<>(tRecipe.getIngredientStacks(index));
List<OrderStack<?>> out = extractor.getInputIngredients(tmp, recipe, index);
if (priority) {
List<OrderStack<?>> reordered = new ArrayList<>();
byte numFluids = 0;
for (OrderStack<?> orderStack : out) {
if (orderStack != null && orderStack.getStack() instanceof FluidStack) {
reordered.add(new OrderStack<>(orderStack.getStack(), numFluids++));
}
}
for (OrderStack<?> orderStack : out) {
if (orderStack != null && orderStack.getStack() instanceof ItemStack) {
reordered.add(new OrderStack<>(orderStack.getStack(), numFluids++));
}
}
return reordered;
}
return out;
}
private static List<OrderStack<?>> getDefaultPackageInputs(TemplateRecipeHandler tRecipe, int index) {
List<OrderStack<?>> tmp = new LinkedList<>();
AtomicInteger i = new AtomicInteger(0);
tRecipe.getIngredientStacks(index)
.forEach(ps -> tmp.add(new OrderStack<>(ps.item, i.getAndIncrement(), ps.items)));
return tmp;
}
private static List<OrderStack<?>> getDefaultPackageOutputs(TemplateRecipeHandler tRecipe, int index) {
List<OrderStack<?>> tmp = new LinkedList<>();
AtomicInteger i = new AtomicInteger(0);
tmp.add(new OrderStack<>(tRecipe.getResultStack(index).item, i.getAndIncrement()));
tRecipe.getOtherStacks(index).forEach(ps -> tmp.add(new OrderStack<>(ps.item, i.getAndIncrement())));
return tmp;
}
public static List<OrderStack<?>> getPackageOutputs(IRecipeHandler recipe, int index, boolean useOther) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
if (tRecipe == null) return new ArrayList<>();
if (!IdentifierMap.containsKey(tRecipe.getOverlayIdentifier())) return getDefaultPackageOutputs(tRecipe, index);
if (tRecipe.getOverlayIdentifier() == null) return getPackageOutputsLegacy(recipe, index, useOther);
IRecipeExtractor extractor = IdentifierMap.get(tRecipe.getOverlayIdentifier());
if (extractor == null) return new ArrayList<>();
List<PositionedStack> tmp = new ArrayList<>(Collections.singleton(tRecipe.getResultStack(index)));
if (useOther) tmp.addAll(tRecipe.getOtherStacks(index));
return extractor.getOutputIngredients(tmp, recipe, index);
}
public static List<String> getSupportRecipes() {
return new ArrayList<>(IdentifierMap.keySet());
}
public static List<OrderStack<?>> getPackageInputsLegacy(IRecipeHandler recipe, int index) {
if (recipe == null || !IdentifierMapLegacy.containsKey(recipe.getClass().getName())) return new ArrayList<>();
IRecipeExtractor extractor = IdentifierMapLegacy.get(recipe.getClass().getName());
if (extractor == null) return new ArrayList<>();
List<PositionedStack> tmp = new ArrayList<>(recipe.getIngredientStacks(index));
return extractor.getInputIngredients(tmp, recipe, index);
}
public static List<OrderStack<?>> getPackageOutputsLegacy(IRecipeHandler recipe, int index, boolean useOther) {
if (recipe == null || !IdentifierMapLegacy.containsKey(recipe.getClass().getName())) return new ArrayList<>();
IRecipeExtractor extractor = IdentifierMapLegacy.get(recipe.getClass().getName());
if (extractor == null) return new ArrayList<>();
List<PositionedStack> tmp = new ArrayList<>(Collections.singleton(recipe.getResultStack(index)));
if (useOther) tmp.addAll(recipe.getOtherStacks(index));
return extractor.getOutputIngredients(tmp, recipe, index);
}
}
@@ -1,36 +0,0 @@
package com.glodblock.github.nei.recipes.extractor;
import java.util.List;
import com.glodblock.github.nei.NEIUtils;
import com.glodblock.github.nei.object.IRecipeExtractor;
import com.glodblock.github.nei.object.OrderStack;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
public class AvaritiaRecipeExtractor implements IRecipeExtractor {
public AvaritiaRecipeExtractor() {}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
return getInputIngredients(rawInputs);
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe,
int index) {
return getOutputIngredients(rawOutputs);
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
return NEIUtils.compress(ExtractorUtil.packItemStack(rawInputs));
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
return ExtractorUtil.packItemStack(rawOutputs);
}
}
@@ -1,104 +0,0 @@
package com.glodblock.github.nei.recipes.extractor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.nei.object.IRecipeExtractor;
import com.glodblock.github.nei.object.OrderStack;
import com.glodblock.github.util.Ae2Reflect;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import codechicken.nei.recipe.TemplateRecipeHandler;
import crazypants.enderio.machine.crusher.CrusherRecipeManager;
import crazypants.enderio.nei.VatRecipeHandler;
public class EnderIORecipeExtractor implements IRecipeExtractor {
public EnderIORecipeExtractor() {}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
return ExtractorUtil.packItemStack(rawInputs);
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
return ExtractorUtil.packItemStack(rawOutputs);
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
List<OrderStack<?>> tmp;
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe vatRecipe) {
ArrayList<PositionedStack> inputs = ReflectEIO.getInputs(vatRecipe);
tmp = ExtractorUtil.packItemStack(inputs);
FluidStack in = ReflectEIO.getInputFluid(vatRecipe);
if (in != null) {
tmp.add(new OrderStack<>(in, inputs.size()));
}
return tmp;
} else if (tRecipe.getOverlayIdentifier().equals("EnderIOSagMill")) {
for (int i = rawInputs.size() - 1; i >= 0; i--) {
PositionedStack stack = rawInputs.get(i);
if (stack != null && CrusherRecipeManager.getInstance().isValidSagBall(stack.items[0])) {
rawInputs.remove(i);
break;
}
}
return getInputIngredients(rawInputs);
} else {
return getInputIngredients(rawInputs);
}
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe,
int index) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
List<OrderStack<?>> tmp = new LinkedList<>();
if (tRecipe.arecipes.get(index) instanceof VatRecipeHandler.InnerVatRecipe vatRecipe) {
FluidStack result = ReflectEIO.getResult(vatRecipe);
if (result != null) {
tmp.add(new OrderStack<>(result, 0));
}
return tmp;
} else {
return getOutputIngredients(rawOutputs);
}
}
private static class ReflectEIO {
private static final Field inputsF;
private static final Field resultF;
private static final Field inFluidF;
static {
try {
inputsF = Ae2Reflect.reflectField(VatRecipeHandler.InnerVatRecipe.class, "inputs");
resultF = Ae2Reflect.reflectField(VatRecipeHandler.InnerVatRecipe.class, "result");
inFluidF = Ae2Reflect.reflectField(VatRecipeHandler.InnerVatRecipe.class, "inFluid");
} catch (NoSuchFieldException e) {
throw new IllegalStateException("Failed to initialize EIO reflection hacks!", e);
}
}
private static ArrayList<PositionedStack> getInputs(VatRecipeHandler.InnerVatRecipe vat) {
return Ae2Reflect.readField(vat, inputsF);
}
private static FluidStack getResult(VatRecipeHandler.InnerVatRecipe vat) {
return Ae2Reflect.readField(vat, resultF);
}
private static FluidStack getInputFluid(VatRecipeHandler.InnerVatRecipe vat) {
return Ae2Reflect.readField(vat, inFluidF);
}
}
}
@@ -1,32 +0,0 @@
package com.glodblock.github.nei.recipes.extractor;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;
import com.glodblock.github.nei.object.OrderStack;
import codechicken.nei.PositionedStack;
public final class ExtractorUtil {
public static List<OrderStack<?>> packItemStack(List<PositionedStack> items) {
AtomicInteger index = new AtomicInteger(-1);
return items.stream().map(item -> {
index.getAndIncrement();
return OrderStack.pack(item, index.get());
}).filter(Objects::nonNull).collect(Collectors.toList());
}
public static List<OrderStack<?>> packItemStack(List<PositionedStack> items,
Function<PositionedStack, Object> transformer) {
AtomicInteger index = new AtomicInteger(-1);
return items.stream().map(item -> {
index.getAndIncrement();
Object o = transformer.apply(item);
return o != null ? new OrderStack<>(o, index.get(), item.items) : null;
}).filter(Objects::nonNull).collect(Collectors.toList());
}
}
@@ -1,90 +0,0 @@
package com.glodblock.github.nei.recipes.extractor;
import java.util.ArrayList;
import java.util.List;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.nei.object.IRecipeExtractorLegacy;
import com.glodblock.github.nei.object.OrderStack;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import codechicken.nei.recipe.TemplateRecipeHandler;
import forestry.core.recipes.nei.PositionedFluidTank;
import forestry.core.recipes.nei.RecipeHandlerBase;
import forestry.factory.recipes.nei.NEIHandlerFabricator;
import forestry.factory.recipes.nei.NEIHandlerSqueezer;
public class ForestryRecipeExtractor implements IRecipeExtractorLegacy {
private final IRecipeHandler handler;
public ForestryRecipeExtractor(IRecipeHandler recipes) {
handler = recipes;
}
@Override
public String getClassName() {
return handler.getClass().getName();
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
return ExtractorUtil.packItemStack(rawInputs);
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
return ExtractorUtil.packItemStack(rawOutputs);
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
List<OrderStack<?>> tmp = new ArrayList<>();
if (tRecipe.arecipes.get(index) instanceof RecipeHandlerBase.CachedBaseRecipe) {
tmp = getInputIngredients(rawInputs);
List<PositionedFluidTank> tanks = ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index))
.getFluidTanks();
if (tanks.size() > 0 && !(handler instanceof NEIHandlerSqueezer)) {
FluidStack fluid = tanks.get(0).tank.getFluid();
if (fluid != null) {
tmp.add(new OrderStack<>(fluid, rawInputs.size()));
}
}
}
return tmp;
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe,
int index) {
TemplateRecipeHandler tRecipe = (TemplateRecipeHandler) recipe;
removeGlass(rawOutputs);
List<OrderStack<?>> tmp = new ArrayList<>();
if (tRecipe.arecipes.get(index) instanceof RecipeHandlerBase.CachedBaseRecipe) {
tmp = getOutputIngredients(rawOutputs);
List<PositionedFluidTank> tanks = ((RecipeHandlerBase.CachedBaseRecipe) tRecipe.arecipes.get(index))
.getFluidTanks();
if (tanks.size() > 0 && handler instanceof NEIHandlerSqueezer) {
FluidStack fluid = tanks.get(0).tank.getFluid();
if (fluid != null) {
tmp.add(new OrderStack<>(fluid, rawOutputs.size()));
}
} else if (tanks.size() > 1) {
FluidStack fluid = tanks.get(1).tank.getFluid();
if (fluid != null) {
tmp.add(new OrderStack<>(fluid, rawOutputs.size()));
}
}
}
return tmp;
}
private void removeGlass(List<PositionedStack> list) {
if (handler instanceof NEIHandlerFabricator) {
list.remove(list.size() - 1);
}
}
}
@@ -1,8 +0,0 @@
package com.glodblock.github.nei.recipes.extractor;
public class GTPPRecipeExtractor extends GregTech5RecipeExtractor {
public GTPPRecipeExtractor() {
super(false);
}
}
@@ -1,62 +0,0 @@
package com.glodblock.github.nei.recipes.extractor;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.nei.object.IRecipeExtractor;
import com.glodblock.github.nei.object.OrderStack;
import codechicken.nei.PositionedStack;
import gregtech.api.enums.ItemList;
import gregtech.common.items.ItemFluidDisplay;
public class GregTech5RecipeExtractor implements IRecipeExtractor {
boolean removeSpecial;
public GregTech5RecipeExtractor(boolean removeSpecial) {
this.removeSpecial = removeSpecial;
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
if (removeSpecial) removeSpecial(rawInputs);
return ExtractorUtil.packItemStack(rawInputs, GregTech5RecipeExtractor::getFluidFromDisplay);
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
return ExtractorUtil.packItemStack(rawOutputs, GregTech5RecipeExtractor::getFluidFromDisplay);
}
private void removeSpecial(List<PositionedStack> list) {
for (int i = list.size() - 1; i >= 0; i--) {
PositionedStack positionedStack = list.get(i);
if (positionedStack != null && (positionedStack.items[0].isItemEqual(ItemList.Tool_DataStick.get(1))
|| positionedStack.items[0].isItemEqual(ItemList.Tool_DataOrb.get(1)))) {
list.remove(i);
break;
}
}
}
public static Object getFluidFromDisplay(PositionedStack stack) {
if (stack != null) {
ItemStack item = stack.items[0].copy();
if (item.getItem() instanceof ItemFluidDisplay) {
if (item.getTagCompound() != null) {
Fluid fluid = FluidRegistry.getFluid(item.getItemDamage());
int amt = (int) item.getTagCompound().getLong("mFluidDisplayAmount");
return amt > 0 && fluid != null ? new FluidStack(fluid, amt) : null;
}
} else {
return item;
}
}
return null;
}
}
@@ -1,62 +0,0 @@
package com.glodblock.github.nei.recipes.extractor;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.nei.object.IRecipeExtractor;
import com.glodblock.github.nei.object.OrderStack;
import codechicken.nei.PositionedStack;
import gregapi.item.ItemFluidDisplay;
import gregapi.recipes.Recipe;
public class GregTech6RecipeExtractor implements IRecipeExtractor {
private final Recipe.RecipeMap Recipes;
public GregTech6RecipeExtractor(Recipe.RecipeMap aMap) {
Recipes = aMap;
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
this.removeMachine(rawInputs);
return ExtractorUtil.packItemStack(rawInputs, GregTech6RecipeExtractor::getFluidFromDisplay);
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
return ExtractorUtil.packItemStack(rawOutputs, GregTech6RecipeExtractor::getFluidFromDisplay);
}
private void removeMachine(List<PositionedStack> list) {
for (int i = list.size() - 1; i >= 0; i--) {
PositionedStack positionedStack = list.get(i);
if (positionedStack != null) {
for (ItemStack machine : this.Recipes.mRecipeMachineList) {
if (positionedStack.items[0].isItemEqual(machine)) {
list.remove(i);
break;
}
}
}
}
}
public static Object getFluidFromDisplay(PositionedStack stack) {
if (stack != null) {
ItemStack item = stack.items[0].copy();
if (item.getItem() instanceof ItemFluidDisplay) {
if (item.getTagCompound() != null) {
FluidStack fluid = ((ItemFluidDisplay) item.getItem()).getFluid(item);
return fluid != null && fluid.amount > 0 ? fluid : null;
}
} else {
return item;
}
}
return null;
}
}
@@ -1,107 +0,0 @@
package com.glodblock.github.nei.recipes.extractor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import com.glodblock.github.nei.object.IRecipeExtractor;
import com.glodblock.github.nei.object.OrderStack;
import com.glodblock.github.util.Ae2Reflect;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.IRecipeHandler;
import ic2.neiIntegration.core.recipehandler.FluidCannerRecipeHandler;
import ic2.neiIntegration.core.recipehandler.OreWashingRecipeHandler;
public class IndustrialCraftRecipeExtractor implements IRecipeExtractor {
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
return ExtractorUtil.packItemStack(rawInputs);
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
return ExtractorUtil.packItemStack(rawOutputs);
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs, IRecipeHandler recipe, int index) {
List<OrderStack<?>> stacks = new LinkedList<>();
if (recipe instanceof FluidCannerRecipeHandler) {
FluidCannerRecipeHandler.CachedFluidCannerRecipe cachedRecipe = (FluidCannerRecipeHandler.CachedFluidCannerRecipe) ((FluidCannerRecipeHandler) recipe).arecipes
.get(index);
FluidStack input = ReflectIC2.getInputFluid(cachedRecipe);
PositionedStack add = rawInputs.size() > 1 ? rawInputs.get(1) : null;
stacks.add(OrderStack.pack(add, 0));
stacks.add(new OrderStack<>(input, 1));
} else if (recipe instanceof OreWashingRecipeHandler) {
stacks = getInputIngredients(rawInputs);
int water = ReflectIC2.getOreWasherWater((OreWashingRecipeHandler) recipe, index);
stacks.add(new OrderStack<>(new FluidStack(FluidRegistry.WATER, water), stacks.size()));
} else {
stacks = getInputIngredients(rawInputs);
}
return stacks.stream().filter(Objects::nonNull).collect(Collectors.toList());
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs, IRecipeHandler recipe,
int index) {
List<OrderStack<?>> stacks = new LinkedList<>();
if (recipe instanceof FluidCannerRecipeHandler) {
FluidCannerRecipeHandler.CachedFluidCannerRecipe cachedRecipe = (FluidCannerRecipeHandler.CachedFluidCannerRecipe) ((FluidCannerRecipeHandler) recipe).arecipes
.get(index);
FluidStack output = ReflectIC2.getOutputFluid(cachedRecipe);
stacks.add(new OrderStack<>(output, 0));
} else {
stacks = getOutputIngredients(rawOutputs);
}
return stacks.stream().filter(Objects::nonNull).collect(Collectors.toList());
}
private static class ReflectIC2 {
private static final Field inputsF;
private static final Field resultF;
private static final Method oreWasherWater;
static {
try {
inputsF = Ae2Reflect.reflectField(FluidCannerRecipeHandler.CachedFluidCannerRecipe.class, "fluidInput");
resultF = Ae2Reflect
.reflectField(FluidCannerRecipeHandler.CachedFluidCannerRecipe.class, "fluidOutput");
oreWasherWater = Ae2Reflect.reflectMethod(OreWashingRecipeHandler.class, "getreqWater", int.class);
} catch (NoSuchFieldException | NoSuchMethodException e) {
throw new IllegalStateException("Failed to initialize IC2 reflection hacks!", e);
}
}
private static FluidStack getInputFluid(FluidCannerRecipeHandler.CachedFluidCannerRecipe recipe) {
return Ae2Reflect.readField(recipe, inputsF);
}
private static FluidStack getOutputFluid(FluidCannerRecipeHandler.CachedFluidCannerRecipe recipe) {
return Ae2Reflect.readField(recipe, resultF);
}
private static int getOreWasherWater(OreWashingRecipeHandler recipeHandler, int index) {
try {
return (int) oreWasherWater.invoke(recipeHandler, index);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + oreWasherWater, e);
}
}
}
}
@@ -1,37 +0,0 @@
package com.glodblock.github.nei.recipes.extractor;
import java.util.LinkedList;
import java.util.List;
import com.glodblock.github.nei.object.IRecipeExtractor;
import com.glodblock.github.nei.object.OrderStack;
import codechicken.nei.PositionedStack;
public class VanillaRecipeExtractor implements IRecipeExtractor {
private final boolean c;
public VanillaRecipeExtractor(boolean isCraft) {
c = isCraft;
}
@Override
public List<OrderStack<?>> getInputIngredients(List<PositionedStack> rawInputs) {
List<OrderStack<?>> tmp = new LinkedList<>();
for (int i = 0; i < rawInputs.size(); i++) {
if (rawInputs.get(i) == null) continue;
final int col = (rawInputs.get(i).relx - 25) / 18;
final int row = (rawInputs.get(i).rely - 6) / 18;
int index = col + row * 3;
OrderStack<?> stack = OrderStack.pack(rawInputs.get(i), c ? index : i);
if (stack != null) tmp.add(stack);
}
return tmp;
}
@Override
public List<OrderStack<?>> getOutputIngredients(List<PositionedStack> rawOutputs) {
return getInputIngredients(rawOutputs);
}
}
@@ -72,8 +72,9 @@ public class CPacketValueConfig implements IMessage {
: NameConst.TT_ULTRA_TERMINAL_RESTOCK_OFF)));
} else {
IGridNode gridNode = Util.getWirelessGrid(wirelessTerm);
if (gridNode != null && Util.isRestock(wirelessTerm)
&& Util.rangeCheck(wirelessTerm, player, gridNode)) {
boolean inRange = AEApi.instance().registries().wireless().checkRange(wirelessTerm, player);
if (gridNode != null && Util.isRestock(wirelessTerm) && inRange) {
restockItems(wirelessTerm, gridNode, result.getLeft(), player);
}
}
@@ -4,8 +4,6 @@ import static com.glodblock.github.common.Config.reStockTime;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -13,13 +11,10 @@ import com.glodblock.github.FluidCraft;
import com.glodblock.github.loader.KeybindLoader;
import com.glodblock.github.loader.ListenerLoader;
import com.glodblock.github.loader.RenderLoader;
import com.glodblock.github.nei.recipes.DefaultExtractorLoader;
import com.glodblock.github.network.CPacketValueConfig;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.Util;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -29,7 +24,6 @@ public class ClientProxy extends CommonProxy {
private static final Minecraft mc = Minecraft.getMinecraft();
private static long refreshTick = System.currentTimeMillis();
private static IModelCustom modelWalrus;
@Override
public void preInit(FMLPreInitializationEvent event) {
@@ -42,7 +36,6 @@ public class ClientProxy extends CommonProxy {
(new ListenerLoader()).run();
(new RenderLoader()).run();
(new KeybindLoader()).run();
modelWalrus = AdvancedModelLoader.loadModel(FluidCraft.resource("models/walrus.obj"));
}
@Override
@@ -50,14 +43,6 @@ public class ClientProxy extends CommonProxy {
super.postInit(event);
}
@Override
public void onLoadComplete(FMLLoadCompleteEvent event) {
super.onLoadComplete(event);
if (ModAndClassUtil.NEI) {
new DefaultExtractorLoader().run();
}
}
@SubscribeEvent
public void tickEvent(TickEvent.PlayerTickEvent e) {
if (refreshTick + reStockTime < System.currentTimeMillis()) {
@@ -69,8 +54,4 @@ public class ClientProxy extends CommonProxy {
refreshTick = System.currentTimeMillis();
}
}
public static IModelCustom getWalrusModel() {
return modelWalrus;
}
}
@@ -3,7 +3,6 @@ package com.glodblock.github.proxy;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
@@ -54,7 +53,6 @@ public class CommonProxy {
EntityPlayer player = e.entityPlayer;
EntityItem itemEntity = e.item;
ItemStack stack = itemEntity.getEntityItem();
World world = player.getEntityWorld();
ImmutablePair<Integer, ItemStack> result = Util.getUltraWirelessTerm(player);
if (result != null) {
@@ -62,7 +60,9 @@ public class CommonProxy {
WirelessMagnet.Mode mode = WirelessMagnet.getMode(wirelessTerm);
if (mode == WirelessMagnet.Mode.ME) {
IGridNode gridNode = Util.getWirelessGrid(wirelessTerm);
if (gridNode != null && Util.rangeCheck(wirelessTerm, player, gridNode)) {
boolean inRange = AEApi.instance().registries().wireless().checkRange(wirelessTerm, player);
if (gridNode != null && inRange) {
WirelessMagnetCardFilterInventory inv = FilterCache
.getFilter(wirelessTerm, result.getLeft(), gridNode, player);
@@ -38,7 +38,6 @@ import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.SecurityPermissions;
import appeng.api.implementations.tiles.IWirelessAccessPoint;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
import appeng.api.networking.IGridNode;
@@ -50,12 +49,10 @@ import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.container.AEBaseContainer;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.me.storage.NullInventory;
import appeng.tile.networking.TileCableBus;
import appeng.tile.networking.TileWireless;
import appeng.util.Platform;
import appeng.util.item.AEFluidStack;
import appeng.util.item.AEItemStack;
@@ -105,32 +102,6 @@ public final class Util {
return ticks;
}
public static boolean rangeCheck(ItemStack is, EntityPlayer player, IGridNode grid) {
if (grid.getGrid() == null) return false;
return rangeCheck(is, player, grid.getGrid());
}
public static boolean rangeCheck(ItemStack is, EntityPlayer player, IGrid grid) {
boolean canConnect = false;
if (hasInfinityBoosterCard(is)) {
canConnect = true;
} else {
for (IGridNode node : grid.getMachines(TileWireless.class)) {
IWirelessAccessPoint accessPoint = (IWirelessAccessPoint) node.getMachine();
if (accessPoint.isActive() && accessPoint.getLocation().getDimension() == player.dimension) {
WorldCoord distance = accessPoint.getLocation()
.subtract((int) player.posX, (int) player.posY, (int) player.posZ);
int squaredDistance = distance.x * distance.x + distance.y * distance.y + distance.z * distance.z;
if (squaredDistance <= accessPoint.getRange() * accessPoint.getRange()) {
canConnect = true;
break;
}
}
}
}
return canConnect;
}
public static boolean isRestock(ItemStack is) {
if (is.getItem() instanceof ItemBaseWirelessTerminal) {
NBTTagCompound data = Platform.openNbtData(is);
@@ -155,8 +126,8 @@ public final class Util {
}
public static IGridNode getWirelessGrid(ItemStack is) {
if (is.getItem() instanceof ToolWirelessTerminal) {
String key = ((ToolWirelessTerminal) is.getItem()).getEncryptionKey(is);
if (is.getItem() instanceof ToolWirelessTerminal wirelessTerminal) {
String key = wirelessTerminal.getEncryptionKey(is);
IGridHost securityTerminal = (IGridHost) AEApi.instance().registries().locatable()
.getLocatableBy(Long.parseLong(key));
if (securityTerminal == null) return null;
@@ -166,26 +137,27 @@ public final class Util {
}
public static IMEInventoryHandler<?> getWirelessInv(ItemStack is, EntityPlayer player, StorageChannel channel) {
if (Platform.isServer()) {
IGridNode gridNode = getWirelessGrid(is);
if (gridNode != null) {
IGrid grid = gridNode.getGrid();
if (grid != null) {
if (rangeCheck(is, player, grid)) {
IStorageGrid gridCache = grid.getCache(IStorageGrid.class);
if (gridCache != null) {
if (channel == StorageChannel.FLUIDS) {
return gridCache.getFluidInventory();
} else {
return gridCache.getItemInventory();
}
}
}
if (Platform.isClient()) return new NullInventory<>();
IGridNode gridNode = getWirelessGrid(is);
if (gridNode == null) return null;
IGrid grid = gridNode.getGrid();
if (grid == null) return null;
boolean inRange = AEApi.instance().registries().wireless().checkRange(is, player);
if (inRange) {
IStorageGrid gridCache = grid.getCache(IStorageGrid.class);
if (gridCache != null) {
if (channel == StorageChannel.FLUIDS) {
return gridCache.getFluidInventory();
} else {
return gridCache.getItemInventory();
}
}
return null;
}
return new NullInventory<>();
return null;
}
public static ImmutablePair<Integer, ItemStack> getUltraWirelessTerm(EntityPlayer player) {