Start implementing wireless terminals.
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.container.implementations.ContainerWirelessCraftingTerminal;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
|
||||
public class GuiWirelessCraftingTerminal extends GuiMEMonitorable {
|
||||
|
||||
private GuiImgButton clearBtn;
|
||||
|
||||
public GuiWirelessCraftingTerminal(final InventoryPlayer inventoryPlayer, final WirelessTerminalGuiObject te) {
|
||||
super(inventoryPlayer, te, new ContainerWirelessCraftingTerminal(inventoryPlayer, te));
|
||||
this.setReservedSpace(73);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(final GuiButton btn) {
|
||||
super.actionPerformed(btn);
|
||||
|
||||
if (this.clearBtn == btn) {
|
||||
Slot s = null;
|
||||
final Container c = this.inventorySlots;
|
||||
for (final Object j : c.inventorySlots) {
|
||||
if (j instanceof SlotCraftingMatrix) {
|
||||
s = (Slot) j;
|
||||
}
|
||||
}
|
||||
|
||||
if (s != null) {
|
||||
final PacketInventoryAction p = new PacketInventoryAction(InventoryAction.MOVE_REGION, s.slotNumber, 0);
|
||||
NetworkHandler.instance().sendToServer(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.buttonList.add(this.clearBtn = new GuiImgButton(this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.STASH));
|
||||
this.clearBtn.setHalfSize(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
|
||||
super.drawFG(offsetX, offsetY, mouseX, mouseY);
|
||||
this.fontRenderer.drawString(GuiText.CraftingTerminal.getLocal(), 8, this.ySize - 96 + 1 - this.getReservedSpace(), 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBackground() {
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
|
||||
public ItemRepo getRepo() {
|
||||
return this.repo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiWirelessFluidTerminal extends GuiMEPortableCell {
|
||||
|
||||
public GuiWirelessFluidTerminal(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows() {
|
||||
return this.defaultGetMaxRows();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
|
||||
public class GuiWirelessPatternTerminal extends GuiMEPortableCell {
|
||||
|
||||
public GuiWirelessPatternTerminal(final InventoryPlayer inventoryPlayer, final IPortableCell te) {
|
||||
super(inventoryPlayer, te);
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows() {
|
||||
return this.defaultGetMaxRows();
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ package appeng.container.implementations;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
@@ -70,7 +71,7 @@ import java.util.List;
|
||||
|
||||
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigurableObject, IMEMonitorHandlerReceiver<IAEItemStack> {
|
||||
|
||||
private final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
|
||||
protected final SlotRestrictedInput[] cellView = new SlotRestrictedInput[5];
|
||||
private final IMEMonitor<IAEItemStack> monitor;
|
||||
public final IItemList<IAEItemStack> items = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final IConfigManager clientCM;
|
||||
@@ -90,7 +91,11 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa
|
||||
}
|
||||
|
||||
protected ContainerMEMonitorable(final InventoryPlayer ip, final ITerminalHost monitorable, final boolean bindInventory) {
|
||||
super(ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null);
|
||||
this(ip, monitorable, null, bindInventory);
|
||||
}
|
||||
|
||||
protected ContainerMEMonitorable(final InventoryPlayer ip, final ITerminalHost monitorable, final IGuiItemObject iGuiItemObject, final boolean bindInventory) {
|
||||
super(ip, monitorable instanceof TileEntity ? (TileEntity) monitorable : null, monitorable instanceof IPart ? (IPart) monitorable : null, iGuiItemObject);
|
||||
|
||||
this.host = monitorable;
|
||||
this.clientCM = new ConfigManager(this);
|
||||
|
||||
@@ -21,8 +21,10 @@ package appeng.container.implementations;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@@ -31,12 +33,20 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable {
|
||||
|
||||
private double powerMultiplier = 0.5;
|
||||
|
||||
private final IPortableCell civ;
|
||||
protected final IPortableCell civ;
|
||||
private int ticks = 0;
|
||||
private final int slot;
|
||||
|
||||
public ContainerMEPortableCell(final InventoryPlayer ip, final IPortableCell monitorable) {
|
||||
super(ip, monitorable, false);
|
||||
this(ip, monitorable, null, true);
|
||||
}
|
||||
|
||||
public ContainerMEPortableCell(final InventoryPlayer ip, final IPortableCell monitorable, IGuiItemObject iGuiItemObject) {
|
||||
this(ip, monitorable, iGuiItemObject, true);
|
||||
}
|
||||
|
||||
public ContainerMEPortableCell(InventoryPlayer ip, IPortableCell monitorable, IGuiItemObject iGuiItemObject, boolean bindInventory) {
|
||||
super(ip, monitorable, iGuiItemObject, bindInventory);
|
||||
if (monitorable instanceof IInventorySlotAware) {
|
||||
final int slotIndex = ((IInventorySlotAware) monitorable).getInventorySlot();
|
||||
this.lockPlayerInventorySlot(slotIndex);
|
||||
@@ -46,7 +56,9 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable {
|
||||
this.lockPlayerInventorySlot(ip.currentItem);
|
||||
}
|
||||
this.civ = monitorable;
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
if (bindInventory) {
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.IContainerCraftingPacket;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.WrapperInvItemHandler;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
|
||||
|
||||
|
||||
public class ContainerWirelessCraftingTerminal extends ContainerMEPortableCell implements IAEAppEngInventory, IContainerCraftingPacket {
|
||||
|
||||
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
|
||||
|
||||
private final AppEngInternalInventory output = new AppEngInternalInventory(this, 1);
|
||||
private final SlotCraftingMatrix[] craftingSlots = new SlotCraftingMatrix[9];
|
||||
private final SlotCraftingTerm outputSlot;
|
||||
|
||||
private final AppEngInternalInventory craftingGrid = new AppEngInternalInventory(this, 9);
|
||||
|
||||
private IRecipe currentRecipe;
|
||||
|
||||
public ContainerWirelessCraftingTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
|
||||
super(ip, gui, gui, false);
|
||||
this.wirelessTerminalGUIObject = gui;
|
||||
|
||||
final IItemHandler crafting = this.craftingGrid;
|
||||
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int x = 0; x < 3; x++) {
|
||||
this.addSlotToContainer(this.craftingSlots[x + y * 3] = new SlotCraftingMatrix(this, crafting, x + y * 3, 37 + x * 18, -72 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
this.addSlotToContainer(this.outputSlot = new SlotCraftingTerm(this.getPlayerInv().player, this.getActionSource(), this
|
||||
.getPowerSource(), this.civ, crafting, crafting, this.output, 131, -72 + 18, this));
|
||||
|
||||
this.bindPlayerInventory(ip, 0, 0);
|
||||
this.loadFromNBT();
|
||||
|
||||
this.onCraftMatrixChanged(new WrapperInvItemHandler(crafting));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
|
||||
if (Platform.isServer() && this.isValidContainer()) {
|
||||
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
|
||||
}
|
||||
|
||||
this.setValidContainer(false);
|
||||
} else {
|
||||
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inventory) {
|
||||
final ContainerNull cn = new ContainerNull();
|
||||
final InventoryCrafting ic = new InventoryCrafting(cn, 3, 3);
|
||||
|
||||
for (int x = 0; x < 9; x++) {
|
||||
ic.setInventorySlotContents(x, this.craftingSlots[x].getStack());
|
||||
}
|
||||
|
||||
if (this.currentRecipe == null || !this.currentRecipe.matches(ic, this.getPlayerInv().player.world)) {
|
||||
this.currentRecipe = CraftingManager.findMatchingRecipe(ic, this.getPlayerInv().player.world);
|
||||
}
|
||||
|
||||
if (this.currentRecipe == null) {
|
||||
this.outputSlot.putStack(ItemStack.EMPTY);
|
||||
} else {
|
||||
final ItemStack craftingResult = this.currentRecipe.getCraftingResult(ic);
|
||||
|
||||
this.outputSlot.putStack(craftingResult);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
if (Platform.isServer()) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.craftingGrid.writeToNBT(tag, "craftingGrid");
|
||||
this.wirelessTerminalGUIObject.saveChanges(tag);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFromNBT() {
|
||||
NBTTagCompound data = wirelessTerminalGUIObject.getItemStack().getTagCompound();
|
||||
if (data != null) {
|
||||
this.craftingGrid.readFromNBT(data, "craftingGrid");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack) {
|
||||
if (inv == craftingGrid) {
|
||||
saveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getInventoryByName(final String name) {
|
||||
if (name.equals("player")) {
|
||||
return new PlayerInvWrapper(this.getInventoryPlayer());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useRealItems() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
|
||||
public class ContainerWirelessFluidTerminal extends ContainerMEPortableCell {
|
||||
|
||||
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
|
||||
|
||||
public ContainerWirelessFluidTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
|
||||
super(ip, gui);
|
||||
this.wirelessTerminalGUIObject = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
|
||||
if (Platform.isServer() && this.isValidContainer()) {
|
||||
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
|
||||
}
|
||||
|
||||
this.setValidContainer(false);
|
||||
} else {
|
||||
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.container.implementations;
|
||||
|
||||
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
|
||||
public class ContainerWirelessPatternTerminal extends ContainerMEPortableCell {
|
||||
|
||||
private final WirelessTerminalGuiObject wirelessTerminalGUIObject;
|
||||
|
||||
public ContainerWirelessPatternTerminal(final InventoryPlayer ip, final WirelessTerminalGuiObject gui) {
|
||||
super(ip, gui);
|
||||
this.wirelessTerminalGUIObject = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (!this.wirelessTerminalGUIObject.rangeCheck()) {
|
||||
if (Platform.isServer() && this.isValidContainer()) {
|
||||
this.getPlayerInv().player.sendMessage(PlayerMessages.OutOfRange.get());
|
||||
}
|
||||
|
||||
this.setValidContainer(false);
|
||||
} else {
|
||||
this.setPowerMultiplier(AEConfig.instance().wireless_getDrainRate(this.wirelessTerminalGUIObject.getRange()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,6 +404,10 @@ final class Registration {
|
||||
|
||||
// Wireless Terminal Handler
|
||||
items.wirelessTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
|
||||
items.wirelessCraftingTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
|
||||
items.wirelessPatternTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
|
||||
items.wirelessFluidTerminal().maybeItem().ifPresent(terminal -> registries.wireless().registerWirelessHandler((IWirelessTermHandler) terminal));
|
||||
|
||||
|
||||
// Charge Rates
|
||||
items.chargedStaff().maybeItem().ifPresent(chargedStaff -> registries.charger().addChargeRate(chargedStaff, 320d));
|
||||
|
||||
@@ -78,6 +78,9 @@ public final class ApiItems implements IItems {
|
||||
|
||||
private final IItemDefinition entropyManipulator;
|
||||
private final IItemDefinition wirelessTerminal;
|
||||
private final IItemDefinition wirelessCraftingTerminal;
|
||||
private final IItemDefinition wirelessPatternTerminal;
|
||||
private final IItemDefinition wirelessFluidTerminal;
|
||||
private final IItemDefinition biometricCard;
|
||||
private final IItemDefinition chargedStaff;
|
||||
private final IItemDefinition massCannon;
|
||||
@@ -178,6 +181,10 @@ public final class ApiItems implements IItems {
|
||||
.dispenserBehavior(DispenserBlockTool::new)
|
||||
.build();
|
||||
this.wirelessTerminal = powerTools.item("wireless_terminal", ToolWirelessTerminal::new).addFeatures(AEFeature.WIRELESS_ACCESS_TERMINAL).build();
|
||||
this.wirelessCraftingTerminal = powerTools.item("wireless_crafting_terminal", ToolWirelessCraftingTerminal::new).addFeatures(AEFeature.WIRELESS_CRAFTING_TERMINAL).build();
|
||||
this.wirelessPatternTerminal = powerTools.item("wireless_pattern_terminal", ToolWirelessPatternTerminal::new).addFeatures(AEFeature.WIRELESS_PATTERN_TERMINAL).build();
|
||||
this.wirelessFluidTerminal = powerTools.item("wireless_fluid_terminal", ToolWirelessFluidTerminal::new).addFeatures(AEFeature.WIRELESS_FLUID_TERMINAL).build();
|
||||
|
||||
this.chargedStaff = powerTools.item("charged_staff", ToolChargedStaff::new).addFeatures(AEFeature.CHARGED_STAFF).build();
|
||||
this.massCannon = powerTools.item("matter_cannon", ToolMatterCannon::new)
|
||||
.addFeatures(AEFeature.MATTER_CANNON)
|
||||
@@ -343,6 +350,21 @@ public final class ApiItems implements IItems {
|
||||
return this.wirelessTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessCraftingTerminal() {
|
||||
return wirelessCraftingTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessFluidTerminal() {
|
||||
return wirelessFluidTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition wirelessPatternTerminal() {
|
||||
return wirelessPatternTerminal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemDefinition biometricCard() {
|
||||
return this.biometricCard;
|
||||
|
||||
@@ -64,6 +64,10 @@ public enum AEFeature {
|
||||
ENTROPY_MANIPULATOR("EntropyManipulator", Constants.CATEGORY_TOOLS),
|
||||
MATTER_CANNON("MatterCannon", Constants.CATEGORY_TOOLS),
|
||||
WIRELESS_ACCESS_TERMINAL("WirelessAccessTerminal", Constants.CATEGORY_TOOLS),
|
||||
WIRELESS_CRAFTING_TERMINAL("WirelessCraftingTerminal", Constants.CATEGORY_TOOLS),
|
||||
WIRELESS_PATTERN_TERMINAL("WirelessPatternTerminal", Constants.CATEGORY_TOOLS),
|
||||
WIRELESS_FLUID_TERMINAL("WirelessFluidTerminal", Constants.CATEGORY_TOOLS),
|
||||
|
||||
COLOR_APPLICATOR("ColorApplicator", Constants.CATEGORY_TOOLS),
|
||||
METEORITE_COMPASS("MeteoriteCompass", Constants.CATEGORY_TOOLS),
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ public final class WirelessRegistry implements IWirelessTermRegistry {
|
||||
}
|
||||
|
||||
if (handler.hasPower(player, 0.5, item)) {
|
||||
Platform.openGUI(player, null, null, GuiBridge.GUI_WIRELESS_TERM);
|
||||
Platform.openGUI(player, null, null, (GuiBridge) handler.getGuiHandler(item));
|
||||
} else {
|
||||
player.sendMessage(PlayerMessages.DeviceNotPowered.get());
|
||||
}
|
||||
|
||||
@@ -101,6 +101,10 @@ public enum GuiBridge implements IGuiHandler {
|
||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, GuiHostType.ITEM, null),
|
||||
|
||||
GUI_WIRELESS_TERM(ContainerWirelessTerm.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
|
||||
GUI_WIRELESS_CRAFTING_TERMINAL(ContainerWirelessCraftingTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
|
||||
GUI_WIRELESS_PATTERN_TERMINAL(ContainerWirelessPatternTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
|
||||
GUI_WIRELESS_FLUID_TERMINAL(ContainerWirelessFluidTerminal.class, WirelessTerminalGuiObject.class, GuiHostType.ITEM, null),
|
||||
|
||||
|
||||
GUI_NETWORK_STATUS(ContainerNetworkStatus.class, INetworkTool.class, GuiHostType.ITEM, null),
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.implementations.tiles.IWirelessAccessPoint;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -43,13 +44,18 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.interfaces.IInventorySlotAware;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware {
|
||||
public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, IInventorySlotAware, IViewCellStorage, IAEAppEngInventory {
|
||||
|
||||
private final ItemStack effectiveItem;
|
||||
private final IWirelessTermHandler wth;
|
||||
@@ -63,6 +69,8 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
private double myRange = Double.MAX_VALUE;
|
||||
private final int inventorySlot;
|
||||
|
||||
private final AppEngInternalInventory viewCell = new AppEngInternalInventory(this, 5);
|
||||
|
||||
public WirelessTerminalGuiObject(final IWirelessTermHandler wh, final ItemStack is, final EntityPlayer ep, final World w, final int x, final int y, final int z) {
|
||||
this.encryptionKey = wh.getEncryptionKey(is);
|
||||
this.effectiveItem = is;
|
||||
@@ -91,6 +99,8 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.loadFromNBT();
|
||||
}
|
||||
|
||||
public double getRange() {
|
||||
@@ -286,4 +296,42 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II
|
||||
return this.inventorySlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemHandler getViewCellStorage() {
|
||||
NBTTagCompound data = effectiveItem.getTagCompound();
|
||||
if (data != null) {
|
||||
viewCell.readFromNBT(data, "viewCell");
|
||||
}
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges() {
|
||||
NBTTagCompound data = effectiveItem.getTagCompound();
|
||||
if (data == null) {
|
||||
data = new NBTTagCompound();
|
||||
}
|
||||
viewCell.writeToNBT(data, "viewCell");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveChanges(NBTTagCompound data) {
|
||||
if (effectiveItem.getTagCompound() != null) {
|
||||
effectiveItem.getTagCompound().merge(data);
|
||||
} else {
|
||||
effectiveItem.setTagCompound(data);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadFromNBT() {
|
||||
NBTTagCompound data = effectiveItem.getTagCompound();
|
||||
if (data != null) {
|
||||
viewCell.readFromNBT(data);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ToolWirelessCraftingTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
||||
|
||||
public ToolWirelessCraftingTerminal() {
|
||||
super(AEConfig.instance().getWirelessTerminalBattery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer player, final EnumHand hand) {
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
if (stack.hasTagCompound()) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(stack);
|
||||
if (tag != null) {
|
||||
final String encKey = tag.getString("encryptionKey");
|
||||
|
||||
if (encKey == null || encKey.isEmpty()) {
|
||||
lines.add(GuiText.Unlinked.getLocal());
|
||||
} else {
|
||||
lines.add(GuiText.Linked.getLocal());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(I18n.translateToLocal("AppEng.GuiITooltip.Unlinked"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(final ItemStack is) {
|
||||
return AEApi.instance().definitions().items().wirelessCraftingTerminal().isSameAs(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usePower(final EntityPlayer player, final double amount, final ItemStack is) {
|
||||
return this.extractAEPower(is, amount, Actionable.MODULATE) >= amount - 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPower(final EntityPlayer player, final double amt, final ItemStack is) {
|
||||
return this.getAECurrentPower(is) >= amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager(final ItemStack target) {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) ->
|
||||
{
|
||||
final NBTTagCompound data = Platform.openNbtData(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(Platform.openNbtData(target).copy());
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptionKey(final ItemStack item) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
||||
return tag.getString("encryptionKey");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionKey(final ItemStack item, final String encKey, final String name) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
||||
tag.setString("encryptionKey", encKey);
|
||||
tag.setString("name", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return slotChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiHandler getGuiHandler(ItemStack is) {
|
||||
return GuiBridge.GUI_WIRELESS_CRAFTING_TERMINAL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ToolWirelessFluidTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
||||
|
||||
public ToolWirelessFluidTerminal() {
|
||||
super(AEConfig.instance().getWirelessTerminalBattery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer player, final EnumHand hand) {
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
if (stack.hasTagCompound()) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(stack);
|
||||
if (tag != null) {
|
||||
final String encKey = tag.getString("encryptionKey");
|
||||
|
||||
if (encKey == null || encKey.isEmpty()) {
|
||||
lines.add(GuiText.Unlinked.getLocal());
|
||||
} else {
|
||||
lines.add(GuiText.Linked.getLocal());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(I18n.translateToLocal("AppEng.GuiITooltip.Unlinked"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(final ItemStack is) {
|
||||
return AEApi.instance().definitions().items().wirelessFluidTerminal().isSameAs(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usePower(final EntityPlayer player, final double amount, final ItemStack is) {
|
||||
return this.extractAEPower(is, amount, Actionable.MODULATE) >= amount - 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPower(final EntityPlayer player, final double amt, final ItemStack is) {
|
||||
return this.getAECurrentPower(is) >= amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager(final ItemStack target) {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) ->
|
||||
{
|
||||
final NBTTagCompound data = Platform.openNbtData(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(Platform.openNbtData(target).copy());
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptionKey(final ItemStack item) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
||||
return tag.getString("encryptionKey");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionKey(final ItemStack item, final String encKey, final String name) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
||||
tag.setString("encryptionKey", encKey);
|
||||
tag.setString("name", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return slotChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiHandler getGuiHandler(ItemStack is) {
|
||||
return GuiBridge.GUI_WIRELESS_FLUID_TERMINAL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.items.tools.powered;
|
||||
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ToolWirelessPatternTerminal extends AEBasePoweredItem implements IWirelessTermHandler {
|
||||
|
||||
public ToolWirelessPatternTerminal() {
|
||||
super(AEConfig.instance().getWirelessTerminalBattery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(final World w, final EntityPlayer player, final EnumHand hand) {
|
||||
AEApi.instance().registries().wireless().openWirelessTerminalGui(player.getHeldItem(hand), w, player);
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addCheckedInformation(final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips) {
|
||||
super.addCheckedInformation(stack, world, lines, advancedTooltips);
|
||||
|
||||
if (stack.hasTagCompound()) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(stack);
|
||||
if (tag != null) {
|
||||
final String encKey = tag.getString("encryptionKey");
|
||||
|
||||
if (encKey == null || encKey.isEmpty()) {
|
||||
lines.add(GuiText.Unlinked.getLocal());
|
||||
} else {
|
||||
lines.add(GuiText.Linked.getLocal());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lines.add(I18n.translateToLocal("AppEng.GuiITooltip.Unlinked"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(final ItemStack is) {
|
||||
return AEApi.instance().definitions().items().wirelessFluidTerminal().isSameAs(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean usePower(final EntityPlayer player, final double amount, final ItemStack is) {
|
||||
return this.extractAEPower(is, amount, Actionable.MODULATE) >= amount - 0.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPower(final EntityPlayer player, final double amt, final ItemStack is) {
|
||||
return this.getAECurrentPower(is) >= amt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager(final ItemStack target) {
|
||||
final ConfigManager out = new ConfigManager((manager, settingName, newValue) ->
|
||||
{
|
||||
final NBTTagCompound data = Platform.openNbtData(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(Platform.openNbtData(target).copy());
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEncryptionKey(final ItemStack item) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
||||
return tag.getString("encryptionKey");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionKey(final ItemStack item, final String encKey, final String name) {
|
||||
final NBTTagCompound tag = Platform.openNbtData(item);
|
||||
tag.setString("encryptionKey", encKey);
|
||||
tag.setString("name", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return slotChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiHandler getGuiHandler(ItemStack is) {
|
||||
return GuiBridge.GUI_WIRELESS_PATTERN_TERMINAL;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.Platform;
|
||||
@@ -37,6 +38,7 @@ import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -130,4 +132,9 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return slotChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGuiHandler getGuiHandler(ItemStack is) {
|
||||
return GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,15 @@ package appeng.util.inv;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
|
||||
public interface IAEAppEngInventory {
|
||||
void saveChanges();
|
||||
|
||||
default void saveChanges(NBTTagCompound data) {
|
||||
}
|
||||
|
||||
void onChangeInventory(IItemHandler inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user