wireless crafting terminal

This commit is contained in:
GlodBlock committed 2023-02-04 18:27:16 +08:00
1 parent 513af871aa
commit f22bebbf21
33 files changed
+695 -215

No files matched your search

@@ -239,12 +239,25 @@ public enum GuiType {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerPatternPortableCell(player.inventory, inv);
return new ContainerFluidPatternWireless(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiPatternPortableCell(player.inventory, inv);
return new GuiFluidPatternWireless(player.inventory, inv);
}
}),
WIRELESS_CRAFTING_TERMINAL(new ItemGuiFactory<IWirelessTerminal>(IWirelessTerminal.class) {
@Override
protected Object createServerGui(EntityPlayer player, IWirelessTerminal inv) {
return new ContainerCraftingWireless(player.inventory, inv);
}
@Override
protected Object createClientGui(EntityPlayer player, IWirelessTerminal inv) {
return new GuiFluidCraftingWireless(player.inventory, inv);
}
}),
@@ -1,15 +1,11 @@
package com.glodblock.github.inventory.item;
import net.minecraft.inventory.IInventory;
import appeng.api.storage.data.IAEItemStack;
public interface PatternTerminal {
public interface IItemPatternTerminal extends IItemTerminal {
boolean isInverted();
IInventory getInventoryByName(final String name);
boolean canBeSubstitute();
boolean isPrioritize();
@@ -39,6 +35,4 @@ public interface PatternTerminal {
boolean isCraftingRecipe();
void sortCraftingItems();
default void saveSettings() {}
}
@@ -0,0 +1,11 @@
package com.glodblock.github.inventory.item;
import net.minecraft.inventory.IInventory;
public interface IItemTerminal {
IInventory getInventoryByName(final String name);
default void saveSettings() {}
}
@@ -0,0 +1,5 @@
package com.glodblock.github.inventory.item;
public interface IWirelessCraftTerminal extends IWirelessTerminal, IItemTerminal {
}
@@ -1,5 +1,5 @@
package com.glodblock.github.inventory.item;
public interface IWirelessPatternTerminal extends IWirelessTerminal, PatternTerminal {
public interface IWirelessPatternTerminal extends IWirelessTerminal, IItemPatternTerminal {
}
@@ -0,0 +1,151 @@
package com.glodblock.github.inventory.item;
import java.util.Objects;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.*;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.networking.IGridNode;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.MEMonitorHandler;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.IConfigManager;
import appeng.items.contents.WirelessTerminalViewCells;
import appeng.items.tools.powered.ToolWirelessTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.ConfigManager;
import appeng.util.Platform;
import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
import com.glodblock.github.util.Util;
public class WirelessCraftingTerminalInventory extends MEMonitorHandler<IAEItemStack>
implements IWirelessCraftTerminal {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final int inventorySlot;
private final AppEngInternalInventory viewCell;
private final StorageChannel channel;
private final IGridNode grid;
protected AppEngInternalInventory crafting;
protected AppEngInternalInventory output;
@SuppressWarnings("unchecked")
public WirelessCraftingTerminalInventory(final ItemStack is, final int slot, IGridNode gridNode,
EntityPlayer player) {
super(
(IMEInventoryHandler<IAEItemStack>) Objects
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS)));
this.ips = (ToolWirelessTerminal) is.getItem();
this.grid = gridNode;
this.target = is;
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.ITEMS;
this.crafting = new ItemBiggerAppEngInventory(is, "crafting", 9);
this.output = new ItemBiggerAppEngInventory(is, "output", 3);
}
public StorageChannel getChannel() {
return this.channel;
}
@Override
public ItemStack getItemStack() {
return this.target;
}
@Override
public double extractAEPower(double amt, Actionable mode, PowerMultiplier usePowerMultiplier) {
amt = usePowerMultiplier.multiply(amt);
if (mode == Actionable.SIMULATE) {
return usePowerMultiplier.divide(Math.min(amt, this.ips.getAECurrentPower(this.target)));
}
return usePowerMultiplier.divide(this.ips.extractAEPower(this.target, amt));
}
@Override
public IMEMonitor<IAEItemStack> getItemInventory() {
return this;
}
@Override
public IMEMonitor<IAEFluidStack> getFluidInventory() {
return null;
}
@Override
public IConfigManager getConfigManager() {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final NBTTagCompound data = Platform.openNbtData(this.target);
manager.writeToNBT(data);
});
out.registerSetting(Settings.SORT_BY, SortOrder.NAME);
out.registerSetting(Settings.VIEW_MODE, ViewItems.ALL);
out.registerSetting(Settings.SORT_DIRECTION, SortDir.ASCENDING);
out.readFromNBT((NBTTagCompound) Platform.openNbtData(this.target).copy());
return out;
}
@Override
public int getInventorySlot() {
return this.inventorySlot;
}
@Override
public IInventory getViewCellStorage() {
return this.viewCell;
}
@Override
public IGridNode getGridNode(ForgeDirection dir) {
return this.grid;
}
@Override
public AECableType getCableConnectionType(ForgeDirection dir) {
return AECableType.NONE;
}
@Override
public void securityBreak() {
this.getGridNode(ForgeDirection.UNKNOWN).getMachine().securityBreak();
}
@Override
public void saveChanges() {
// NO-OP
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
// NO-OP
}
@Override
public IInventory getInventoryByName(String name) {
if (name.equals("crafting")) {
return this.crafting;
}
if (name.equals("output")) {
return this.output;
}
return null;
}
}
@@ -28,7 +28,7 @@ import appeng.util.Platform;
import com.glodblock.github.util.Util;
public class WirelessFluidTerminal extends MEMonitorHandler<IAEFluidStack> implements IWirelessTerminal {
public class WirelessFluidTerminalInventory extends MEMonitorHandler<IAEFluidStack> implements IWirelessTerminal {
private final ItemStack target;
private final IAEItemPowerStorage ips;
@@ -38,7 +38,7 @@ public class WirelessFluidTerminal extends MEMonitorHandler<IAEFluidStack> imple
private final IGridNode grid;
@SuppressWarnings("unchecked")
public WirelessFluidTerminal(final ItemStack is, final int slot, IGridNode gridNode, EntityPlayer player) {
public WirelessFluidTerminalInventory(final ItemStack is, final int slot, IGridNode gridNode, EntityPlayer player) {
super(
(IMEInventoryHandler<IAEFluidStack>) Objects
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.FLUIDS)));
@@ -33,11 +33,11 @@ import com.glodblock.github.inventory.ItemBiggerAppEngInventory;
import com.glodblock.github.inventory.WirelessFluidPatternTerminalPatterns;
import com.glodblock.github.util.Util;
public class WirelessPatternTerminal extends MEMonitorHandler<IAEItemStack> implements IWirelessPatternTerminal {
public class WirelessPatternTerminalInventory extends MEMonitorHandler<IAEItemStack>
implements IWirelessPatternTerminal {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final EntityPlayer p;
private final int inventorySlot;
private final AppEngInternalInventory viewCell;
private final StorageChannel channel;
@@ -56,14 +56,14 @@ public class WirelessPatternTerminal extends MEMonitorHandler<IAEItemStack> impl
protected int activePage = 0;
@SuppressWarnings("unchecked")
public WirelessPatternTerminal(final ItemStack is, final int slot, IGridNode gridNode, EntityPlayer player) {
public WirelessPatternTerminalInventory(final ItemStack is, final int slot, IGridNode gridNode,
EntityPlayer player) {
super(
(IMEInventoryHandler<IAEItemStack>) Objects
.requireNonNull(Util.getWirelessInv(is, player, StorageChannel.ITEMS)));
this.ips = (ToolWirelessTerminal) is.getItem();
this.grid = gridNode;
this.target = is;
this.p = player;
this.inventorySlot = slot;
this.viewCell = new WirelessTerminalViewCells(is);
this.channel = StorageChannel.ITEMS;
@@ -163,12 +163,14 @@ public class WirelessPatternTerminal extends MEMonitorHandler<IAEItemStack> impl
@Override
public void saveChanges() {
// NO-OP
}
@Override
public void onChangeInventory(IInventory inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {}
ItemStack newStack) {
// NO-OP
}
@Override
public boolean isInverted() {