More moves

This commit is contained in:
Sebastian Hartte
2020-07-01 01:39:50 +02:00
parent 1cda087c03
commit 996d387525
13 changed files with 9 additions and 19 deletions
@@ -1,39 +0,0 @@
/*
* 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.contents;
import alexiil.mc.lib.attributes.item.FixedItemInvView;
import net.minecraft.item.ItemStack;
import appeng.parts.automation.StackUpgradeInventory;
public final class CellUpgrades extends StackUpgradeInventory {
private final ItemStack is;
public CellUpgrades(final ItemStack is, final int upgrades) {
super(is, null, upgrades);
this.is = is;
this.readFromNBT(is.getOrCreateTag(), "upgrades");
}
@Override
protected void onContentsChanged(FixedItemInvView inv, int slot, ItemStack previous, ItemStack current) {
this.writeToNBT(this.is.getOrCreateTag(), "upgrades");
}
}
@@ -1,90 +0,0 @@
/*
* 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.contents;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.item.ItemStack;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.networking.IGridHost;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import appeng.util.inv.filter.IAEItemFilter;
public class NetworkToolViewer implements INetworkTool, IAEAppEngInventory {
private final AppEngInternalInventory inv;
private final ItemStack is;
private final IGridHost gh;
public NetworkToolViewer(final ItemStack is, final IGridHost gHost) {
this.is = is;
this.gh = gHost;
this.inv = new AppEngInternalInventory(this, 9);
this.inv.setFilter(new NetworkToolInventoryFilter());
if (is.hasTag()) // prevent crash when opening network status screen.
{
this.inv.readFromNBT(is.getOrCreateTag(), "inv");
}
}
@Override
public void saveChanges() {
this.inv.writeToNBT(this.is.getOrCreateTag(), "inv");
}
@Override
public void onChangeInventory(FixedItemInv inv, int slot, InvOperation mc, ItemStack removedStack,
ItemStack newStack) {
}
@Override
public ItemStack getItemStack() {
return this.is;
}
@Override
public IGridHost getGridHost() {
return this.gh;
}
private static class NetworkToolInventoryFilter implements IAEItemFilter {
@Override
public boolean allowExtract(FixedItemInv inv, int slot, int amount) {
return true;
}
@Override
public boolean allowInsert(FixedItemInv inv, int slot, ItemStack stack) {
return stack.getItem() instanceof IUpgradeModule
&& ((IUpgradeModule) stack.getItem()).getType(stack) != null;
}
}
public FixedItemInv getInternalInventory() {
return this.inv;
}
@Override
public FixedItemInv getInventory() {
return this.inv;
}
}
@@ -1,100 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, 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.contents;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.implementations.guiobjects.IPortableCell;
import appeng.api.implementations.items.IAEItemPowerStorage;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.me.helpers.MEMonitorHandler;
import appeng.util.ConfigManager;
public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implements IPortableCell, IInventorySlotAware {
private final ItemStack target;
private final IAEItemPowerStorage ips;
private final int inventorySlot;
public PortableCellViewer(final ItemStack is, final int slot) {
super(AEApi.instance().registries().cell().getCellInventory(is, null,
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)));
this.ips = (IAEItemPowerStorage) is.getItem();
this.target = is;
this.inventorySlot = slot;
}
@Override
public int getInventorySlot() {
return this.inventorySlot;
}
@Override
public ItemStack getItemStack() {
return this.target;
}
@Override
public double extractAEPower(double amt, final Actionable mode, final 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, Actionable.MODULATE));
}
@Override
public <T extends IAEStack<T>> IMEMonitor<T> getInventory(IStorageChannel<T> channel) {
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
return (IMEMonitor<T>) this;
}
return null;
}
@Override
public IConfigManager getConfigManager() {
final ConfigManager out = new ConfigManager((manager, settingName, newValue) -> {
final CompoundTag data = this.target.getOrCreateTag();
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(this.target.getOrCreateTag().copy());
return out;
}
}
@@ -1,37 +0,0 @@
/*
* 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.contents;
import net.minecraft.item.ItemStack;
import appeng.api.implementations.guiobjects.IGuiItemObject;
public class QuartzKnifeObj implements IGuiItemObject {
private final ItemStack is;
public QuartzKnifeObj(final ItemStack o) {
this.is = o;
}
@Override
public ItemStack getItemStack() {
return this.is;
}
}