More moves
This commit is contained in:
@@ -1,35 +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.container.interfaces;
|
||||
|
||||
/**
|
||||
* Any item providing a GUI and depending on an exact inventory slot.
|
||||
*
|
||||
* This interface is likely a volatile one until a general GUI refactoring
|
||||
* occurred. Use it with care and expect changes.
|
||||
*
|
||||
*/
|
||||
public interface IInventorySlotAware {
|
||||
/**
|
||||
* This is needed to select the correct slot index.
|
||||
*
|
||||
* @return the inventory index of this portable cell.
|
||||
*/
|
||||
int getInventorySlot();
|
||||
}
|
||||
@@ -1,78 +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.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.sync.BasePacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.services.compass.ICompassCallback;
|
||||
|
||||
public class CompassRequestPacket extends BasePacket implements ICompassCallback {
|
||||
|
||||
final long attunement;
|
||||
final int cx;
|
||||
final int cz;
|
||||
final int cdy;
|
||||
|
||||
private PlayerEntity talkBackTo;
|
||||
|
||||
public CompassRequestPacket(final PacketByteBuf stream) {
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
this.cz = stream.readInt();
|
||||
this.cdy = stream.readInt();
|
||||
}
|
||||
|
||||
// api
|
||||
public CompassRequestPacket(final long attunement, final int cx, final int cz, final int cdy) {
|
||||
|
||||
final PacketByteBuf data = new PacketByteBuf(Unpooled.buffer());
|
||||
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeLong(this.attunement = attunement);
|
||||
data.writeInt(this.cx = cx);
|
||||
data.writeInt(this.cz = cz);
|
||||
data.writeInt(this.cdy = cdy);
|
||||
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculatedDirection(final boolean hasResult, final boolean spin, final double radians,
|
||||
final double dist) {
|
||||
NetworkHandler.instance().sendTo(new CompassResponsePacket(this, hasResult, spin, radians),
|
||||
(ServerPlayerEntity) this.talkBackTo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(final INetworkInfo manager, final PlayerEntity player) {
|
||||
this.talkBackTo = player;
|
||||
|
||||
final DimensionalCoord loc = new DimensionalCoord(player.world, this.cx << 4, this.cdy << 5, this.cz << 4);
|
||||
WorldData.instance().compassData().service().getCompassDirection(loc, 174, this);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +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.core.sync.packets;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
||||
import appeng.core.sync.BasePacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.hooks.CompassManager;
|
||||
import appeng.hooks.CompassResult;
|
||||
|
||||
public class CompassResponsePacket extends BasePacket {
|
||||
|
||||
private final long attunement;
|
||||
private final int cx;
|
||||
private final int cz;
|
||||
private final int cdy;
|
||||
|
||||
private CompassResult cr;
|
||||
|
||||
public CompassResponsePacket(final PacketByteBuf stream) {
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
this.cz = stream.readInt();
|
||||
this.cdy = stream.readInt();
|
||||
|
||||
this.cr = new CompassResult(stream.readBoolean(), stream.readBoolean(), stream.readDouble());
|
||||
}
|
||||
|
||||
// api
|
||||
public CompassResponsePacket(final CompassRequestPacket req, final boolean hasResult, final boolean spin,
|
||||
final double radians) {
|
||||
|
||||
final PacketByteBuf data = new PacketByteBuf(Unpooled.buffer());
|
||||
|
||||
data.writeInt(this.getPacketID());
|
||||
data.writeLong(this.attunement = req.attunement);
|
||||
data.writeInt(this.cx = req.cx);
|
||||
data.writeInt(this.cz = req.cz);
|
||||
data.writeInt(this.cdy = req.cdy);
|
||||
|
||||
data.writeBoolean(hasResult);
|
||||
data.writeBoolean(spin);
|
||||
data.writeDouble(radians);
|
||||
|
||||
this.configureWrite(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(final INetworkInfo network, final PlayerEntity player) {
|
||||
CompassManager.INSTANCE.postResult(this.attunement, this.cx << 4, this.cdy << 5, this.cz << 4, this.cr);
|
||||
}
|
||||
}
|
||||
@@ -1,105 +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.hooks;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.CompassRequestPacket;
|
||||
|
||||
public class CompassManager {
|
||||
|
||||
public static final CompassManager INSTANCE = new CompassManager();
|
||||
private final HashMap<CompassRequest, CompassResult> requests = new HashMap<>();
|
||||
|
||||
public void postResult(final long attunement, final int x, final int y, final int z, final CompassResult result) {
|
||||
final CompassRequest r = new CompassRequest(attunement, x, y, z);
|
||||
this.requests.put(r, result);
|
||||
}
|
||||
|
||||
public CompassResult getCompassDirection(final long attunement, final int x, final int y, final int z) {
|
||||
final long now = System.currentTimeMillis();
|
||||
|
||||
final Iterator<CompassResult> i = this.requests.values().iterator();
|
||||
while (i.hasNext()) {
|
||||
final CompassResult res = i.next();
|
||||
final long diff = now - res.getTime();
|
||||
if (diff > 20000) {
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
final CompassRequest r = new CompassRequest(attunement, x, y, z);
|
||||
CompassResult res = this.requests.get(r);
|
||||
|
||||
if (res == null) {
|
||||
res = new CompassResult(false, true, 0);
|
||||
this.requests.put(r, res);
|
||||
this.requestUpdate(r);
|
||||
} else if (now - res.getTime() > 1000 * 3) {
|
||||
if (!res.isRequested()) {
|
||||
res.setRequested(true);
|
||||
this.requestUpdate(r);
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private void requestUpdate(final CompassRequest r) {
|
||||
NetworkHandler.instance().sendToServer(new CompassRequestPacket(r.attunement, r.cx, r.cz, r.cdy));
|
||||
}
|
||||
|
||||
private static class CompassRequest {
|
||||
|
||||
private final int hash;
|
||||
private final long attunement;
|
||||
private final int cx;
|
||||
private final int cdy;
|
||||
private final int cz;
|
||||
|
||||
public CompassRequest(final long attunement, final int x, final int y, final int z) {
|
||||
this.attunement = attunement;
|
||||
this.cx = x >> 4;
|
||||
this.cdy = y >> 5;
|
||||
this.cz = z >> 4;
|
||||
this.hash = ((Integer) this.cx).hashCode() ^ ((Integer) this.cdy).hashCode()
|
||||
^ ((Integer) this.cz).hashCode() ^ ((Long) attunement).hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final CompassRequest other = (CompassRequest) obj;
|
||||
return this.attunement == other.attunement && this.cx == other.cx && this.cdy == other.cdy
|
||||
&& this.cz == other.cz;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +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.hooks;
|
||||
|
||||
public class CompassResult {
|
||||
|
||||
private final boolean hasResult;
|
||||
private final boolean spin;
|
||||
private final double rad;
|
||||
private final long time;
|
||||
private boolean requested = false;
|
||||
|
||||
public CompassResult(final boolean hasResult, final boolean spin, final double rad) {
|
||||
this.hasResult = hasResult;
|
||||
this.spin = spin;
|
||||
this.rad = rad;
|
||||
this.time = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isValidResult() {
|
||||
return this.hasResult;
|
||||
}
|
||||
|
||||
public boolean isSpin() {
|
||||
return this.spin;
|
||||
}
|
||||
|
||||
public double getRad() {
|
||||
return this.rad;
|
||||
}
|
||||
|
||||
boolean isRequested() {
|
||||
return this.requested;
|
||||
}
|
||||
|
||||
void setRequested(final boolean requested) {
|
||||
this.requested = requested;
|
||||
}
|
||||
|
||||
long getTime() {
|
||||
return this.time;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +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.parts.automation;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
|
||||
public class BlockUpgradeInventory extends UpgradeInventory {
|
||||
private final Block block;
|
||||
|
||||
public BlockUpgradeInventory(final Block block, final IAEAppEngInventory parent, final int s) {
|
||||
super(parent, s);
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInstalled(final Upgrades upgrades) {
|
||||
int max = 0;
|
||||
|
||||
for (final ItemStack is : upgrades.getSupported().keySet()) {
|
||||
final Item encodedItem = is.getItem();
|
||||
|
||||
if (encodedItem instanceof BlockItem && Block.getBlockFromItem(encodedItem) == this.block) {
|
||||
max = upgrades.getSupported().get(is);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
}
|
||||
@@ -1,47 +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.parts.automation;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
|
||||
public class StackUpgradeInventory extends UpgradeInventory {
|
||||
private final ItemStack stack;
|
||||
|
||||
public StackUpgradeInventory(final ItemStack stack, final IAEAppEngInventory inventory, final int s) {
|
||||
super(inventory, s);
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxInstalled(final Upgrades upgrades) {
|
||||
int max = 0;
|
||||
|
||||
for (final ItemStack is : upgrades.getSupported().keySet()) {
|
||||
if (ItemStack.areItemsEqual(this.stack, is)) {
|
||||
max = upgrades.getSupported().get(is);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user