Fix errors in tile package
This commit is contained in:
@@ -1,28 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage;
|
|
||||||
|
|
||||||
public final class RSGui {
|
|
||||||
public static final int CONTROLLER = 0;
|
|
||||||
public static final int DISK_DRIVE = 1;
|
|
||||||
public static final int IMPORTER = 2;
|
|
||||||
public static final int EXPORTER = 3;
|
|
||||||
public static final int DETECTOR = 4;
|
|
||||||
public static final int DESTRUCTOR = 5;
|
|
||||||
public static final int CONSTRUCTOR = 6;
|
|
||||||
public static final int STORAGE = 7;
|
|
||||||
public static final int RELAY = 8;
|
|
||||||
public static final int INTERFACE = 9;
|
|
||||||
public static final int CRAFTING_MONITOR = 10;
|
|
||||||
public static final int WIRELESS_TRANSMITTER = 11;
|
|
||||||
public static final int CRAFTER = 12;
|
|
||||||
public static final int FILTER = 13;
|
|
||||||
public static final int NETWORK_TRANSMITTER = 14;
|
|
||||||
public static final int FLUID_INTERFACE = 15;
|
|
||||||
public static final int EXTERNAL_STORAGE = 16;
|
|
||||||
public static final int FLUID_STORAGE = 17;
|
|
||||||
public static final int DISK_MANIPULATOR = 18;
|
|
||||||
public static final int WIRELESS_CRAFTING_MONITOR = 19;
|
|
||||||
public static final int READER_WRITER = 20;
|
|
||||||
public static final int SECURITY_MANAGER = 21;
|
|
||||||
public static final int STORAGE_MONITOR = 22;
|
|
||||||
public static final int CRAFTER_MANAGER = 23;
|
|
||||||
}
|
|
65
src/main/java/com/raoulvdberge/refinedstorage/RSTiles.java
Normal file
65
src/main/java/com/raoulvdberge/refinedstorage/RSTiles.java
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package com.raoulvdberge.refinedstorage;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.*;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||||
|
import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid;
|
||||||
|
import net.minecraft.tileentity.TileEntityType;
|
||||||
|
import net.minecraftforge.registries.ObjectHolder;
|
||||||
|
|
||||||
|
public class RSTiles {
|
||||||
|
@ObjectHolder(RS.ID + ":constructor")
|
||||||
|
public static final TileEntityType<TileConstructor> CONSTRUCTOR = null;
|
||||||
|
@ObjectHolder(RS.ID + ":controller")
|
||||||
|
public static final TileEntityType<TileController> CONTROLLER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":crafter")
|
||||||
|
public static final TileEntityType<TileCrafter> CRAFTER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":crafter_manager")
|
||||||
|
public static final TileEntityType<TileCrafter> CRAFTER_MANAGER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":crafting_monitor")
|
||||||
|
public static final TileEntityType<TileCraftingMonitor> CRAFTING_MONITOR = null;
|
||||||
|
@ObjectHolder(RS.ID + ":destructor")
|
||||||
|
public static final TileEntityType<TileDestructor> DESTRUCTOR = null;
|
||||||
|
@ObjectHolder(RS.ID + ":detector")
|
||||||
|
public static final TileEntityType<TileDetector> DETECTOR = null;
|
||||||
|
@ObjectHolder(RS.ID + ":disk_drive")
|
||||||
|
public static final TileEntityType<TileDiskDrive> DISK_DRIVE = null;
|
||||||
|
@ObjectHolder(RS.ID + ":disk_manipulator")
|
||||||
|
public static final TileEntityType<TileDiskManipulator> DISK_MANIPULATOR = null;
|
||||||
|
@ObjectHolder(RS.ID + ":exporter")
|
||||||
|
public static final TileEntityType<TileExporter> EXPORTER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":external_storage")
|
||||||
|
public static final TileEntityType<TileExternalStorage> EXTERNAL_STORAGE = null;
|
||||||
|
@ObjectHolder(RS.ID + ":fluid_interface")
|
||||||
|
public static final TileEntityType<TileFluidInterface> FLUID_INTERFACE = null;
|
||||||
|
@ObjectHolder(RS.ID + ":fluid_storage")
|
||||||
|
public static final TileEntityType<TileFluidInterface> FLUID_STORAGE = null;
|
||||||
|
@ObjectHolder(RS.ID + ":grid")
|
||||||
|
public static final TileEntityType<TileGrid> GRID = null;
|
||||||
|
@ObjectHolder(RS.ID + ":importer")
|
||||||
|
public static final TileEntityType<TileImporter> IMPORTER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":interface")
|
||||||
|
public static final TileEntityType<TileImporter> INTERFACE = null;
|
||||||
|
@ObjectHolder(RS.ID + ":network_transmitter")
|
||||||
|
public static final TileEntityType<TileNetworkTransmitter> NETWORK_TRANSMITTER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":network_receiver")
|
||||||
|
public static final TileEntityType<TileNetworkReceiver> NETWORK_RECEIVER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":reader")
|
||||||
|
public static final TileEntityType<TileReader> READER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":writer")
|
||||||
|
public static final TileEntityType<TileWriter> WRITER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":relay")
|
||||||
|
public static final TileEntityType<TileRelay> RELAY = null;
|
||||||
|
@ObjectHolder(RS.ID + ":security_manager")
|
||||||
|
public static final TileEntityType<TileSecurityManager> SECURITY_MANAGER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":storage")
|
||||||
|
public static final TileEntityType<TileStorage> STORAGE = null;
|
||||||
|
@ObjectHolder(RS.ID + ":storage_monitor")
|
||||||
|
public static final TileEntityType<TileStorageMonitor> STORAGE_MONITOR = null;
|
||||||
|
@ObjectHolder(RS.ID + ":wireless_transmitter")
|
||||||
|
public static final TileEntityType<TileSecurityManager> WIRELESS_TRANSMITTER = null;
|
||||||
|
@ObjectHolder(RS.ID + ":cable")
|
||||||
|
public static final TileEntityType<TileCable> CABLE = null;
|
||||||
|
@ObjectHolder(RS.ID + ":portable_grid")
|
||||||
|
public static final TileEntityType<TilePortableGrid> PORTABLE_GRID = null;
|
||||||
|
}
|
@@ -1,6 +1,5 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingManager;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingManager;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
@@ -17,6 +16,7 @@ import net.minecraft.world.World;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class NetworkNodeCraftingMonitor extends NetworkNode implements ICraftingMonitor {
|
public class NetworkNodeCraftingMonitor extends NetworkNode implements ICraftingMonitor {
|
||||||
@@ -25,7 +25,7 @@ public class NetworkNodeCraftingMonitor extends NetworkNode implements ICrafting
|
|||||||
private static final String NBT_TAB_SELECTED = "TabSelected";
|
private static final String NBT_TAB_SELECTED = "TabSelected";
|
||||||
private static final String NBT_TAB_PAGE = "TabPage";
|
private static final String NBT_TAB_PAGE = "TabPage";
|
||||||
|
|
||||||
private Optional<UUID> tabSelected = Optional.absent();
|
private Optional<UUID> tabSelected = Optional.empty();
|
||||||
private int tabPage;
|
private int tabPage;
|
||||||
|
|
||||||
public NetworkNodeCraftingMonitor(World world, BlockPos pos) {
|
public NetworkNodeCraftingMonitor(World world, BlockPos pos) {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCable;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCable;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -7,6 +8,10 @@ import net.minecraft.world.World;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class TileCable extends TileNode<NetworkNodeCable> {
|
public class TileCable extends TileNode<NetworkNodeCable> {
|
||||||
|
public TileCable() {
|
||||||
|
super(RSTiles.CABLE);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public NetworkNodeCable createNode(World world, BlockPos pos) {
|
public NetworkNodeCable createNode(World world, BlockPos pos) {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeConstructor;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeConstructor;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
@@ -19,6 +20,8 @@ public class TileConstructor extends TileNode<NetworkNodeConstructor> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
public TileConstructor() {
|
public TileConstructor() {
|
||||||
|
super(RSTiles.CONSTRUCTOR);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(TYPE);
|
dataManager.addWatchedParameter(TYPE);
|
||||||
dataManager.addWatchedParameter(DROP);
|
dataManager.addWatchedParameter(DROP);
|
||||||
|
@@ -3,6 +3,7 @@ package com.raoulvdberge.refinedstorage.tile;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingManager;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingManager;
|
||||||
import com.raoulvdberge.refinedstorage.api.energy.IEnergy;
|
import com.raoulvdberge.refinedstorage.api.energy.IEnergy;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
@@ -38,7 +39,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageTrackerItem;
|
|||||||
import com.raoulvdberge.refinedstorage.block.BlockController;
|
import com.raoulvdberge.refinedstorage.block.BlockController;
|
||||||
import com.raoulvdberge.refinedstorage.block.enums.ControllerEnergyType;
|
import com.raoulvdberge.refinedstorage.block.enums.ControllerEnergyType;
|
||||||
import com.raoulvdberge.refinedstorage.block.enums.ControllerType;
|
import com.raoulvdberge.refinedstorage.block.enums.ControllerType;
|
||||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
|
||||||
import com.raoulvdberge.refinedstorage.integration.forgeenergy.EnergyProxy;
|
import com.raoulvdberge.refinedstorage.integration.forgeenergy.EnergyProxy;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||||
@@ -46,21 +46,25 @@ import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
|||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
|
import net.minecraft.tileentity.ITickableTileEntity;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.items.ItemHandlerHelper;
|
import net.minecraftforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -69,7 +73,7 @@ import java.util.function.Predicate;
|
|||||||
import static com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY;
|
import static com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY;
|
||||||
|
|
||||||
// TODO: Change INetwork to be offloaded from the tile.
|
// TODO: Change INetwork to be offloaded from the tile.
|
||||||
public class TileController extends TileBase implements ITickable, INetwork, IRedstoneConfigurable, INetworkNode, INetworkNodeProxy<TileController>, INetworkNodeVisitor {
|
public class TileController extends TileBase implements ITickableTileEntity, INetwork, IRedstoneConfigurable, INetworkNode, INetworkNodeProxy<TileController>, INetworkNodeVisitor {
|
||||||
private static final Comparator<ClientNode> CLIENT_NODE_COMPARATOR = (left, right) -> {
|
private static final Comparator<ClientNode> CLIENT_NODE_COMPARATOR = (left, right) -> {
|
||||||
if (left.getEnergyUsage() == right.getEnergyUsage()) {
|
if (left.getEnergyUsage() == right.getEnergyUsage()) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -114,7 +118,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
private static final int THROTTLE_ACTIVE_TO_INACTIVE = 4;
|
private static final int THROTTLE_ACTIVE_TO_INACTIVE = 4;
|
||||||
|
|
||||||
public static final String NBT_ENERGY = "Energy";
|
public static final String NBT_ENERGY = "Energy";
|
||||||
public static final String NBT_ENERGY_TYPE = "EnergyType";
|
private static final String NBT_ENERGY_TYPE = "EnergyType";
|
||||||
|
|
||||||
private static final String NBT_ITEM_STORAGE_TRACKER = "ItemStorageTracker";
|
private static final String NBT_ITEM_STORAGE_TRACKER = "ItemStorageTracker";
|
||||||
private static final String NBT_FLUID_STORAGE_TRACKER = "FluidStorageTracker";
|
private static final String NBT_FLUID_STORAGE_TRACKER = "FluidStorageTracker";
|
||||||
@@ -141,6 +145,9 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
private final IEnergy energy = new Energy(RS.INSTANCE.config.controllerCapacity);
|
private final IEnergy energy = new Energy(RS.INSTANCE.config.controllerCapacity);
|
||||||
private final EnergyProxy energyProxy = new EnergyProxy(this.energy, RS.INSTANCE.config.controllerMaxReceive, 0);
|
private final EnergyProxy energyProxy = new EnergyProxy(this.energy, RS.INSTANCE.config.controllerMaxReceive, 0);
|
||||||
|
|
||||||
|
private final LazyOptional<IEnergyStorage> energyProxyCap = LazyOptional.of(() -> energyProxy);
|
||||||
|
private final LazyOptional<INetworkNodeProxy<TileController>> networkNodeProxyCap = LazyOptional.of(() -> this);
|
||||||
|
|
||||||
private boolean throttlingDisabled = true; // Will be enabled after first update
|
private boolean throttlingDisabled = true; // Will be enabled after first update
|
||||||
private boolean couldRun;
|
private boolean couldRun;
|
||||||
private int ticksSinceUpdateChanged;
|
private int ticksSinceUpdateChanged;
|
||||||
@@ -151,6 +158,8 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||||
|
|
||||||
public TileController() {
|
public TileController() {
|
||||||
|
super(RSTiles.CONTROLLER);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(REDSTONE_MODE);
|
dataManager.addWatchedParameter(REDSTONE_MODE);
|
||||||
dataManager.addWatchedParameter(ENERGY_USAGE);
|
dataManager.addWatchedParameter(ENERGY_USAGE);
|
||||||
dataManager.addWatchedParameter(ENERGY_STORED);
|
dataManager.addWatchedParameter(ENERGY_STORED);
|
||||||
@@ -202,7 +211,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void tick() {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
if (canRun()) {
|
if (canRun()) {
|
||||||
craftingManager.update();
|
craftingManager.update();
|
||||||
@@ -214,7 +223,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getType() == ControllerType.NORMAL) {
|
if (getControllerType() == ControllerType.NORMAL) {
|
||||||
if (!RS.INSTANCE.config.controllerUsesEnergy) {
|
if (!RS.INSTANCE.config.controllerUsesEnergy) {
|
||||||
this.energy.setStored(this.energy.getCapacity());
|
this.energy.setStored(this.energy.getCapacity());
|
||||||
} else if (this.energy.extract(getEnergyUsage(), Action.SIMULATE) >= 0) {
|
} else if (this.energy.extract(getEnergyUsage(), Action.SIMULATE) >= 0) {
|
||||||
@@ -222,7 +231,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
} else {
|
} else {
|
||||||
this.energy.setStored(0);
|
this.energy.setStored(0);
|
||||||
}
|
}
|
||||||
} else if (getType() == ControllerType.CREATIVE) {
|
} else if (getControllerType() == ControllerType.CREATIVE) {
|
||||||
this.energy.setStored(this.energy.getCapacity());
|
this.energy.setStored(this.energy.getCapacity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,8 +283,8 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public void remove() {
|
||||||
super.invalidate();
|
super.remove();
|
||||||
|
|
||||||
if (world != null && !world.isRemote) {
|
if (world != null && !world.isRemote) {
|
||||||
nodeGraph.disconnectAll();
|
nodeGraph.disconnectAll();
|
||||||
@@ -430,13 +439,13 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// The external storage is responsible for sending changes, we don't need to anymore
|
// The external storage is responsible for sending changes, we don't need to anymore
|
||||||
if (size != remainder.amount && storage instanceof IStorageExternal && action == Action.PERFORM) {
|
if (size != remainder.getAmount() && storage instanceof IStorageExternal && action == Action.PERFORM) {
|
||||||
((IStorageExternal) storage).update(this);
|
((IStorageExternal) storage).update(this);
|
||||||
|
|
||||||
insertedExternally += size - remainder.amount;
|
insertedExternally += size - remainder.getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
size = remainder.amount;
|
size = remainder.getAmount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,16 +477,16 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
if (storage instanceof IStorageExternal && action == Action.PERFORM) {
|
if (storage instanceof IStorageExternal && action == Action.PERFORM) {
|
||||||
((IStorageExternal) storage).update(this);
|
((IStorageExternal) storage).update(this);
|
||||||
|
|
||||||
extractedExternally += took.amount;
|
extractedExternally += took.getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack == null) {
|
if (newStack == null) {
|
||||||
newStack = took;
|
newStack = took;
|
||||||
} else {
|
} else {
|
||||||
newStack.amount += took.amount;
|
newStack.grow(took.getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
received += took.amount;
|
received += took.getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requested == received) {
|
if (requested == received) {
|
||||||
@@ -485,8 +494,8 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack != null && newStack.amount - extractedExternally > 0 && action == Action.PERFORM) {
|
if (newStack != null && newStack.getAmount() - extractedExternally > 0 && action == Action.PERFORM) {
|
||||||
fluidStorage.remove(newStack, newStack.amount - extractedExternally, false);
|
fluidStorage.remove(newStack, newStack.getAmount() - extractedExternally, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return newStack;
|
return newStack;
|
||||||
@@ -511,8 +520,8 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
public void read(CompoundNBT tag) {
|
public void read(CompoundNBT tag) {
|
||||||
super.read(tag);
|
super.read(tag);
|
||||||
|
|
||||||
if (tag.hasKey(NBT_ENERGY)) {
|
if (tag.contains(NBT_ENERGY)) {
|
||||||
this.energy.setStored(tag.getInteger(NBT_ENERGY));
|
this.energy.setStored(tag.getInt(NBT_ENERGY));
|
||||||
}
|
}
|
||||||
|
|
||||||
redstoneMode = RedstoneMode.read(tag);
|
redstoneMode = RedstoneMode.read(tag);
|
||||||
@@ -521,11 +530,11 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
|
|
||||||
readerWriterManager.readFromNbt(tag);
|
readerWriterManager.readFromNbt(tag);
|
||||||
|
|
||||||
if (tag.hasKey(NBT_ITEM_STORAGE_TRACKER)) {
|
if (tag.contains(NBT_ITEM_STORAGE_TRACKER)) {
|
||||||
itemStorageTracker.readFromNbt(tag.getList(NBT_ITEM_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
itemStorageTracker.readFromNbt(tag.getList(NBT_ITEM_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.hasKey(NBT_FLUID_STORAGE_TRACKER)) {
|
if (tag.contains(NBT_FLUID_STORAGE_TRACKER)) {
|
||||||
fluidStorageTracker.readFromNbt(tag.getList(NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
fluidStorageTracker.readFromNbt(tag.getList(NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -559,8 +568,8 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readUpdate(CompoundNBT tag) {
|
public void readUpdate(CompoundNBT tag) {
|
||||||
if (tag.hasKey(NBT_ENERGY_TYPE)) {
|
if (tag.contains(NBT_ENERGY_TYPE)) {
|
||||||
this.energyType = ControllerEnergyType.getById(tag.getInteger(NBT_ENERGY_TYPE));
|
this.energyType = ControllerEnergyType.getById(tag.getInt(NBT_ENERGY_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.readUpdate(tag);
|
super.readUpdate(tag);
|
||||||
@@ -624,11 +633,11 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemStack() {
|
public ItemStack getItemStack() {
|
||||||
IBlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
|
|
||||||
Item item = Item.getItemFromBlock(state.getBlock());
|
Item item = Item.getItemFromBlock(state.getBlock());
|
||||||
|
|
||||||
return new ItemStack(item, 1, state.getBlock().getMetaFromState(state));
|
return new ItemStack(item, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -651,35 +660,35 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControllerType getType() {
|
@Override
|
||||||
|
public void update() {
|
||||||
|
// This is update from INetworkNode
|
||||||
|
}
|
||||||
|
|
||||||
|
public ControllerType getControllerType() {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
IBlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
|
|
||||||
if (state.getBlock() == RSBlocks.CONTROLLER) {
|
if (state.getBlock() == RSBlocks.CONTROLLER) {
|
||||||
this.type = (ControllerType) state.getValue(BlockController.TYPE);
|
this.type = state.get(BlockController.TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return type == null ? ControllerType.NORMAL : type;
|
return type == null ? ControllerType.NORMAL : type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap) {
|
||||||
if (capability == CapabilityEnergy.ENERGY) {
|
if (cap == CapabilityEnergy.ENERGY) {
|
||||||
return CapabilityEnergy.ENERGY.cast(energyProxy);
|
return energyProxyCap.cast();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (capability == CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY) {
|
if (cap == NETWORK_NODE_PROXY_CAPABILITY) {
|
||||||
return CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY.cast(this);
|
return networkNodeProxyCap.cast();
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getCapability(capability, facing);
|
return super.getCapability(cap);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
|
||||||
return capability == CapabilityEnergy.ENERGY
|
|
||||||
|| capability == CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY
|
|
||||||
|| super.hasCapability(capability, facing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -690,18 +699,21 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(Operator operator) {
|
public void visit(Operator operator) {
|
||||||
for (Direction facing : Direction.VALUES) {
|
for (Direction facing : Direction.values()) {
|
||||||
BlockPos pos = this.pos.offset(facing);
|
BlockPos pos = this.pos.offset(facing);
|
||||||
|
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
|
|
||||||
// Little hack to support not conducting through covers (if the cover is right next to the controller).
|
// Little hack to support not conducting through covers (if the cover is right next to the controller).
|
||||||
if (tile != null && tile.hasCapability(NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite())) {
|
if (tile != null) {
|
||||||
INetworkNodeProxy otherNodeProxy = NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite()));
|
INetworkNodeProxy otherNodeProxy = tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY).orElse(null);
|
||||||
INetworkNode otherNode = otherNodeProxy.getNode();
|
|
||||||
|
|
||||||
if (otherNode instanceof ICoverable && ((ICoverable) otherNode).getCoverManager().hasCover(facing.getOpposite())) {
|
if (otherNodeProxy != null) {
|
||||||
continue;
|
INetworkNode otherNode = otherNodeProxy.getNode();
|
||||||
|
|
||||||
|
if (otherNode instanceof ICoverable && ((ICoverable) otherNode).getCoverManager().hasCover(facing.getOpposite())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -722,7 +734,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
|
|
||||||
TileController otherController = (TileController) o;
|
TileController otherController = (TileController) o;
|
||||||
|
|
||||||
if (world.provider.getDimension() != otherController.world.provider.getDimension()) {
|
if (world.getDimension().getType() != otherController.world.getDimension().getType()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -732,7 +744,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = pos.hashCode();
|
int result = pos.hashCode();
|
||||||
result = 31 * result + world.provider.getDimension();
|
result = 31 * result + world.getDimension().getType().getId();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,14 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafter;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafter;
|
||||||
import com.raoulvdberge.refinedstorage.gui.TileDataParameterClientListenerCrafter;
|
import com.raoulvdberge.refinedstorage.gui.TileDataParameterClientListenerCrafter;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TileCrafter extends TileNode<NetworkNodeCrafter> {
|
public class TileCrafter extends TileNode<NetworkNodeCrafter> {
|
||||||
public static final TileDataParameter<String, TileCrafter> NAME = new TileDataParameter<>(DataSerializers.STRING, NetworkNodeCrafter.DEFAULT_NAME, t -> t.getNode().getName());
|
public static final TileDataParameter<String, TileCrafter> NAME = new TileDataParameter<>(DataSerializers.STRING, NetworkNodeCrafter.DEFAULT_NAME, t -> t.getNode().getName());
|
||||||
@@ -19,6 +16,8 @@ public class TileCrafter extends TileNode<NetworkNodeCrafter> {
|
|||||||
private static final TileDataParameter<Boolean, TileCrafter> HAS_ROOT = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().getRootContainerNotSelf().isPresent(), null, (t, v) -> new TileDataParameterClientListenerCrafter().onChanged(t, v));
|
private static final TileDataParameter<Boolean, TileCrafter> HAS_ROOT = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().getRootContainerNotSelf().isPresent(), null, (t, v) -> new TileDataParameterClientListenerCrafter().onChanged(t, v));
|
||||||
|
|
||||||
public TileCrafter() {
|
public TileCrafter() {
|
||||||
|
super(RSTiles.CRAFTER);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(NAME);
|
dataManager.addWatchedParameter(NAME);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
dataManager.addParameter(HAS_ROOT);
|
dataManager.addParameter(HAS_ROOT);
|
||||||
@@ -35,7 +34,7 @@ public class TileCrafter extends TileNode<NetworkNodeCrafter> {
|
|||||||
return NetworkNodeCrafter.ID;
|
return NetworkNodeCrafter.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* TODO @Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||||
}
|
}
|
||||||
@@ -47,5 +46,5 @@ public class TileCrafter extends TileNode<NetworkNodeCrafter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return super.getCapability(capability, facing);
|
return super.getCapability(capability, facing);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafterManager;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafterManager;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
@@ -15,7 +16,7 @@ public class TileCrafterManager extends TileNode<NetworkNodeCrafterManager> {
|
|||||||
t.getNode().setSize(v);
|
t.getNode().setSize(v);
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
}
|
}
|
||||||
}, (initial, p) -> GuiBase.executeLater(GuiCrafterManager.class, GuiBase::initGui));
|
}, (initial, p) -> GuiBase.executeLater(GuiCrafterManager.class, GuiBase::init));
|
||||||
public static final TileDataParameter<Integer, TileCrafterManager> SEARCH_BOX_MODE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSearchBoxMode(), (t, v) -> {
|
public static final TileDataParameter<Integer, TileCrafterManager> SEARCH_BOX_MODE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSearchBoxMode(), (t, v) -> {
|
||||||
if (IGrid.isValidSearchBoxMode(v)) {
|
if (IGrid.isValidSearchBoxMode(v)) {
|
||||||
t.getNode().setSearchBoxMode(v);
|
t.getNode().setSearchBoxMode(v);
|
||||||
@@ -24,6 +25,8 @@ public class TileCrafterManager extends TileNode<NetworkNodeCrafterManager> {
|
|||||||
}, (initial, p) -> GuiBase.executeLater(GuiCrafterManager.class, crafterManager -> crafterManager.getSearchField().setMode(p)));
|
}, (initial, p) -> GuiBase.executeLater(GuiCrafterManager.class, crafterManager -> crafterManager.getSearchField().setMode(p)));
|
||||||
|
|
||||||
public TileCrafterManager() {
|
public TileCrafterManager() {
|
||||||
|
super(RSTiles.CRAFTER_MANAGER);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(SIZE);
|
dataManager.addWatchedParameter(SIZE);
|
||||||
dataManager.addWatchedParameter(SEARCH_BOX_MODE);
|
dataManager.addWatchedParameter(SEARCH_BOX_MODE);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDestructor;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDestructor;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
@@ -21,6 +22,8 @@ public class TileDestructor extends TileNode<NetworkNodeDestructor> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
public TileDestructor() {
|
public TileDestructor() {
|
||||||
|
super(RSTiles.DESTRUCTOR);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
dataManager.addWatchedParameter(TYPE);
|
dataManager.addWatchedParameter(TYPE);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDetector;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeDetector;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiDetector;
|
import com.raoulvdberge.refinedstorage.gui.GuiDetector;
|
||||||
@@ -30,6 +31,8 @@ public class TileDetector extends TileNode<NetworkNodeDetector> {
|
|||||||
}, (initial, p) -> GuiBase.executeLater(GuiDetector.class, detector -> detector.getAmount().setText(String.valueOf(p))));
|
}, (initial, p) -> GuiBase.executeLater(GuiDetector.class, detector -> detector.getAmount().setText(String.valueOf(p))));
|
||||||
|
|
||||||
public TileDetector() {
|
public TileDetector() {
|
||||||
|
super(RSTiles.DETECTOR);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(TYPE);
|
dataManager.addWatchedParameter(TYPE);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.NetworkNodeDiskDrive;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.NetworkNodeDiskDrive;
|
||||||
@@ -8,14 +9,10 @@ import com.raoulvdberge.refinedstorage.tile.config.*;
|
|||||||
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
||||||
public static final TileDataParameter<Integer, TileDiskDrive> PRIORITY = IPrioritizable.createParameter();
|
public static final TileDataParameter<Integer, TileDiskDrive> PRIORITY = IPrioritizable.createParameter();
|
||||||
@@ -71,6 +68,8 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
|||||||
private Integer[] diskState = new Integer[8];
|
private Integer[] diskState = new Integer[8];
|
||||||
|
|
||||||
public TileDiskDrive() {
|
public TileDiskDrive() {
|
||||||
|
super(RSTiles.DISK_DRIVE);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(PRIORITY);
|
dataManager.addWatchedParameter(PRIORITY);
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
@@ -123,7 +122,7 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
|||||||
|
|
||||||
public static void readDiskState(CompoundNBT tag, Integer[] diskState) {
|
public static void readDiskState(CompoundNBT tag, Integer[] diskState) {
|
||||||
for (int i = 0; i < diskState.length; ++i) {
|
for (int i = 0; i < diskState.length; ++i) {
|
||||||
diskState[i] = tag.getInteger(String.format(NBT_DISK_STATE, i));
|
diskState[i] = tag.getInt(String.format(NBT_DISK_STATE, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +132,7 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* TODO @Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||||
}
|
}
|
||||||
@@ -145,7 +144,7 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return super.getCapability(capability, facing);
|
return super.getCapability(capability, facing);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskmanipulator.NetworkNodeDiskManipulator;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskmanipulator.NetworkNodeDiskManipulator;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
@@ -7,14 +8,10 @@ import com.raoulvdberge.refinedstorage.tile.config.IType;
|
|||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
|
public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
|
||||||
public static final TileDataParameter<Integer, TileDiskManipulator> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer, TileDiskManipulator> COMPARE = IComparable.createParameter();
|
||||||
@@ -28,6 +25,8 @@ public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
|
|||||||
private Integer[] diskState = new Integer[6];
|
private Integer[] diskState = new Integer[6];
|
||||||
|
|
||||||
public TileDiskManipulator() {
|
public TileDiskManipulator() {
|
||||||
|
super(RSTiles.DISK_MANIPULATOR);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
dataManager.addWatchedParameter(TYPE);
|
dataManager.addWatchedParameter(TYPE);
|
||||||
@@ -56,7 +55,7 @@ public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
|
|||||||
return diskState;
|
return diskState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/* TODO @Override
|
||||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getDisks());
|
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getDisks());
|
||||||
@@ -68,7 +67,7 @@ public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExporter;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExporter;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
@@ -14,6 +15,8 @@ public class TileExporter extends TileNode<NetworkNodeExporter> {
|
|||||||
public static final TileDataParameter<Integer, TileExporter> TYPE = IType.createParameter();
|
public static final TileDataParameter<Integer, TileExporter> TYPE = IType.createParameter();
|
||||||
|
|
||||||
public TileExporter() {
|
public TileExporter() {
|
||||||
|
super(RSTiles.EXPORTER);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(TYPE);
|
dataManager.addWatchedParameter(TYPE);
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
|
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExternalStorage;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeExternalStorage;
|
||||||
@@ -47,6 +48,8 @@ public class TileExternalStorage extends TileNode<NetworkNodeExternalStorage> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
public TileExternalStorage() {
|
public TileExternalStorage() {
|
||||||
|
super(RSTiles.EXTERNAL_STORAGE);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(PRIORITY);
|
dataManager.addWatchedParameter(PRIORITY);
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
|
@@ -1,28 +1,27 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeFluidInterface;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TileFluidInterface extends TileNode<NetworkNodeFluidInterface> {
|
public class TileFluidInterface extends TileNode<NetworkNodeFluidInterface> {
|
||||||
public static final TileDataParameter<FluidStack, TileFluidInterface> TANK_IN = new TileDataParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, null, t -> t.getNode().getTankIn().getFluid());
|
public static final TileDataParameter<FluidStack, TileFluidInterface> TANK_IN = new TileDataParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, null, t -> t.getNode().getTankIn().getFluid());
|
||||||
public static final TileDataParameter<FluidStack, TileFluidInterface> TANK_OUT = new TileDataParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, null, t -> t.getNode().getTankOut().getFluid());
|
public static final TileDataParameter<FluidStack, TileFluidInterface> TANK_OUT = new TileDataParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, null, t -> t.getNode().getTankOut().getFluid());
|
||||||
|
|
||||||
public TileFluidInterface() {
|
public TileFluidInterface() {
|
||||||
|
super(RSTiles.FLUID_INTERFACE);
|
||||||
|
|
||||||
dataManager.addParameter(TANK_IN);
|
dataManager.addParameter(TANK_IN);
|
||||||
dataManager.addParameter(TANK_OUT);
|
dataManager.addParameter(TANK_OUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||||
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||||
@@ -37,7 +36,7 @@ public class TileFluidInterface extends TileNode<NetworkNodeFluidInterface> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return super.getCapability(capability, facing);
|
return super.getCapability(capability, facing);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IAccessType;
|
import com.raoulvdberge.refinedstorage.tile.config.IAccessType;
|
||||||
@@ -21,6 +22,8 @@ public class TileFluidStorage extends TileNode<NetworkNodeFluidStorage> {
|
|||||||
public static final TileDataParameter<Long, TileFluidStorage> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> t.getNode().getStorage() != null ? (long) t.getNode().getStorage().getStored() : 0);
|
public static final TileDataParameter<Long, TileFluidStorage> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> t.getNode().getStorage() != null ? (long) t.getNode().getStorage().getStored() : 0);
|
||||||
|
|
||||||
public TileFluidStorage() {
|
public TileFluidStorage() {
|
||||||
|
super(RSTiles.FLUID_STORAGE);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(PRIORITY);
|
dataManager.addWatchedParameter(PRIORITY);
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeImporter;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeImporter;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||||
@@ -16,6 +17,8 @@ public class TileImporter extends TileNode<NetworkNodeImporter> {
|
|||||||
public static final TileDataParameter<Integer, TileImporter> TYPE = IType.createParameter();
|
public static final TileDataParameter<Integer, TileImporter> TYPE = IType.createParameter();
|
||||||
|
|
||||||
public TileImporter() {
|
public TileImporter() {
|
||||||
|
super(RSTiles.IMPORTER);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
dataManager.addWatchedParameter(TYPE);
|
dataManager.addWatchedParameter(TYPE);
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeInterface;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeInterface;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TileInterface extends TileNode<NetworkNodeInterface> {
|
public class TileInterface extends TileNode<NetworkNodeInterface> {
|
||||||
public static final TileDataParameter<Integer, TileInterface> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer, TileInterface> COMPARE = IComparable.createParameter();
|
||||||
|
|
||||||
public TileInterface() {
|
public TileInterface() {
|
||||||
|
super(RSTiles.INTERFACE);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO
|
||||||
@Override
|
@Override
|
||||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
||||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItems()) : super.getCapability(capability, facing);
|
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(getNode().getItems()) : super.getCapability(capability, facing);
|
||||||
@@ -27,7 +27,7 @@ public class TileInterface extends TileNode<NetworkNodeInterface> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeNetworkReceiver;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeNetworkReceiver;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -7,6 +8,10 @@ import net.minecraft.world.World;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class TileNetworkReceiver extends TileNode<NetworkNodeNetworkReceiver> {
|
public class TileNetworkReceiver extends TileNode<NetworkNodeNetworkReceiver> {
|
||||||
|
public TileNetworkReceiver() {
|
||||||
|
super(RSTiles.NETWORK_RECEIVER);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public NetworkNodeNetworkReceiver createNode(World world, BlockPos pos) {
|
public NetworkNodeNetworkReceiver createNode(World world, BlockPos pos) {
|
||||||
|
@@ -1,16 +1,13 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeNetworkTransmitter;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeNetworkTransmitter;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TileNetworkTransmitter extends TileNode<NetworkNodeNetworkTransmitter> {
|
public class TileNetworkTransmitter extends TileNode<NetworkNodeNetworkTransmitter> {
|
||||||
public static final TileDataParameter<Integer, TileNetworkTransmitter> DISTANCE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> {
|
public static final TileDataParameter<Integer, TileNetworkTransmitter> DISTANCE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> {
|
||||||
@@ -22,6 +19,8 @@ public class TileNetworkTransmitter extends TileNode<NetworkNodeNetworkTransmitt
|
|||||||
public static final TileDataParameter<Integer, TileNetworkTransmitter> RECEIVER_DIMENSION = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getReceiverDimension());
|
public static final TileDataParameter<Integer, TileNetworkTransmitter> RECEIVER_DIMENSION = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getReceiverDimension());
|
||||||
|
|
||||||
public TileNetworkTransmitter() {
|
public TileNetworkTransmitter() {
|
||||||
|
super(RSTiles.NETWORK_TRANSMITTER);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(DISTANCE);
|
dataManager.addWatchedParameter(DISTANCE);
|
||||||
dataManager.addWatchedParameter(RECEIVER_DIMENSION);
|
dataManager.addWatchedParameter(RECEIVER_DIMENSION);
|
||||||
}
|
}
|
||||||
@@ -37,6 +36,7 @@ public class TileNetworkTransmitter extends TileNode<NetworkNodeNetworkTransmitt
|
|||||||
return NetworkNodeNetworkTransmitter.ID;
|
return NetworkNodeNetworkTransmitter.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||||
@@ -49,5 +49,5 @@ public class TileNetworkTransmitter extends TileNode<NetworkNodeNetworkTransmitt
|
|||||||
}
|
}
|
||||||
|
|
||||||
return super.getCapability(capability, facing);
|
return super.getCapability(capability, facing);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
@@ -1,23 +1,16 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReader;
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandler;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerFactory;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiReaderWriter;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiReaderWriter;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeReader;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeReader;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiReaderWriter;
|
import com.raoulvdberge.refinedstorage.gui.GuiReaderWriter;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TileReader extends TileNode<NetworkNodeReader> {
|
public class TileReader extends TileNode<NetworkNodeReader> {
|
||||||
static <T extends TileNode> TileDataParameter<String, T> createChannelParameter() {
|
static <T extends TileNode> TileDataParameter<String, T> createChannelParameter() {
|
||||||
@@ -31,9 +24,12 @@ public class TileReader extends TileNode<NetworkNodeReader> {
|
|||||||
public static final TileDataParameter<String, TileReader> CHANNEL = createChannelParameter();
|
public static final TileDataParameter<String, TileReader> CHANNEL = createChannelParameter();
|
||||||
|
|
||||||
public TileReader() {
|
public TileReader() {
|
||||||
|
super(RSTiles.READER);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(CHANNEL);
|
dataManager.addWatchedParameter(CHANNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||||
if (super.hasCapability(capability, facing)) {
|
if (super.hasCapability(capability, facing)) {
|
||||||
@@ -93,7 +89,7 @@ public class TileReader extends TileNode<NetworkNodeReader> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return foundCapability;
|
return foundCapability;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeRelay;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeRelay;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -7,6 +8,10 @@ import net.minecraft.world.World;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class TileRelay extends TileNode<NetworkNodeRelay> {
|
public class TileRelay extends TileNode<NetworkNodeRelay> {
|
||||||
|
public TileRelay() {
|
||||||
|
super(RSTiles.RELAY);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public NetworkNodeRelay createNode(World world, BlockPos pos) {
|
public NetworkNodeRelay createNode(World world, BlockPos pos) {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSecurityManager;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSecurityManager;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -7,6 +8,10 @@ import net.minecraft.world.World;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class TileSecurityManager extends TileNode<NetworkNodeSecurityManager> {
|
public class TileSecurityManager extends TileNode<NetworkNodeSecurityManager> {
|
||||||
|
public TileSecurityManager() {
|
||||||
|
super(RSTiles.SECURITY_MANAGER);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public NetworkNodeSecurityManager createNode(World world, BlockPos pos) {
|
public NetworkNodeSecurityManager createNode(World world, BlockPos pos) {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IAccessType;
|
import com.raoulvdberge.refinedstorage.tile.config.IAccessType;
|
||||||
@@ -21,6 +22,8 @@ public class TileStorage extends TileNode<NetworkNodeStorage> {
|
|||||||
public static final TileDataParameter<Long, TileStorage> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> t.getNode().getStorage() != null ? (long) t.getNode().getStorage().getStored() : 0);
|
public static final TileDataParameter<Long, TileStorage> STORED = new TileDataParameter<>(RSSerializers.LONG_SERIALIZER, 0L, t -> t.getNode().getStorage() != null ? (long) t.getNode().getStorage().getStored() : 0);
|
||||||
|
|
||||||
public TileStorage() {
|
public TileStorage() {
|
||||||
|
super(RSTiles.STORAGE);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(PRIORITY);
|
dataManager.addWatchedParameter(PRIORITY);
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
dataManager.addWatchedParameter(MODE);
|
dataManager.addWatchedParameter(MODE);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeStorageMonitor;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeStorageMonitor;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
@@ -22,6 +23,8 @@ public class TileStorageMonitor extends TileNode<NetworkNodeStorageMonitor> {
|
|||||||
private ItemStack itemStack;
|
private ItemStack itemStack;
|
||||||
|
|
||||||
public TileStorageMonitor() {
|
public TileStorageMonitor() {
|
||||||
|
super(RSTiles.STORAGE_MONITOR);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(COMPARE);
|
dataManager.addWatchedParameter(COMPARE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +45,7 @@ public class TileStorageMonitor extends TileNode<NetworkNodeStorageMonitor> {
|
|||||||
ItemStack stack = getNode().getItemFilters().getStackInSlot(0);
|
ItemStack stack = getNode().getItemFilters().getStackInSlot(0);
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
tag.put(NBT_STACK, stack.writeToNBT(new CompoundNBT()));
|
tag.put(NBT_STACK, stack.write(new CompoundNBT()));
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.putInt(NBT_AMOUNT, getNode().getAmount());
|
tag.putInt(NBT_AMOUNT, getNode().getAmount());
|
||||||
@@ -54,13 +57,13 @@ public class TileStorageMonitor extends TileNode<NetworkNodeStorageMonitor> {
|
|||||||
public void readUpdate(CompoundNBT tag) {
|
public void readUpdate(CompoundNBT tag) {
|
||||||
super.readUpdate(tag);
|
super.readUpdate(tag);
|
||||||
|
|
||||||
itemStack = tag.hasKey(NBT_STACK) ? new ItemStack(tag.getCompound(NBT_STACK)) : null;
|
itemStack = tag.contains(NBT_STACK) ? ItemStack.read(tag.getCompound(NBT_STACK)) : null;
|
||||||
amount = tag.getInteger(NBT_AMOUNT);
|
amount = tag.getInt(NBT_AMOUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canCauseRenderUpdate(CompoundNBT tag) {
|
protected boolean canCauseRenderUpdate(CompoundNBT tag) {
|
||||||
Direction receivedDirection = Direction.byIndex(tag.getInteger(NBT_DIRECTION));
|
Direction receivedDirection = Direction.byIndex(tag.getInt(NBT_DIRECTION));
|
||||||
boolean receivedActive = tag.getBoolean(NBT_ACTIVE);
|
boolean receivedActive = tag.getBoolean(NBT_ACTIVE);
|
||||||
|
|
||||||
return receivedDirection != getDirection() || receivedActive != getNode().isActive();
|
return receivedDirection != getDirection() || receivedActive != getNode().isActive();
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWirelessTransmitter;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWirelessTransmitter;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
@@ -12,6 +13,8 @@ public class TileWirelessTransmitter extends TileNode<NetworkNodeWirelessTransmi
|
|||||||
public static final TileDataParameter<Integer, TileWirelessTransmitter> RANGE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getRange());
|
public static final TileDataParameter<Integer, TileWirelessTransmitter> RANGE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getRange());
|
||||||
|
|
||||||
public TileWirelessTransmitter() {
|
public TileWirelessTransmitter() {
|
||||||
|
super(RSTiles.WIRELESS_TRANSMITTER);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(RANGE);
|
dataManager.addWatchedParameter(RANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,27 +1,23 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile;
|
package com.raoulvdberge.refinedstorage.tile;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandler;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerFactory;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IWriter;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWriter;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWriter;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TileWriter extends TileNode<NetworkNodeWriter> {
|
public class TileWriter extends TileNode<NetworkNodeWriter> {
|
||||||
public static final TileDataParameter<String, TileWriter> CHANNEL = TileReader.createChannelParameter();
|
public static final TileDataParameter<String, TileWriter> CHANNEL = TileReader.createChannelParameter();
|
||||||
|
|
||||||
public TileWriter() {
|
public TileWriter() {
|
||||||
|
super(RSTiles.WRITER);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(CHANNEL);
|
dataManager.addWatchedParameter(CHANNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||||
if (super.hasCapability(capability, facing)) {
|
if (super.hasCapability(capability, facing)) {
|
||||||
@@ -81,7 +77,7 @@ public class TileWriter extends TileNode<NetworkNodeWriter> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return foundCapability;
|
return foundCapability;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile.craftingmonitor;
|
package com.raoulvdberge.refinedstorage.tile.craftingmonitor;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingManager;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingManager;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
@@ -9,6 +8,7 @@ import net.minecraft.entity.player.ServerPlayerEntity;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface ICraftingMonitor {
|
public interface ICraftingMonitor {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile.craftingmonitor;
|
package com.raoulvdberge.refinedstorage.tile.craftingmonitor;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCraftingMonitor;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCraftingMonitor;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
@@ -9,12 +9,13 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TileCraftingMonitor extends TileNode<NetworkNodeCraftingMonitor> {
|
public class TileCraftingMonitor extends TileNode<NetworkNodeCraftingMonitor> {
|
||||||
public static final TileDataParameter<Optional<UUID>, TileCraftingMonitor> TAB_SELECTED = new TileDataParameter<>(DataSerializers.OPTIONAL_UNIQUE_ID, Optional.absent(), t -> t.getNode().getTabSelected(), (t, v) -> {
|
public static final TileDataParameter<Optional<UUID>, TileCraftingMonitor> TAB_SELECTED = new TileDataParameter<>(DataSerializers.OPTIONAL_UNIQUE_ID, Optional.empty(), t -> t.getNode().getTabSelected(), (t, v) -> {
|
||||||
if (v.isPresent() && t.getNode().getTabSelected().isPresent() && v.get().equals(t.getNode().getTabSelected().get())) {
|
if (v.isPresent() && t.getNode().getTabSelected().isPresent() && v.get().equals(t.getNode().getTabSelected().get())) {
|
||||||
t.getNode().setTabSelected(Optional.absent());
|
t.getNode().setTabSelected(Optional.empty());
|
||||||
} else {
|
} else {
|
||||||
t.getNode().setTabSelected(v);
|
t.getNode().setTabSelected(v);
|
||||||
}
|
}
|
||||||
@@ -29,6 +30,8 @@ public class TileCraftingMonitor extends TileNode<NetworkNodeCraftingMonitor> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
public TileCraftingMonitor() {
|
public TileCraftingMonitor() {
|
||||||
|
super(RSTiles.CRAFTING_MONITOR);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(TAB_SELECTED);
|
dataManager.addWatchedParameter(TAB_SELECTED);
|
||||||
dataManager.addWatchedParameter(TAB_PAGE);
|
dataManager.addWatchedParameter(TAB_PAGE);
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile.craftingmonitor;
|
package com.raoulvdberge.refinedstorage.tile.craftingmonitor;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingManager;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingManager;
|
||||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemWirelessCraftingMonitor;
|
import com.raoulvdberge.refinedstorage.item.ItemWirelessCraftingMonitor;
|
||||||
import com.raoulvdberge.refinedstorage.network.MessageWirelessCraftingMonitorSettings;
|
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
@@ -14,7 +12,6 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -80,7 +77,8 @@ public class WirelessCraftingMonitor implements ICraftingMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private INetwork getNetwork() {
|
private INetwork getNetwork() {
|
||||||
World world = DimensionManager.getWorld(networkDimension);
|
// TODO World world = DimensionManager.getWorld(networkDimension);
|
||||||
|
World world = null;
|
||||||
|
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
TileEntity tile = world.getTileEntity(network);
|
TileEntity tile = world.getTileEntity(network);
|
||||||
@@ -127,7 +125,7 @@ public class WirelessCraftingMonitor implements ICraftingMonitor {
|
|||||||
this.tabSelected = taskId;
|
this.tabSelected = taskId;
|
||||||
}
|
}
|
||||||
|
|
||||||
RS.INSTANCE.network.sendToServer(new MessageWirelessCraftingMonitorSettings(tabSelected, tabPage));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageWirelessCraftingMonitorSettings(tabSelected, tabPage));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -135,7 +133,7 @@ public class WirelessCraftingMonitor implements ICraftingMonitor {
|
|||||||
if (page >= 0) {
|
if (page >= 0) {
|
||||||
this.tabPage = page;
|
this.tabPage = page;
|
||||||
|
|
||||||
RS.INSTANCE.network.sendToServer(new MessageWirelessCraftingMonitorSettings(tabSelected, tabPage));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageWirelessCraftingMonitorSettings(tabSelected, tabPage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile.grid;
|
package com.raoulvdberge.refinedstorage.tile.grid;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
||||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||||
@@ -9,14 +9,10 @@ import com.raoulvdberge.refinedstorage.tile.TileNode;
|
|||||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class TileGrid extends TileNode<NetworkNodeGrid> {
|
public class TileGrid extends TileNode<NetworkNodeGrid> {
|
||||||
public static final TileDataParameter<Integer, TileGrid> VIEW_TYPE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getViewType(), (t, v) -> {
|
public static final TileDataParameter<Integer, TileGrid> VIEW_TYPE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getViewType(), (t, v) -> {
|
||||||
@@ -48,7 +44,7 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
|||||||
t.getNode().setSize(v);
|
t.getNode().setSize(v);
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
}
|
}
|
||||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::init));
|
||||||
public static final TileDataParameter<Integer, TileGrid> TAB_SELECTED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getTabSelected(), (t, v) -> {
|
public static final TileDataParameter<Integer, TileGrid> TAB_SELECTED = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getTabSelected(), (t, v) -> {
|
||||||
t.getNode().setTabSelected(v == t.getNode().getTabSelected() ? -1 : v);
|
t.getNode().setTabSelected(v == t.getNode().getTabSelected() ? -1 : v);
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
@@ -67,8 +63,8 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
|||||||
t.getNode().setProcessingPattern(v);
|
t.getNode().setProcessingPattern(v);
|
||||||
t.getNode().clearMatrix();
|
t.getNode().clearMatrix();
|
||||||
t.getNode().markDirty();
|
t.getNode().markDirty();
|
||||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::init));
|
||||||
public static final TileDataParameter<Integer, TileGrid> PROCESSING_TYPE = IType.createParameter((initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
public static final TileDataParameter<Integer, TileGrid> PROCESSING_TYPE = IType.createParameter((initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::init));
|
||||||
|
|
||||||
public static void trySortGrid(boolean initial) {
|
public static void trySortGrid(boolean initial) {
|
||||||
if (!initial) {
|
if (!initial) {
|
||||||
@@ -77,6 +73,8 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TileGrid() {
|
public TileGrid() {
|
||||||
|
super(RSTiles.GRID);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(VIEW_TYPE);
|
dataManager.addWatchedParameter(VIEW_TYPE);
|
||||||
dataManager.addWatchedParameter(SORTING_DIRECTION);
|
dataManager.addWatchedParameter(SORTING_DIRECTION);
|
||||||
dataManager.addWatchedParameter(SORTING_TYPE);
|
dataManager.addWatchedParameter(SORTING_TYPE);
|
||||||
@@ -100,6 +98,7 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
|||||||
return NetworkNodeGrid.ID;
|
return NetworkNodeGrid.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction side) {
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction side) {
|
||||||
return (getNode().getGridType() == GridType.PATTERN && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) || super.hasCapability(capability, side);
|
return (getNode().getGridType() == GridType.PATTERN && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) || super.hasCapability(capability, side);
|
||||||
@@ -112,5 +111,5 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return super.getCapability(capability, side);
|
return super.getCapability(capability, side);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile.grid;
|
package com.raoulvdberge.refinedstorage.tile.grid;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.*;
|
import com.raoulvdberge.refinedstorage.api.network.grid.*;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
||||||
@@ -13,19 +12,17 @@ import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
|||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
|
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemWirelessFluidGrid;
|
import com.raoulvdberge.refinedstorage.item.ItemWirelessFluidGrid;
|
||||||
import com.raoulvdberge.refinedstorage.network.MessageWirelessFluidGridSettingsUpdate;
|
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.inventory.InventoryCraftResult;
|
import net.minecraft.inventory.CraftResultInventory;
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -54,11 +51,11 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|
||||||
if (!stack.hasTagCompound()) {
|
if (!stack.hasTag()) {
|
||||||
stack.setTagCompound(new CompoundNBT());
|
stack.setTag(new CompoundNBT());
|
||||||
}
|
}
|
||||||
|
|
||||||
StackUtils.writeItems(this, 0, stack.getTagCompound());
|
StackUtils.writeItems(this, 0, stack.getTag());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -75,8 +72,8 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
this.tabPage = ItemWirelessFluidGrid.getTabPage(stack);
|
this.tabPage = ItemWirelessFluidGrid.getTabPage(stack);
|
||||||
this.size = ItemWirelessFluidGrid.getSize(stack);
|
this.size = ItemWirelessFluidGrid.getSize(stack);
|
||||||
|
|
||||||
if (stack.hasTagCompound()) {
|
if (stack.hasTag()) {
|
||||||
StackUtils.readItems(filter, 0, stack.getTagCompound());
|
StackUtils.readItems(filter, 0, stack.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +89,8 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public INetwork getNetwork() {
|
public INetwork getNetwork() {
|
||||||
World world = DimensionManager.getWorld(networkDimension);
|
// TODO World world = DimensionManager.getWorld(networkDimension);
|
||||||
|
World world = null;
|
||||||
|
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
TileEntity tile = world.getTileEntity(network);
|
TileEntity tile = world.getTileEntity(network);
|
||||||
@@ -192,7 +190,7 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingTypeChanged(int type) {
|
public void onSortingTypeChanged(int type) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), type, getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), type, getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.sortingType = type;
|
this.sortingType = type;
|
||||||
|
|
||||||
@@ -201,7 +199,7 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingDirectionChanged(int direction) {
|
public void onSortingDirectionChanged(int direction) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(direction, getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(direction, getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.sortingDirection = direction;
|
this.sortingDirection = direction;
|
||||||
|
|
||||||
@@ -210,19 +208,19 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchBoxModeChanged(int searchBoxMode) {
|
public void onSearchBoxModeChanged(int searchBoxMode) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), getSortingType(), searchBoxMode, getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), getSortingType(), searchBoxMode, getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.searchBoxMode = searchBoxMode;
|
this.searchBoxMode = searchBoxMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSizeChanged(int size) {
|
public void onSizeChanged(int size) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), getSortingType(), getSearchBoxMode(), size, getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), getSortingType(), getSearchBoxMode(), size, getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
||||||
if (Minecraft.getMinecraft().currentScreen != null) {
|
if (Minecraft.getInstance().currentScreen != null) {
|
||||||
Minecraft.getMinecraft().currentScreen.initGui();
|
// TODO Minecraft.getInstance().currentScreen.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +228,7 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
public void onTabSelectionChanged(int tab) {
|
public void onTabSelectionChanged(int tab) {
|
||||||
this.tabSelected = tab == tabSelected ? -1 : tab;
|
this.tabSelected = tab == tabSelected ? -1 : tab;
|
||||||
|
|
||||||
RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), tabSelected, getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), tabSelected, getTabPage()));
|
||||||
|
|
||||||
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
||||||
}
|
}
|
||||||
@@ -238,7 +236,7 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
@Override
|
@Override
|
||||||
public void onTabPageChanged(int page) {
|
public void onTabPageChanged(int page) {
|
||||||
if (page >= 0 && page <= getTotalTabPages()) {
|
if (page >= 0 && page <= getTotalTabPages()) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), page));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageWirelessFluidGridSettingsUpdate(getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), page));
|
||||||
|
|
||||||
this.tabPage = page;
|
this.tabPage = page;
|
||||||
}
|
}
|
||||||
@@ -260,12 +258,12 @@ public class WirelessFluidGrid implements IGridNetworkAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryCrafting getCraftingMatrix() {
|
public CraftingInventory getCraftingMatrix() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryCraftResult getCraftingResult() {
|
public CraftResultInventory getCraftingResult() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
package com.raoulvdberge.refinedstorage.tile.grid;
|
package com.raoulvdberge.refinedstorage.tile.grid;
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
|
||||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.*;
|
import com.raoulvdberge.refinedstorage.api.network.grid.*;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
import com.raoulvdberge.refinedstorage.api.network.grid.handler.IFluidGridHandler;
|
||||||
@@ -13,19 +12,16 @@ import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
|||||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
|
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemWirelessGrid;
|
import com.raoulvdberge.refinedstorage.item.ItemWirelessGrid;
|
||||||
import com.raoulvdberge.refinedstorage.network.MessageGridSettingsUpdate;
|
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.inventory.InventoryCraftResult;
|
import net.minecraft.inventory.CraftResultInventory;
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -55,11 +51,11 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|
||||||
if (!stack.hasTagCompound()) {
|
if (!stack.hasTag()) {
|
||||||
stack.setTagCompound(new CompoundNBT());
|
stack.setTag(new CompoundNBT());
|
||||||
}
|
}
|
||||||
|
|
||||||
StackUtils.writeItems(this, 0, stack.getTagCompound());
|
StackUtils.writeItems(this, 0, stack.getTag());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,8 +73,8 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
this.tabPage = ItemWirelessGrid.getTabPage(stack);
|
this.tabPage = ItemWirelessGrid.getTabPage(stack);
|
||||||
this.size = ItemWirelessGrid.getSize(stack);
|
this.size = ItemWirelessGrid.getSize(stack);
|
||||||
|
|
||||||
if (stack.hasTagCompound()) {
|
if (stack.hasTag()) {
|
||||||
StackUtils.readItems(filter, 0, stack.getTagCompound());
|
StackUtils.readItems(filter, 0, stack.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +90,8 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public INetwork getNetwork() {
|
public INetwork getNetwork() {
|
||||||
World world = DimensionManager.getWorld(networkDimension);
|
// TODO World world = DimensionManager.getWorld(networkDimension);
|
||||||
|
World world = null;
|
||||||
|
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
TileEntity tile = world.getTileEntity(network);
|
TileEntity tile = world.getTileEntity(network);
|
||||||
@@ -189,7 +186,7 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewTypeChanged(int type) {
|
public void onViewTypeChanged(int type) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(type, getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(type, getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.viewType = type;
|
this.viewType = type;
|
||||||
|
|
||||||
@@ -198,7 +195,7 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingTypeChanged(int type) {
|
public void onSortingTypeChanged(int type) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), type, getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), type, getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.sortingType = type;
|
this.sortingType = type;
|
||||||
|
|
||||||
@@ -207,7 +204,7 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingDirectionChanged(int direction) {
|
public void onSortingDirectionChanged(int direction) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), direction, getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), direction, getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.sortingDirection = direction;
|
this.sortingDirection = direction;
|
||||||
|
|
||||||
@@ -216,27 +213,27 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchBoxModeChanged(int searchBoxMode) {
|
public void onSearchBoxModeChanged(int searchBoxMode) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), searchBoxMode, getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), searchBoxMode, getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.searchBoxMode = searchBoxMode;
|
this.searchBoxMode = searchBoxMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSizeChanged(int size) {
|
public void onSizeChanged(int size) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), size, getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), size, getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
||||||
if (Minecraft.getMinecraft().currentScreen != null) {
|
// TODO if (Minecraft.getMinecraft().currentScreen != null) {
|
||||||
Minecraft.getMinecraft().currentScreen.initGui();
|
// Minecraft.getMinecraft().currentScreen.initGui();
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelectionChanged(int tab) {
|
public void onTabSelectionChanged(int tab) {
|
||||||
this.tabSelected = tab == tabSelected ? -1 : tab;
|
this.tabSelected = tab == tabSelected ? -1 : tab;
|
||||||
|
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), tabSelected, getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), tabSelected, getTabPage()));
|
||||||
|
|
||||||
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
||||||
}
|
}
|
||||||
@@ -244,7 +241,7 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
@Override
|
@Override
|
||||||
public void onTabPageChanged(int page) {
|
public void onTabPageChanged(int page) {
|
||||||
if (page >= 0 && page <= getTotalTabPages()) {
|
if (page >= 0 && page <= getTotalTabPages()) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), page));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), page));
|
||||||
|
|
||||||
this.tabPage = page;
|
this.tabPage = page;
|
||||||
}
|
}
|
||||||
@@ -266,12 +263,12 @@ public class WirelessGrid implements IGridNetworkAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryCrafting getCraftingMatrix() {
|
public CraftingInventory getCraftingMatrix() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryCraftResult getCraftingResult() {
|
public CraftResultInventory getCraftingResult() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -27,20 +27,16 @@ import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
|||||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
|
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
|
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemWirelessGrid;
|
import com.raoulvdberge.refinedstorage.item.ItemWirelessGrid;
|
||||||
import com.raoulvdberge.refinedstorage.item.itemblock.ItemBlockPortableGrid;
|
|
||||||
import com.raoulvdberge.refinedstorage.network.MessageGridSettingsUpdate;
|
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.inventory.InventoryCraftResult;
|
import net.minecraft.inventory.CraftResultInventory;
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -71,8 +67,8 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
private int tabPage;
|
private int tabPage;
|
||||||
private int size;
|
private int size;
|
||||||
|
|
||||||
private StorageTrackerItem storageTracker = new StorageTrackerItem(() -> stack.getTagCompound().put(NBT_STORAGE_TRACKER, getItemStorageTracker().serializeNbt()));
|
private StorageTrackerItem storageTracker = new StorageTrackerItem(() -> stack.getTag().put(NBT_STORAGE_TRACKER, getItemStorageTracker().serializeNbt()));
|
||||||
private StorageTrackerFluid fluidStorageTracker = new StorageTrackerFluid(() -> stack.getTagCompound().put(NBT_FLUID_STORAGE_TRACKER, getFluidStorageTracker().serializeNbt()));
|
private StorageTrackerFluid fluidStorageTracker = new StorageTrackerFluid(() -> stack.getTag().put(NBT_FLUID_STORAGE_TRACKER, getFluidStorageTracker().serializeNbt()));
|
||||||
|
|
||||||
private List<IFilter> filters = new ArrayList<>();
|
private List<IFilter> filters = new ArrayList<>();
|
||||||
private List<IGridTab> tabs = new ArrayList<>();
|
private List<IGridTab> tabs = new ArrayList<>();
|
||||||
@@ -81,11 +77,11 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|
||||||
if (!stack.hasTagCompound()) {
|
if (!stack.hasTag()) {
|
||||||
stack.setTagCompound(new CompoundNBT());
|
stack.setTag(new CompoundNBT());
|
||||||
}
|
}
|
||||||
|
|
||||||
StackUtils.writeItems(this, 0, stack.getTagCompound());
|
StackUtils.writeItems(this, 0, stack.getTag());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private ItemHandlerBase disk = new ItemHandlerBase(1, NetworkNodeDiskDrive.VALIDATOR_STORAGE_DISK) {
|
private ItemHandlerBase disk = new ItemHandlerBase(1, NetworkNodeDiskDrive.VALIDATOR_STORAGE_DISK) {
|
||||||
@@ -93,7 +89,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
protected void onContentsChanged(int slot) {
|
protected void onContentsChanged(int slot) {
|
||||||
super.onContentsChanged(slot);
|
super.onContentsChanged(slot);
|
||||||
|
|
||||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
if (/*TODO FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER*/false) {
|
||||||
ItemStack diskStack = getStackInSlot(slot);
|
ItemStack diskStack = getStackInSlot(slot);
|
||||||
|
|
||||||
if (diskStack.isEmpty()) {
|
if (diskStack.isEmpty()) {
|
||||||
@@ -127,7 +123,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
cache.invalidate();
|
cache.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
StackUtils.writeItems(this, 4, stack.getTagCompound());
|
StackUtils.writeItems(this, 4, stack.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -145,25 +141,21 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
this.size = ItemWirelessGrid.getSize(stack);
|
this.size = ItemWirelessGrid.getSize(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stack.hasTagCompound()) {
|
if (!stack.hasTag()) {
|
||||||
stack.setTagCompound(new CompoundNBT());
|
stack.setTag(new CompoundNBT());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getTagCompound().hasKey(NBT_STORAGE_TRACKER)) {
|
if (stack.getTag().contains(NBT_STORAGE_TRACKER)) {
|
||||||
storageTracker.readFromNbt(stack.getTagCompound().getList(NBT_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
storageTracker.readFromNbt(stack.getTag().getList(NBT_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getTagCompound().hasKey(NBT_FLUID_STORAGE_TRACKER)) {
|
if (stack.getTag().contains(NBT_FLUID_STORAGE_TRACKER)) {
|
||||||
fluidStorageTracker.readFromNbt(stack.getTagCompound().getList(NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
fluidStorageTracker.readFromNbt(stack.getTag().getList(NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
StackUtils.readItems(disk, 4, stack.getTagCompound());
|
StackUtils.readItems(disk, 4, stack.getTag());
|
||||||
|
|
||||||
if (!player.getEntityWorld().isRemote) {
|
StackUtils.readItems(filter, 0, stack.getTag());
|
||||||
API.instance().getOneSixMigrationHelper().migrateDiskInventory(player.getEntityWorld(), disk);
|
|
||||||
}
|
|
||||||
|
|
||||||
StackUtils.readItems(filter, 0, stack.getTagCompound());
|
|
||||||
|
|
||||||
drainEnergy(RS.INSTANCE.config.portableGridOpenUsage);
|
drainEnergy(RS.INSTANCE.config.portableGridOpenUsage);
|
||||||
}
|
}
|
||||||
@@ -186,18 +178,21 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drainEnergy(int energy) {
|
public void drainEnergy(int energy) {
|
||||||
if (RS.INSTANCE.config.portableGridUsesEnergy && stack.getItemDamage() != ItemBlockPortableGrid.TYPE_CREATIVE) {
|
//TODO if (RS.INSTANCE.config.portableGridUsesEnergy && stack.getItemDamage() != ItemBlockPortableGrid.TYPE_CREATIVE) {
|
||||||
stack.getCapability(CapabilityEnergy.ENERGY, null).extractEnergy(energy, false);
|
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||||
|
//}
|
||||||
|
if (storage != null) {
|
||||||
|
storage.extractEnergy(energy, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergy() {
|
public int getEnergy() {
|
||||||
if (RS.INSTANCE.config.portableGridUsesEnergy && stack.getItemDamage() != ItemBlockPortableGrid.TYPE_CREATIVE) {
|
//TODO if (RS.INSTANCE.config.portableGridUsesEnergy && stack.getItemDamage() != ItemBlockPortableGrid.TYPE_CREATIVE) {
|
||||||
return stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored();
|
IEnergyStorage storage = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return RS.INSTANCE.config.portableGridCapacity;
|
return storage == null ? RS.INSTANCE.config.portableGridCapacity : storage.getMaxEnergyStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -299,7 +294,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingTypeChanged(int type) {
|
public void onSortingTypeChanged(int type) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), type, getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), type, getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.sortingType = type;
|
this.sortingType = type;
|
||||||
|
|
||||||
@@ -308,7 +303,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSortingDirectionChanged(int direction) {
|
public void onSortingDirectionChanged(int direction) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), direction, getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), direction, getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.sortingDirection = direction;
|
this.sortingDirection = direction;
|
||||||
|
|
||||||
@@ -317,27 +312,27 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSearchBoxModeChanged(int searchBoxMode) {
|
public void onSearchBoxModeChanged(int searchBoxMode) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), searchBoxMode, getSize(), getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), searchBoxMode, getSize(), getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.searchBoxMode = searchBoxMode;
|
this.searchBoxMode = searchBoxMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSizeChanged(int size) {
|
public void onSizeChanged(int size) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), size, getTabSelected(), getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), size, getTabSelected(), getTabPage()));
|
||||||
|
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
||||||
if (Minecraft.getMinecraft().currentScreen != null) {
|
// TODO if (Minecraft.getMinecraft().currentScreen != null) {
|
||||||
Minecraft.getMinecraft().currentScreen.initGui();
|
// Minecraft.getMinecraft().currentScreen.initGui();
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelectionChanged(int tab) {
|
public void onTabSelectionChanged(int tab) {
|
||||||
this.tabSelected = tab == tabSelected ? -1 : tab;
|
this.tabSelected = tab == tabSelected ? -1 : tab;
|
||||||
|
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), tabSelected, getTabPage()));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), tabSelected, getTabPage()));
|
||||||
|
|
||||||
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
GuiBase.executeLater(GuiGrid.class, grid -> grid.getView().sort());
|
||||||
}
|
}
|
||||||
@@ -345,7 +340,7 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
@Override
|
@Override
|
||||||
public void onTabPageChanged(int page) {
|
public void onTabPageChanged(int page) {
|
||||||
if (page >= 0 && page <= getTotalTabPages()) {
|
if (page >= 0 && page <= getTotalTabPages()) {
|
||||||
RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), page));
|
// TODO RS.INSTANCE.network.sendToServer(new MessageGridSettingsUpdate(getViewType(), getSortingDirection(), getSortingType(), getSearchBoxMode(), getSize(), getTabSelected(), page));
|
||||||
|
|
||||||
this.tabPage = page;
|
this.tabPage = page;
|
||||||
}
|
}
|
||||||
@@ -377,12 +372,12 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryCrafting getCraftingMatrix() {
|
public CraftingInventory getCraftingMatrix() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryCraftResult getCraftingResult() {
|
public CraftResultInventory getCraftingResult() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -409,15 +404,15 @@ public class PortableGrid implements IGrid, IPortableGrid, IStorageDiskContainer
|
|||||||
@Override
|
@Override
|
||||||
public void onClosed(PlayerEntity player) {
|
public void onClosed(PlayerEntity player) {
|
||||||
if (!player.getEntityWorld().isRemote) {
|
if (!player.getEntityWorld().isRemote) {
|
||||||
StackUtils.writeItems(disk, 4, stack.getTagCompound());
|
StackUtils.writeItems(disk, 4, stack.getTag());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
if (RS.INSTANCE.config.portableGridUsesEnergy && stack.getItemDamage() != ItemBlockPortableGrid.TYPE_CREATIVE && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() <= RS.INSTANCE.config.portableGridOpenUsage) {
|
// TODO if (RS.INSTANCE.config.portableGridUsesEnergy && stack.getItemDamage() != ItemBlockPortableGrid.TYPE_CREATIVE && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() <= RS.INSTANCE.config.portableGridOpenUsage) {
|
||||||
return false;
|
// return false;
|
||||||
}
|
//+}
|
||||||
|
|
||||||
if (disk.getStackInSlot(0).isEmpty()) {
|
if (disk.getStackInSlot(0).isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.tile.grid.portable;
|
|||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.RS;
|
import com.raoulvdberge.refinedstorage.RS;
|
||||||
import com.raoulvdberge.refinedstorage.RSBlocks;
|
import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||||
|
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
import com.raoulvdberge.refinedstorage.api.network.grid.GridType;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridCraftingListener;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGridCraftingListener;
|
||||||
@@ -30,7 +31,6 @@ import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
|
|||||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
|
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerFilter;
|
||||||
import com.raoulvdberge.refinedstorage.inventory.listener.ListenerTile;
|
import com.raoulvdberge.refinedstorage.inventory.listener.ListenerTile;
|
||||||
import com.raoulvdberge.refinedstorage.item.ItemWirelessGrid;
|
import com.raoulvdberge.refinedstorage.item.ItemWirelessGrid;
|
||||||
import com.raoulvdberge.refinedstorage.item.itemblock.ItemBlockPortableGrid;
|
|
||||||
import com.raoulvdberge.refinedstorage.render.constants.ConstantsDisk;
|
import com.raoulvdberge.refinedstorage.render.constants.ConstantsDisk;
|
||||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||||
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
||||||
@@ -40,20 +40,21 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
|||||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
import net.minecraft.inventory.InventoryCraftResult;
|
import net.minecraft.inventory.CraftResultInventory;
|
||||||
import net.minecraft.inventory.InventoryCrafting;
|
import net.minecraft.inventory.CraftingInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.ListNBT;
|
import net.minecraft.nbt.ListNBT;
|
||||||
import net.minecraft.network.datasync.DataSerializers;
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
import net.minecraft.util.Direction;
|
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.common.util.Constants;
|
import net.minecraftforge.common.util.Constants;
|
||||||
|
import net.minecraftforge.common.util.LazyOptional;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.EnergyStorage;
|
import net.minecraftforge.energy.EnergyStorage;
|
||||||
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
t.setSize(v);
|
t.setSize(v);
|
||||||
t.markDirty();
|
t.markDirty();
|
||||||
}
|
}
|
||||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::initGui));
|
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, GuiBase::init));
|
||||||
private static final TileDataParameter<Integer, TilePortableGrid> TAB_SELECTED = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getTabSelected, (t, v) -> {
|
private static final TileDataParameter<Integer, TilePortableGrid> TAB_SELECTED = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getTabSelected, (t, v) -> {
|
||||||
t.setTabSelected(v == t.getTabSelected() ? -1 : v);
|
t.setTabSelected(v == t.getTabSelected() ? -1 : v);
|
||||||
t.markDirty();
|
t.markDirty();
|
||||||
@@ -110,6 +111,7 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
private static final String NBT_TYPE = "Type";
|
private static final String NBT_TYPE = "Type";
|
||||||
private static final String NBT_ENCHANTMENTS = "ench"; // @Volatile: minecraft specific nbt key
|
private static final String NBT_ENCHANTMENTS = "ench"; // @Volatile: minecraft specific nbt key
|
||||||
private EnergyStorage energyStorage = recreateEnergyStorage(0);
|
private EnergyStorage energyStorage = recreateEnergyStorage(0);
|
||||||
|
private LazyOptional<EnergyStorage> energyStorageCap = LazyOptional.of(() -> energyStorage);
|
||||||
private PortableGridType type;
|
private PortableGridType type;
|
||||||
|
|
||||||
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||||
@@ -152,6 +154,8 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
private ListNBT enchants = null;
|
private ListNBT enchants = null;
|
||||||
|
|
||||||
public TilePortableGrid() {
|
public TilePortableGrid() {
|
||||||
|
super(RSTiles.PORTABLE_GRID);
|
||||||
|
|
||||||
dataManager.addWatchedParameter(REDSTONE_MODE);
|
dataManager.addWatchedParameter(REDSTONE_MODE);
|
||||||
dataManager.addWatchedParameter(ENERGY_STORED);
|
dataManager.addWatchedParameter(ENERGY_STORED);
|
||||||
dataManager.addWatchedParameter(SORTING_DIRECTION);
|
dataManager.addWatchedParameter(SORTING_DIRECTION);
|
||||||
@@ -211,10 +215,10 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
|
|
||||||
public PortableGridType getPortableType() {
|
public PortableGridType getPortableType() {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
IBlockState state = world.getBlockState(pos);
|
BlockState state = world.getBlockState(pos);
|
||||||
|
|
||||||
if (state.getBlock() == RSBlocks.PORTABLE_GRID) {
|
if (state.getBlock() == RSBlocks.PORTABLE_GRID) {
|
||||||
this.type = (PortableGridType) state.getValue(BlockPortableGrid.TYPE);
|
this.type = state.get(BlockPortableGrid.TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,27 +233,29 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
this.tabPage = ItemWirelessGrid.getTabPage(stack);
|
this.tabPage = ItemWirelessGrid.getTabPage(stack);
|
||||||
this.size = ItemWirelessGrid.getSize(stack);
|
this.size = ItemWirelessGrid.getSize(stack);
|
||||||
|
|
||||||
this.energyStorage = recreateEnergyStorage(stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored());
|
IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY).orElse(null);
|
||||||
|
|
||||||
if (stack.hasTagCompound()) {
|
this.energyStorage = recreateEnergyStorage(energyStorage != null ? energyStorage.getEnergyStored() : 0);
|
||||||
|
|
||||||
|
if (stack.hasTag()) {
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
StackUtils.readItems(filter, i, stack.getTagCompound());
|
StackUtils.readItems(filter, i, stack.getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
StackUtils.readItems(disk, 4, stack.getTagCompound());
|
StackUtils.readItems(disk, 4, stack.getTag());
|
||||||
|
|
||||||
this.redstoneMode = RedstoneMode.read(stack.getTagCompound());
|
this.redstoneMode = RedstoneMode.read(stack.getTag());
|
||||||
|
|
||||||
if (stack.getTagCompound().hasKey(PortableGrid.NBT_STORAGE_TRACKER)) {
|
if (stack.getTag().contains(PortableGrid.NBT_STORAGE_TRACKER)) {
|
||||||
storageTracker.readFromNbt(stack.getTagCompound().getList(PortableGrid.NBT_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
storageTracker.readFromNbt(stack.getTag().getList(PortableGrid.NBT_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getTagCompound().hasKey(PortableGrid.NBT_FLUID_STORAGE_TRACKER)) {
|
if (stack.getTag().contains(PortableGrid.NBT_FLUID_STORAGE_TRACKER)) {
|
||||||
fluidStorageTracker.readFromNbt(stack.getTagCompound().getList(PortableGrid.NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
fluidStorageTracker.readFromNbt(stack.getTag().getList(PortableGrid.NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getTagCompound().hasKey(NBT_ENCHANTMENTS)) {
|
if (stack.getTag().contains(NBT_ENCHANTMENTS)) {
|
||||||
enchants = stack.getTagCompound().getList(NBT_ENCHANTMENTS, Constants.NBT.TAG_COMPOUND);
|
enchants = stack.getTag().getList(NBT_ENCHANTMENTS, Constants.NBT.TAG_COMPOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,33 +269,33 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getAsItem() {
|
public ItemStack getAsItem() {
|
||||||
ItemStack stack = new ItemStack(RSBlocks.PORTABLE_GRID, 1, getPortableType() == PortableGridType.NORMAL ? ItemBlockPortableGrid.TYPE_NORMAL : ItemBlockPortableGrid.TYPE_CREATIVE);
|
ItemStack stack = new ItemStack(RSBlocks.PORTABLE_GRID, 1/* TODO, getPortableType() == PortableGridType.NORMAL ? ItemBlockPortableGrid.TYPE_NORMAL : ItemBlockPortableGrid.TYPE_CREATIVE*/);
|
||||||
|
|
||||||
stack.setTagCompound(new CompoundNBT());
|
stack.setTag(new CompoundNBT());
|
||||||
|
|
||||||
stack.getTagCompound().putInt(NetworkNodeGrid.NBT_SORTING_DIRECTION, sortingDirection);
|
stack.getTag().putInt(NetworkNodeGrid.NBT_SORTING_DIRECTION, sortingDirection);
|
||||||
stack.getTagCompound().putInt(NetworkNodeGrid.NBT_SORTING_TYPE, sortingType);
|
stack.getTag().putInt(NetworkNodeGrid.NBT_SORTING_TYPE, sortingType);
|
||||||
stack.getTagCompound().putInt(NetworkNodeGrid.NBT_SEARCH_BOX_MODE, searchBoxMode);
|
stack.getTag().putInt(NetworkNodeGrid.NBT_SEARCH_BOX_MODE, searchBoxMode);
|
||||||
stack.getTagCompound().putInt(NetworkNodeGrid.NBT_SIZE, size);
|
stack.getTag().putInt(NetworkNodeGrid.NBT_SIZE, size);
|
||||||
stack.getTagCompound().putInt(NetworkNodeGrid.NBT_TAB_SELECTED, tabSelected);
|
stack.getTag().putInt(NetworkNodeGrid.NBT_TAB_SELECTED, tabSelected);
|
||||||
stack.getTagCompound().putInt(NetworkNodeGrid.NBT_TAB_PAGE, tabPage);
|
stack.getTag().putInt(NetworkNodeGrid.NBT_TAB_PAGE, tabPage);
|
||||||
|
|
||||||
stack.getTagCompound().put(PortableGrid.NBT_STORAGE_TRACKER, storageTracker.serializeNbt());
|
stack.getTag().put(PortableGrid.NBT_STORAGE_TRACKER, storageTracker.serializeNbt());
|
||||||
stack.getTagCompound().put(PortableGrid.NBT_FLUID_STORAGE_TRACKER, fluidStorageTracker.serializeNbt());
|
stack.getTag().put(PortableGrid.NBT_FLUID_STORAGE_TRACKER, fluidStorageTracker.serializeNbt());
|
||||||
|
|
||||||
if (enchants != null) {
|
if (enchants != null) {
|
||||||
stack.getTagCompound().put(NBT_ENCHANTMENTS, enchants);
|
stack.getTag().put(NBT_ENCHANTMENTS, enchants);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.getCapability(CapabilityEnergy.ENERGY, null).receiveEnergy(energyStorage.getEnergyStored(), false);
|
stack.getCapability(CapabilityEnergy.ENERGY, null).ifPresent(energyStorage -> energyStorage.receiveEnergy(energyStorage.getEnergyStored(), false));
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
StackUtils.writeItems(filter, i, stack.getTagCompound());
|
StackUtils.writeItems(filter, i, stack.getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
StackUtils.writeItems(disk, 4, stack.getTagCompound());
|
StackUtils.writeItems(disk, 4, stack.getTag());
|
||||||
|
|
||||||
redstoneMode.write(stack.getTagCompound());
|
redstoneMode.write(stack.getTag());
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
@@ -468,12 +474,12 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryCrafting getCraftingMatrix() {
|
public CraftingInventory getCraftingMatrix() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InventoryCraftResult getCraftingResult() {
|
public CraftResultInventory getCraftingResult() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,48 +629,48 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
public void read(CompoundNBT tag) {
|
public void read(CompoundNBT tag) {
|
||||||
super.read(tag);
|
super.read(tag);
|
||||||
|
|
||||||
if (tag.hasKey(NetworkNodeGrid.NBT_SORTING_DIRECTION)) {
|
if (tag.contains(NetworkNodeGrid.NBT_SORTING_DIRECTION)) {
|
||||||
sortingDirection = tag.getInteger(NetworkNodeGrid.NBT_SORTING_DIRECTION);
|
sortingDirection = tag.getInt(NetworkNodeGrid.NBT_SORTING_DIRECTION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.hasKey(NetworkNodeGrid.NBT_SORTING_TYPE)) {
|
if (tag.contains(NetworkNodeGrid.NBT_SORTING_TYPE)) {
|
||||||
sortingType = tag.getInteger(NetworkNodeGrid.NBT_SORTING_TYPE);
|
sortingType = tag.getInt(NetworkNodeGrid.NBT_SORTING_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.hasKey(NetworkNodeGrid.NBT_SEARCH_BOX_MODE)) {
|
if (tag.contains(NetworkNodeGrid.NBT_SEARCH_BOX_MODE)) {
|
||||||
searchBoxMode = tag.getInteger(NetworkNodeGrid.NBT_SEARCH_BOX_MODE);
|
searchBoxMode = tag.getInt(NetworkNodeGrid.NBT_SEARCH_BOX_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.hasKey(NetworkNodeGrid.NBT_SIZE)) {
|
if (tag.contains(NetworkNodeGrid.NBT_SIZE)) {
|
||||||
size = tag.getInteger(NetworkNodeGrid.NBT_SIZE);
|
size = tag.getInt(NetworkNodeGrid.NBT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.hasKey(NetworkNodeGrid.NBT_TAB_SELECTED)) {
|
if (tag.contains(NetworkNodeGrid.NBT_TAB_SELECTED)) {
|
||||||
tabSelected = tag.getInteger(NetworkNodeGrid.NBT_TAB_SELECTED);
|
tabSelected = tag.getInt(NetworkNodeGrid.NBT_TAB_SELECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.hasKey(NetworkNodeGrid.NBT_TAB_PAGE)) {
|
if (tag.contains(NetworkNodeGrid.NBT_TAB_PAGE)) {
|
||||||
tabPage = tag.getInteger(NetworkNodeGrid.NBT_TAB_PAGE);
|
tabPage = tag.getInt(NetworkNodeGrid.NBT_TAB_PAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
StackUtils.readItems(disk, 0, tag);
|
StackUtils.readItems(disk, 0, tag);
|
||||||
StackUtils.readItems(filter, 1, tag);
|
StackUtils.readItems(filter, 1, tag);
|
||||||
|
|
||||||
if (tag.hasKey(NBT_ENERGY)) {
|
if (tag.contains(NBT_ENERGY)) {
|
||||||
energyStorage = recreateEnergyStorage(tag.getInteger(NBT_ENERGY));
|
energyStorage = recreateEnergyStorage(tag.getInt(NBT_ENERGY));
|
||||||
}
|
}
|
||||||
|
|
||||||
redstoneMode = RedstoneMode.read(tag);
|
redstoneMode = RedstoneMode.read(tag);
|
||||||
|
|
||||||
if (tag.hasKey(NBT_STORAGE_TRACKER)) {
|
if (tag.contains(NBT_STORAGE_TRACKER)) {
|
||||||
storageTracker.readFromNbt(tag.getList(NBT_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
storageTracker.readFromNbt(tag.getList(NBT_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.hasKey(NBT_FLUID_STORAGE_TRACKER)) {
|
if (tag.contains(NBT_FLUID_STORAGE_TRACKER)) {
|
||||||
fluidStorageTracker.readFromNbt(tag.getList(NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
fluidStorageTracker.readFromNbt(tag.getList(NBT_FLUID_STORAGE_TRACKER, Constants.NBT.TAG_COMPOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag.hasKey(NBT_ENCHANTMENTS)) {
|
if (tag.contains(NBT_ENCHANTMENTS)) {
|
||||||
enchants = tag.getList(NBT_ENCHANTMENTS, Constants.NBT.TAG_COMPOUND);
|
enchants = tag.getList(NBT_ENCHANTMENTS, Constants.NBT.TAG_COMPOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -692,20 +698,19 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
|||||||
public void readUpdate(CompoundNBT tag) {
|
public void readUpdate(CompoundNBT tag) {
|
||||||
super.readUpdate(tag);
|
super.readUpdate(tag);
|
||||||
|
|
||||||
diskState = PortableGridDiskState.getById(tag.getInteger(NBT_DISK_STATE));
|
diskState = PortableGridDiskState.getById(tag.getInt(NBT_DISK_STATE));
|
||||||
connected = tag.getBoolean(NBT_CONNECTED);
|
connected = tag.getBoolean(NBT_CONNECTED);
|
||||||
clientGridType = GridType.values()[tag.getInteger(NBT_TYPE)];
|
clientGridType = GridType.values()[tag.getInt(NBT_TYPE)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap) {
|
||||||
return capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing);
|
if (cap == CapabilityEnergy.ENERGY) {
|
||||||
}
|
return energyStorageCap.cast();
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
return super.getCapability(cap);
|
||||||
@Override
|
|
||||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
|
|
||||||
return capability == CapabilityEnergy.ENERGY ? CapabilityEnergy.ENERGY.cast(energyStorage) : super.getCapability(capability, facing);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onOpened() {
|
public void onOpened() {
|
||||||
|
Reference in New Issue
Block a user