Implement cables and networks.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.NetworkNodeListener;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.FluidStorageType;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.ItemStorageType;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskFactoryFluid;
|
||||
@@ -9,6 +10,7 @@ import com.raoulvdberge.refinedstorage.block.CableBlock;
|
||||
import com.raoulvdberge.refinedstorage.block.ControllerBlock;
|
||||
import com.raoulvdberge.refinedstorage.block.MachineCasingBlock;
|
||||
import com.raoulvdberge.refinedstorage.block.QuartzEnrichedIronBlock;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.config.ServerConfig;
|
||||
import com.raoulvdberge.refinedstorage.container.ControllerContainer;
|
||||
import com.raoulvdberge.refinedstorage.container.FilterContainer;
|
||||
@@ -17,8 +19,9 @@ import com.raoulvdberge.refinedstorage.item.blockitem.ControllerBlockItem;
|
||||
import com.raoulvdberge.refinedstorage.item.group.MainItemGroup;
|
||||
import com.raoulvdberge.refinedstorage.network.NetworkHandler;
|
||||
import com.raoulvdberge.refinedstorage.recipe.UpgradeWithEnchantedBookRecipeSerializer;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.CableTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.ControllerTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.util.BlockUtils;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -29,6 +32,7 @@ import net.minecraft.item.crafting.IRecipeSerializer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -67,6 +71,10 @@ public final class RS {
|
||||
public void onCommonSetup(FMLCommonSetupEvent e) {
|
||||
NETWORK_HANDLER.register();
|
||||
|
||||
NetworkNodeProxyCapability.register();
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new NetworkNodeListener());
|
||||
|
||||
API.instance().getStorageDiskRegistry().add(StorageDiskFactoryItem.ID, new StorageDiskFactoryItem());
|
||||
API.instance().getStorageDiskRegistry().add(StorageDiskFactoryFluid.ID, new StorageDiskFactoryFluid());
|
||||
}
|
||||
@@ -94,10 +102,12 @@ public final class RS {
|
||||
e.getRegistry().register(registerTileDataParameters(
|
||||
TileEntityType.Builder.create(() -> new ControllerTile(ControllerBlock.Type.CREATIVE), RSBlocks.CREATIVE_CONTROLLER).build(null).setRegistryName(RS.ID, "creative_controller")
|
||||
));
|
||||
|
||||
e.getRegistry().register(TileEntityType.Builder.create(CableTile::new, RSBlocks.CABLE).build(null).setRegistryName(RS.ID, "cable"));
|
||||
}
|
||||
|
||||
private <T extends TileEntity> TileEntityType<T> registerTileDataParameters(TileEntityType<T> t) {
|
||||
TileBase tile = (TileBase) t.create();
|
||||
BaseTile tile = (BaseTile) t.create();
|
||||
|
||||
tile.getDataManager().getParameters().forEach(TileDataManager::registerParameter);
|
||||
|
||||
|
||||
@@ -63,8 +63,10 @@ public class RSTiles {
|
||||
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 + ":cable")
|
||||
public static final TileEntityType<CableTile> CABLE = null;
|
||||
|
||||
//@ObjectHolder(RS.ID + ":portable_grid")
|
||||
public static final TileEntityType<TilePortableGrid> PORTABLE_GRID = null;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -59,13 +59,11 @@ public interface IRSAPI {
|
||||
|
||||
/**
|
||||
* Gets a network node manager for a given world.
|
||||
* This can only be called on the server side!
|
||||
* There is no such concept of a network node manager on the client.
|
||||
*
|
||||
* @param world the world
|
||||
* @return the network node manager for the given world
|
||||
* @param world world
|
||||
* @return the network node manager for a given world
|
||||
*/
|
||||
INetworkNodeManager getNetworkNodeManager(World world);
|
||||
INetworkNodeManager getNetworkNodeManager(ServerWorld world);
|
||||
|
||||
/**
|
||||
* @return the crafting task registry
|
||||
@@ -212,7 +210,7 @@ public interface IRSAPI {
|
||||
* @param world the world
|
||||
* @param pos the position of the node
|
||||
*/
|
||||
void discoverNode(World world, BlockPos pos);
|
||||
void discoverNode(IWorld world, BlockPos pos);
|
||||
|
||||
/**
|
||||
* @param stack the stack
|
||||
|
||||
@@ -21,18 +21,6 @@ public interface INetworkNodeGraph {
|
||||
*/
|
||||
void invalidate(Action action, World world, BlockPos origin);
|
||||
|
||||
/**
|
||||
* Runs an action on the network.
|
||||
* If the network is rebuilding it's graph, the action will be executed after the graph was built.
|
||||
*
|
||||
* @param handler the action to run
|
||||
* @deprecated Use {@link #runActionWhenPossible(Consumer)} - just a method rename
|
||||
*/
|
||||
@Deprecated
|
||||
default void addPostRebuildHandler(Consumer<INetwork> handler) {
|
||||
runActionWhenPossible(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs an action on the network.
|
||||
* If the network is rebuilding it's graph, the action will be executed after the graph was built.
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerRegistry;
|
||||
@@ -40,7 +41,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.util.Comparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.QuantityFormatter;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.StackListFluid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.StackListItem;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
@@ -48,7 +49,7 @@ import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -114,24 +115,10 @@ public class API implements IRSAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkNodeManager getNetworkNodeManager(World world) {
|
||||
if (world.isRemote) {
|
||||
throw new IllegalArgumentException("Attempting to access network node manager on the client");
|
||||
}
|
||||
public INetworkNodeManager getNetworkNodeManager(ServerWorld world) {
|
||||
String name = world.getDimension().getType().getRegistryName().getNamespace() + "_" + world.getDimension().getType().getRegistryName().getPath() + "_" + NetworkNodeManager.NAME;
|
||||
|
||||
/* TODO: Saving
|
||||
MapStorage storage = world.getPerWorldStorage();
|
||||
NetworkNodeManager instance = (NetworkNodeManager) storage.getOrLoadData(NetworkNodeManager.class, NetworkNodeManager.NAME);
|
||||
|
||||
if (instance == null) {
|
||||
instance = new NetworkNodeManager(NetworkNodeManager.NAME);
|
||||
|
||||
storage.setData(NetworkNodeManager.NAME, instance);
|
||||
} else {
|
||||
instance.tryReadNodes(world);
|
||||
}*/
|
||||
|
||||
return new NetworkNodeManager("ABC");
|
||||
return world.getSavedData().getOrCreate(() -> new NetworkNodeManager(name, world), name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -258,20 +245,21 @@ public class API implements IRSAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discoverNode(World world, BlockPos pos) {
|
||||
public void discoverNode(IWorld world, BlockPos pos) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
||||
|
||||
if (tile != null) {
|
||||
tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite()).ifPresent(nodeProxy -> {
|
||||
INetworkNode node = nodeProxy.getNode();
|
||||
INetworkNodeProxy proxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite()).orElse(null);
|
||||
if (proxy != null) {
|
||||
INetworkNode node = proxy.getNode();
|
||||
|
||||
if (node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().world(), node.getNetwork().getPosition());
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
@@ -1023,7 +1024,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
static ICraftingPattern readPatternFromNbt(CompoundNBT tag, World world) throws CraftingTaskReadException {
|
||||
BlockPos containerPos = BlockPos.fromLong(tag.getLong(NBT_PATTERN_CONTAINER_POS));
|
||||
|
||||
INetworkNode node = API.instance().getNetworkNodeManager(world).getNode(containerPos);
|
||||
INetworkNode node = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(containerPos);
|
||||
|
||||
if (node instanceof ICraftingPatternContainer) {
|
||||
ItemStack stack = ItemStack.read(tag.getCompound(NBT_PATTERN_STACK));
|
||||
|
||||
@@ -7,13 +7,10 @@ import com.raoulvdberge.refinedstorage.api.network.INetworkNodeGraphListener;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNodeVisitor;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -21,7 +18,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY;
|
||||
import static com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY;
|
||||
|
||||
public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
private INetwork network;
|
||||
@@ -44,7 +41,7 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
|
||||
TileEntity tile = world.getTileEntity(origin);
|
||||
if (tile != null) {
|
||||
tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null).ifPresent(proxy -> {
|
||||
tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, null).ifPresent(proxy -> {
|
||||
INetworkNode node = proxy.getNode();
|
||||
|
||||
if (node instanceof INetworkNodeVisitor) {
|
||||
@@ -113,16 +110,9 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
|
||||
private void dropConflictingBlock(World world, BlockPos pos) {
|
||||
if (!network.getPosition().equals(pos)) {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
Block.spawnDrops(world.getBlockState(pos), world, pos, world.getTileEntity(pos));
|
||||
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
// TODO: state.getBlock().getDrops(drops, world, pos, state, 0);
|
||||
|
||||
world.removeBlock(pos, false); // TODO: correct?
|
||||
|
||||
for (ItemStack drop : drops) {
|
||||
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), drop);
|
||||
}
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@ import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -20,7 +22,7 @@ public class NetworkNodeListener {
|
||||
if (e.phase == TickEvent.Phase.END) {
|
||||
e.world.getProfiler().startSection("network node ticking");
|
||||
|
||||
for (INetworkNode node : API.instance().getNetworkNodeManager(e.world).all()) {
|
||||
for (INetworkNode node : API.instance().getNetworkNodeManager((ServerWorld) e.world).all()) {
|
||||
node.update();
|
||||
}
|
||||
|
||||
@@ -32,21 +34,29 @@ public class NetworkNodeListener {
|
||||
@SubscribeEvent
|
||||
public void onBlockPlace(BlockEvent.EntityPlaceEvent e) {
|
||||
if (!e.getWorld().isRemote() && e.getEntity() instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) e.getEntity();
|
||||
|
||||
TileEntity placed = e.getWorld().getTileEntity(e.getPos());
|
||||
|
||||
if (placed != null) {
|
||||
placed.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY).ifPresent(x -> {
|
||||
placed.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).ifPresent(proxy -> {
|
||||
API.instance().discoverNode(e.getWorld(), e.getPos());
|
||||
|
||||
if (proxy.getNode() instanceof NetworkNode) {
|
||||
((NetworkNode) proxy.getNode()).setOwner(player.getGameProfile().getId());
|
||||
}
|
||||
|
||||
for (Direction facing : Direction.values()) {
|
||||
TileEntity side = e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing));
|
||||
|
||||
if (side != null) {
|
||||
INetworkNodeProxy nodeProxy = side.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite()).orElse(null);
|
||||
INetworkNodeProxy neighborProxy = side.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite()).orElse(null);
|
||||
|
||||
if (nodeProxy != null) {
|
||||
INetworkNode node = nodeProxy.getNode();
|
||||
if (neighborProxy != null) {
|
||||
INetworkNode node = neighborProxy.getNode();
|
||||
|
||||
if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, (PlayerEntity) e.getEntity())) {
|
||||
WorldUtils.sendNoPermissionMessage((PlayerEntity) e.getEntity());
|
||||
if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, player)) {
|
||||
WorldUtils.sendNoPermissionMessage(player);
|
||||
|
||||
e.setCanceled(true);
|
||||
|
||||
@@ -66,7 +76,7 @@ public class NetworkNodeListener {
|
||||
TileEntity tile = e.getWorld().getTileEntity(e.getPos());
|
||||
|
||||
if (tile != null) {
|
||||
tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY).ifPresent(nodeProxy -> {
|
||||
tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY).ifPresent(nodeProxy -> {
|
||||
INetworkNode node = nodeProxy.getNode();
|
||||
|
||||
if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, e.getPlayer())) {
|
||||
|
||||
@@ -23,26 +23,20 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
private static final String NBT_NODE_DATA = "Data";
|
||||
private static final String NBT_NODE_POS = "Pos";
|
||||
|
||||
private boolean canReadNodes;
|
||||
private ListNBT nodesTag;
|
||||
private final World world;
|
||||
|
||||
private ConcurrentHashMap<BlockPos, INetworkNode> nodes = new ConcurrentHashMap<>();
|
||||
|
||||
public NetworkNodeManager(String name) {
|
||||
public NetworkNodeManager(String name, World world) {
|
||||
super(name);
|
||||
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT tag) {
|
||||
if (tag.contains(NBT_NODES)) {
|
||||
this.nodesTag = tag.getList(NBT_NODES, Constants.NBT.TAG_COMPOUND);
|
||||
this.canReadNodes = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void tryReadNodes(World world) {
|
||||
if (this.canReadNodes) {
|
||||
this.canReadNodes = false;
|
||||
ListNBT nodesTag = tag.getList(NBT_NODES, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
this.nodes.clear();
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -101,7 +102,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
@Override
|
||||
public void markDirty() {
|
||||
if (!world.isRemote) {
|
||||
API.instance().getNetworkNodeManager(world).markForSaving();
|
||||
API.instance().getNetworkNodeManager((ServerWorld) world).markForSaving();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeCable;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -25,7 +24,8 @@ public class NetworkNodeCable extends NetworkNode implements ICoverable, INetwor
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return RS.INSTANCE.config.cableUsage;
|
||||
return 0;
|
||||
//return RS.INSTANCE.config.cableUsage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.INameable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
@@ -384,7 +385,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
|
||||
return null;
|
||||
}
|
||||
|
||||
INetworkNode facing = API.instance().getNetworkNodeManager(world).getNode(pos.offset(getDirection()));
|
||||
INetworkNode facing = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.offset(getDirection()));
|
||||
if (!(facing instanceof ICraftingPatternContainer) || facing.getNetwork() != network) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
@@ -158,7 +159,7 @@ public class NetworkNodeFluidInterface extends NetworkNode {
|
||||
|
||||
private boolean isActingAsStorage() {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing));
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.offset(facing));
|
||||
|
||||
if (facingNode instanceof NetworkNodeExternalStorage &&
|
||||
facingNode.canUpdate() &&
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
|
||||
@@ -136,7 +137,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
||||
|
||||
private boolean isActingAsStorage() {
|
||||
for (Direction facing : Direction.values()) {
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing));
|
||||
INetworkNode facingNode = API.instance().getNetworkNodeManager((ServerWorld) world).getNode(pos.offset(facing));
|
||||
|
||||
if (facingNode instanceof NetworkNodeExternalStorage &&
|
||||
facingNode.canUpdate() &&
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
@@ -36,7 +37,7 @@ public class CoverManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
INetworkNode neighbor = API.instance().getNetworkNodeManager(node.getWorld()).getNode(node.getPos().offset(direction));
|
||||
INetworkNode neighbor = API.instance().getNetworkNodeManager((ServerWorld) node.getWorld()).getNode(node.getPos().offset(direction));
|
||||
if (neighbor instanceof ICoverable) {
|
||||
cover = ((ICoverable) neighbor).getCoverManager().getCover(direction.getOpposite());
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageContext;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExternal;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileInterface;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -18,7 +18,7 @@ import java.util.function.Supplier;
|
||||
public class ExternalStorageProviderItem implements IExternalStorageProvider<ItemStack> {
|
||||
@Override
|
||||
public boolean canProvide(TileEntity tile, Direction direction) {
|
||||
INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, direction.getOpposite()).orElse(null);
|
||||
INetworkNodeProxy nodeProxy = tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, direction.getOpposite()).orElse(null);
|
||||
|
||||
if (!(nodeProxy != null && nodeProxy.getNode() instanceof IStorageProvider)) { // TODO: Correct if still?
|
||||
return WorldUtils.getItemHandler(tile, direction.getOpposite()) != null;
|
||||
|
||||
@@ -26,7 +26,7 @@ public abstract class BlockBase extends Block {
|
||||
private static final CollisionGroup DEFAULT_COLLISION_GROUP = new CollisionGroup().addItem(new AxisAlignedBB(0, 0, 0, 1, 1, 1)).setCanAccessGui(true);
|
||||
private static final List<CollisionGroup> DEFAULT_COLLISION_GROUPS = Collections.singletonList(DEFAULT_COLLISION_GROUP);
|
||||
|
||||
protected final IBlockInfo info;
|
||||
protected IBlockInfo info;
|
||||
|
||||
public BlockBase(IBlockInfo info) {
|
||||
super(Block.Properties
|
||||
@@ -40,6 +40,10 @@ public abstract class BlockBase extends Block {
|
||||
setRegistryName(info.getId());
|
||||
}
|
||||
|
||||
public BlockBase(Properties p_i48440_1_) {
|
||||
super(p_i48440_1_);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(IModelRegistration modelRegistration) {
|
||||
}
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.block;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.block.info.BlockDirection;
|
||||
import com.raoulvdberge.refinedstorage.block.info.BlockInfoBuilder;
|
||||
import com.raoulvdberge.refinedstorage.render.IModelRegistration;
|
||||
import com.raoulvdberge.refinedstorage.render.model.baked.FullbrightBakedModel;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileCrafter;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -19,6 +12,7 @@ public class BlockCrafter extends BlockNode {
|
||||
super(BlockInfoBuilder.forId("crafter").tileEntity(TileCrafter::new).create());
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void registerModels(IModelRegistration modelRegistration) {
|
||||
@@ -32,14 +26,14 @@ public class BlockCrafter extends BlockNode {
|
||||
new ResourceLocation(RS.ID, "blocks/crafter/cutouts/side_connected_270"),
|
||||
new ResourceLocation(RS.ID, "blocks/crafter/cutouts/front_connected")
|
||||
));
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public BlockRenderLayer getRenderLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
//@Override
|
||||
@Nullable
|
||||
public BlockDirection getDirection() {
|
||||
return BlockDirection.ANY_FACE_PLAYER;
|
||||
|
||||
2
src/main/java/com/raoulvdberge/refinedstorage/block/BlockNode.java
Executable file → Normal file
2
src/main/java/com/raoulvdberge/refinedstorage/block/BlockNode.java
Executable file → Normal file
@@ -9,7 +9,7 @@ public abstract class BlockNode extends BlockNodeProxy {
|
||||
public BlockNode(IBlockInfo info) {
|
||||
super(info);
|
||||
}
|
||||
/* TODO
|
||||
/* TODO - Remove this class.
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase placer, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, pos, state, placer, stack);
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package com.raoulvdberge.refinedstorage.block;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.block.info.IBlockInfo;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
public abstract class BlockNodeProxy extends BlockBase {
|
||||
public BlockNodeProxy(IBlockInfo info) {
|
||||
super(info);
|
||||
this(Block.Properties.create(Material.ROCK));
|
||||
}
|
||||
|
||||
/* TODO
|
||||
public BlockNodeProxy(Properties p_i48440_1_) {
|
||||
super(p_i48440_1_);
|
||||
}
|
||||
|
||||
/* TODO - Remove this class...
|
||||
@Override
|
||||
public boolean canEntityDestroy(BlockState state, IBlockAccess world, BlockPos pos, Entity entity) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.raoulvdberge.refinedstorage.block;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.tile.CableTile;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.SoundType;
|
||||
@@ -8,7 +10,9 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
@@ -18,7 +22,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class CableBlock extends Block {
|
||||
public class CableBlock extends NodeBlock {
|
||||
/* TODO
|
||||
public static final PropertyObject<Cover> COVER_NORTH = new PropertyObject<>("cover_north", Cover.class);
|
||||
public static final PropertyObject<Cover> COVER_EAST = new PropertyObject<>("cover_east", Cover.class);
|
||||
@@ -95,21 +99,41 @@ public class CableBlock extends Block {
|
||||
return getState(ctx.getWorld(), ctx.getPos());
|
||||
}
|
||||
|
||||
private static boolean hasNode(World world, BlockPos pos, Direction direction) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return tile.getCapability(NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY, direction).isPresent();
|
||||
}
|
||||
|
||||
private BlockState getState(World world, BlockPos pos) {
|
||||
Block north = world.getBlockState(pos.north()).getBlock();
|
||||
Block east = world.getBlockState(pos.east()).getBlock();
|
||||
Block south = world.getBlockState(pos.south()).getBlock();
|
||||
Block west = world.getBlockState(pos.west()).getBlock();
|
||||
Block up = world.getBlockState(pos.up()).getBlock();
|
||||
Block down = world.getBlockState(pos.down()).getBlock();
|
||||
boolean north = hasNode(world, pos.offset(Direction.NORTH), Direction.SOUTH);
|
||||
boolean east = hasNode(world, pos.offset(Direction.EAST), Direction.WEST);
|
||||
boolean south = hasNode(world, pos.offset(Direction.SOUTH), Direction.NORTH);
|
||||
boolean west = hasNode(world, pos.offset(Direction.WEST), Direction.EAST);
|
||||
boolean up = hasNode(world, pos.offset(Direction.UP), Direction.DOWN);
|
||||
boolean down = hasNode(world, pos.offset(Direction.DOWN), Direction.UP);
|
||||
|
||||
return getDefaultState()
|
||||
.with(NORTH, north instanceof CableBlock)
|
||||
.with(EAST, east instanceof CableBlock)
|
||||
.with(SOUTH, south instanceof CableBlock)
|
||||
.with(WEST, west instanceof CableBlock)
|
||||
.with(UP, up instanceof CableBlock)
|
||||
.with(DOWN, down instanceof CableBlock);
|
||||
.with(NORTH, north)
|
||||
.with(EAST, east)
|
||||
.with(SOUTH, south)
|
||||
.with(WEST, west)
|
||||
.with(UP, up)
|
||||
.with(DOWN, down);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return new CableTile();
|
||||
}
|
||||
|
||||
/* TODO
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.raoulvdberge.refinedstorage.block;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
public abstract class NodeBlock extends Block {
|
||||
public static final BooleanProperty CONNECTED = BooleanProperty.create("connected");
|
||||
|
||||
public NodeBlock(Block.Properties props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerDestroy(IWorld world, BlockPos pos, BlockState state) {
|
||||
super.onPlayerDestroy(world, pos, state);
|
||||
|
||||
if (!world.isRemote()) {
|
||||
INetworkNodeManager manager = API.instance().getNetworkNodeManager((ServerWorld) world);
|
||||
|
||||
INetworkNode node = manager.getNode(pos);
|
||||
|
||||
manager.removeNode(pos);
|
||||
manager.markForSaving();
|
||||
|
||||
if (node != null && node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().world(), node.getNetwork().getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
|
||||
if (hasConnectedState()) {
|
||||
builder.add(CONNECTED);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasConnectedState() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.block.info;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -15,9 +15,9 @@ public class BlockInfo implements IBlockInfo {
|
||||
private final ResourceLocation id;
|
||||
private final Object modObject;
|
||||
@Nullable
|
||||
private final Supplier<TileBase> tileSupplier;
|
||||
private final Supplier<BaseTile> tileSupplier;
|
||||
|
||||
public BlockInfo(Material material, SoundType soundType, float hardness, String id, String modId, Object modObject, Supplier<TileBase> tileSupplier) {
|
||||
public BlockInfo(Material material, SoundType soundType, float hardness, String id, String modId, Object modObject, Supplier<BaseTile> tileSupplier) {
|
||||
this.material = material;
|
||||
this.soundType = soundType;
|
||||
this.hardness = hardness;
|
||||
@@ -53,7 +53,7 @@ public class BlockInfo implements IBlockInfo {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TileBase createTileEntity() {
|
||||
public BaseTile createTileEntity() {
|
||||
return tileSupplier.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.block.info;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
||||
@@ -14,7 +14,7 @@ public final class BlockInfoBuilder {
|
||||
private Object modObject;
|
||||
private float hardness = 1.9F;
|
||||
private SoundType soundType = SoundType.STONE;
|
||||
private Supplier<TileBase> tileSupplier;
|
||||
private Supplier<BaseTile> tileSupplier;
|
||||
|
||||
private BlockInfoBuilder() {
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public final class BlockInfoBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlockInfoBuilder tileEntity(Supplier<TileBase> tileSupplier) {
|
||||
public BlockInfoBuilder tileEntity(Supplier<BaseTile> tileSupplier) {
|
||||
this.tileSupplier = tileSupplier;
|
||||
|
||||
return this;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.block.info;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -19,7 +19,7 @@ public interface IBlockInfo {
|
||||
float getHardness();
|
||||
|
||||
@Nullable
|
||||
TileBase createTileEntity();
|
||||
BaseTile createTileEntity();
|
||||
|
||||
boolean hasTileEntity();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class CapabilityNetworkNodeProxy {
|
||||
public class NetworkNodeProxyCapability {
|
||||
@CapabilityInject(INetworkNodeProxy.class)
|
||||
public static Capability<INetworkNodeProxy> NETWORK_NODE_PROXY_CAPABILITY = null;
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.raoulvdberge.refinedstorage.container.slot.legacy.DisabledLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.FilterLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.container.transfer.TransferManager;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageSlotFilterFluidUpdate;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataWatcher;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
@@ -26,7 +26,7 @@ import java.util.List;
|
||||
|
||||
public abstract class BaseContainer extends Container {
|
||||
@Nullable
|
||||
private TileBase tile;
|
||||
private BaseTile tile;
|
||||
@Nullable
|
||||
private TileDataWatcher listener;
|
||||
private PlayerEntity player;
|
||||
@@ -36,7 +36,7 @@ public abstract class BaseContainer extends Container {
|
||||
private List<FluidFilterSlot> fluidSlots = new ArrayList<>();
|
||||
private List<FluidStack> fluids = new ArrayList<>();
|
||||
|
||||
public BaseContainer(@Nullable ContainerType<?> type, @Nullable TileBase tile, PlayerEntity player, int windowId) {
|
||||
public BaseContainer(@Nullable ContainerType<?> type, @Nullable BaseTile tile, PlayerEntity player, int windowId) {
|
||||
super(type, windowId);
|
||||
|
||||
this.tile = tile;
|
||||
@@ -53,7 +53,7 @@ public abstract class BaseContainer extends Container {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TileBase getTile() {
|
||||
public BaseTile getTile() {
|
||||
return tile;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.raoulvdberge.refinedstorage.container.slot.legacy.BaseLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.DisabledLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.legacy.FilterLegacySlot;
|
||||
import com.raoulvdberge.refinedstorage.screen.IResizableDisplay;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.WirelessGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
@@ -42,7 +42,7 @@ public class GridContainer extends BaseContainer implements IGridCraftingListene
|
||||
private ResultCraftingGridSlot craftingResultSlot;
|
||||
private BaseLegacySlot patternResultSlot;
|
||||
|
||||
public GridContainer(IGrid grid, IResizableDisplay display, @Nullable TileBase gridTile, PlayerEntity player, int windowId) {
|
||||
public GridContainer(IGrid grid, IResizableDisplay display, @Nullable BaseTile gridTile, PlayerEntity player, int windowId) {
|
||||
super(RSContainers.GRID, gridTile, player, windowId);
|
||||
|
||||
this.grid = grid;
|
||||
|
||||
@@ -4,14 +4,14 @@ import com.raoulvdberge.refinedstorage.RSContainers;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterListener;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterManager;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiReaderWriter;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
public class ReaderWriterContainer extends BaseContainer implements IReaderWriterListener {
|
||||
private IGuiReaderWriter readerWriter;
|
||||
private boolean addedListener;
|
||||
|
||||
public ReaderWriterContainer(IGuiReaderWriter readerWriter, TileBase tile, PlayerEntity player, int windowId) {
|
||||
public ReaderWriterContainer(IGuiReaderWriter readerWriter, BaseTile tile, PlayerEntity player, int windowId) {
|
||||
super(RSContainers.READER_WRITER, tile, player, windowId);
|
||||
|
||||
this.readerWriter = readerWriter;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
import com.raoulvdberge.refinedstorage.tile.NetworkNodeTile;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -31,9 +31,9 @@ public class WrenchItem extends Item {
|
||||
TileEntity tile = ctx.getWorld().getTileEntity(ctx.getPos());
|
||||
|
||||
// TODO - Better INetworkNode check
|
||||
if (tile instanceof TileNode &&
|
||||
((TileNode) tile).getNode().getNetwork() != null &&
|
||||
!((TileNode) tile).getNode().getNetwork().getSecurityManager().hasPermission(Permission.BUILD, ctx.getPlayer())) {
|
||||
if (tile instanceof NetworkNodeTile &&
|
||||
((NetworkNodeTile) tile).getNode().getNetwork() != null &&
|
||||
!((NetworkNodeTile) tile).getNode().getNetwork().getSecurityManager().hasPermission(Permission.BUILD, ctx.getPlayer())) {
|
||||
WorldUtils.sendNoPermissionMessage(ctx.getPlayer());
|
||||
|
||||
return ActionResultType.FAIL;
|
||||
|
||||
@@ -24,13 +24,7 @@ public class EnergyCapabilityProvider implements ICapabilityProvider {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
|
||||
return getCapability(cap);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap) {
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction dire) {
|
||||
if (cap == CapabilityEnergy.ENERGY) {
|
||||
return capability.cast();
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ public class ProxyCommon {
|
||||
public void preInit(FMLPreInitializationEvent e) {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
CapabilityNetworkNodeProxy.register();
|
||||
|
||||
API.deliver(e.getAsmData());
|
||||
|
||||
NetworkNodeGrid.FACTORY_ID = API.instance().getGridManager().add(new GridFactoryGridBlock());
|
||||
@@ -66,8 +64,6 @@ public class ProxyCommon {
|
||||
API.instance().addExternalStorageProvider(StorageType.ITEM, new ExternalStorageProviderItem());
|
||||
API.instance().addExternalStorageProvider(StorageType.FLUID, new ExternalStorageProviderFluid());
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new NetworkNodeListener());
|
||||
|
||||
IntegrationInventorySorter.register();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -38,6 +37,7 @@ public class TileEntitySpecialRendererStorageMonitor extends TileEntityRenderer<
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO
|
||||
if (tile.getDirection() == Direction.NORTH) {
|
||||
disX = 0.5F;
|
||||
disXText = disX + textWidth;
|
||||
@@ -72,7 +72,7 @@ public class TileEntitySpecialRendererStorageMonitor extends TileEntityRenderer<
|
||||
|
||||
rotZ = 1F;
|
||||
rotX = -1F;
|
||||
}
|
||||
}*/
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translated(x + disX, y + disY, z + disZ);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.raoulvdberge.refinedstorage.tile;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class BaseTile extends TileEntity {
|
||||
protected TileDataManager dataManager = new TileDataManager(this);
|
||||
|
||||
public BaseTile(TileEntityType<?> tileType) {
|
||||
super(tileType);
|
||||
}
|
||||
|
||||
public TileDataManager getDataManager() {
|
||||
return dataManager;
|
||||
}
|
||||
|
||||
public CompoundNBT writeUpdate(CompoundNBT tag) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void readUpdate(CompoundNBT tag) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CompoundNBT getUpdateTag() {
|
||||
return writeUpdate(super.getUpdateTag());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public final SUpdateTileEntityPacket getUpdatePacket() {
|
||||
return new SUpdateTileEntityPacket(pos, 1, getUpdateTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) {
|
||||
readUpdate(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleUpdateTag(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
readUpdate(tag);
|
||||
}
|
||||
|
||||
// @Volatile: Copied with some changes from the super method (avoid sending neighbor updates, it's not needed)
|
||||
@Override
|
||||
public void markDirty() {
|
||||
if (world != null) {
|
||||
world.markChunkDirty(pos, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileCable extends TileNode<NetworkNodeCable> {
|
||||
public TileCable() {
|
||||
public class CableTile extends NetworkNodeTile<NetworkNodeCable> {
|
||||
public CableTile() {
|
||||
super(RSTiles.CABLE);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,4 @@ public class TileCable extends TileNode<NetworkNodeCable> {
|
||||
public NetworkNodeCable createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeCable(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeCable.ID;
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,6 @@ import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -62,16 +61,16 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY;
|
||||
import static com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY;
|
||||
|
||||
// TODO: Change INetwork to be offloaded from the tile.
|
||||
public class ControllerTile extends TileBase implements ITickableTileEntity, INetwork, IRedstoneConfigurable, INetworkNode, INetworkNodeProxy<ControllerTile>, INetworkNodeVisitor {
|
||||
public class ControllerTile extends BaseTile implements ITickableTileEntity, INetwork, IRedstoneConfigurable, INetworkNode, INetworkNodeProxy<ControllerTile>, INetworkNodeVisitor {
|
||||
private static final Comparator<ClientNode> CLIENT_NODE_COMPARATOR = (left, right) -> {
|
||||
if (left.getEnergyUsage() == right.getEnergyUsage()) {
|
||||
return 0;
|
||||
@@ -87,11 +86,6 @@ public class ControllerTile extends TileBase implements ITickableTileEntity, INe
|
||||
public static final TileDataParameter<List<ClientNode>, ControllerTile> NODES = new TileDataParameter<>(RSSerializers.CLIENT_NODE_SERIALIZER, new ArrayList<>(), t -> {
|
||||
List<ClientNode> nodes = new ArrayList<>();
|
||||
|
||||
Random r = new Random();
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
nodes.add(new ClientNode(new ItemStack(r.nextBoolean() ? Blocks.DIRT : (r.nextBoolean() ? Blocks.BOOKSHELF : (r.nextBoolean() ? Blocks.STONE : Blocks.GLASS))), 10, 10));
|
||||
}
|
||||
|
||||
for (INetworkNode node : t.nodeGraph.all()) {
|
||||
if (node.canUpdate()) {
|
||||
ItemStack stack = node.getItemStack();
|
||||
@@ -668,7 +662,7 @@ public class ControllerTile extends TileBase implements ITickableTileEntity, INe
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap) {
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityEnergy.ENERGY) {
|
||||
return energyProxyCap.cast();
|
||||
}
|
||||
|
||||
@@ -6,38 +6,36 @@ import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.capability.NetworkNodeProxyCapability;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.tile.direction.DirectionHandlerNetworkNode;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class TileNode<N extends NetworkNode> extends TileBase implements INetworkNodeProxy<N>, IRedstoneConfigurable {
|
||||
public static final TileDataParameter<Integer, TileNode> REDSTONE_MODE = RedstoneMode.createParameter();
|
||||
public abstract class NetworkNodeTile<N extends NetworkNode> extends BaseTile implements INetworkNodeProxy<N>, IRedstoneConfigurable {
|
||||
public static final TileDataParameter<Integer, NetworkNodeTile> REDSTONE_MODE = RedstoneMode.createParameter();
|
||||
|
||||
protected static final String NBT_ACTIVE = "Active";
|
||||
private static final String NBT_ACTIVE = "Active";
|
||||
private static final String NBT_COVERS = "Cover";
|
||||
|
||||
private N clientNode;
|
||||
|
||||
private LazyOptional<INetworkNodeProxy<N>> networkNodeProxy = LazyOptional.of(() -> this);
|
||||
|
||||
public TileNode(TileEntityType<?> tileType) {
|
||||
public NetworkNodeTile(TileEntityType<?> tileType) {
|
||||
super(tileType);
|
||||
|
||||
directionHandler = new DirectionHandlerNetworkNode(this);
|
||||
|
||||
dataManager.addWatchedParameter(REDSTONE_MODE);
|
||||
}
|
||||
|
||||
@@ -73,12 +71,6 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
getNode().setActive(tag.getBoolean(NBT_ACTIVE));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IItemHandler getDrops() {
|
||||
return getNode().getDrops();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -91,11 +83,11 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
return clientNode;
|
||||
}
|
||||
|
||||
INetworkNodeManager manager = API.instance().getNetworkNodeManager(world);
|
||||
INetworkNodeManager manager = API.instance().getNetworkNodeManager((ServerWorld) world);
|
||||
|
||||
INetworkNode node = manager.getNode(pos);
|
||||
|
||||
if (node == null || !node.getId().equals(getNodeId())) {
|
||||
if (node == null) {
|
||||
manager.setNode(pos, node = createNode(world, pos));
|
||||
manager.markForSaving();
|
||||
}
|
||||
@@ -105,12 +97,10 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
|
||||
|
||||
public abstract N createNode(World world, BlockPos pos);
|
||||
|
||||
public abstract String getNodeId();
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap) {
|
||||
if (cap == CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY) {
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == NetworkNodeProxyCapability.NETWORK_NODE_PROXY_CAPABILITY) {
|
||||
return networkNodeProxy.cast();
|
||||
}
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.tile;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.direction.DirectionHandlerTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.direction.IDirectionHandler;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class TileBase extends TileEntity {
|
||||
protected static final String NBT_DIRECTION = "Direction";
|
||||
|
||||
private Direction clientDirection = Direction.NORTH;
|
||||
protected IDirectionHandler directionHandler = new DirectionHandlerTile();
|
||||
protected TileDataManager dataManager = new TileDataManager(this);
|
||||
|
||||
public TileBase(TileEntityType<?> tileType) {
|
||||
super(tileType);
|
||||
}
|
||||
|
||||
public void setDirection(Direction direction) {
|
||||
clientDirection = direction;
|
||||
|
||||
directionHandler.setDirection(direction);
|
||||
|
||||
world.notifyNeighborsOfStateChange(pos, world.getBlockState(pos).getBlock());
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public Direction getDirection() {
|
||||
return world.isRemote ? clientDirection : directionHandler.getDirection();
|
||||
}
|
||||
|
||||
public TileDataManager getDataManager() {
|
||||
return dataManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
tag = super.write(tag);
|
||||
|
||||
directionHandler.writeToTileNbt(tag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public CompoundNBT writeUpdate(CompoundNBT tag) {
|
||||
tag.putInt(NBT_DIRECTION, directionHandler.getDirection().ordinal());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
directionHandler.readFromTileNbt(tag);
|
||||
}
|
||||
|
||||
public void readUpdate(CompoundNBT tag) {
|
||||
/*boolean doRender = canCauseRenderUpdate(tag);
|
||||
|
||||
clientDirection = Direction.byIndex(tag.getInt(NBT_DIRECTION));
|
||||
|
||||
if (doRender) {
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
}*/
|
||||
}
|
||||
|
||||
protected boolean canCauseRenderUpdate(CompoundNBT tag) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CompoundNBT getUpdateTag() {
|
||||
return writeUpdate(super.getUpdateTag());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public final SUpdateTileEntityPacket getUpdatePacket() {
|
||||
return new SUpdateTileEntityPacket(pos, 1, getUpdateTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) {
|
||||
readUpdate(packet.getNbtCompound());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void handleUpdateTag(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
readUpdate(tag);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IItemHandler getDrops() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// @Volatile: Copied with some changes from the super method (avoid sending neighbor updates, it's not needed)
|
||||
@Override
|
||||
public void markDirty() {
|
||||
if (world != null) {
|
||||
world.markChunkDirty(pos, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileConstructor extends TileNode<NetworkNodeConstructor> {
|
||||
public class TileConstructor extends NetworkNodeTile<NetworkNodeConstructor> {
|
||||
public static final TileDataParameter<Integer, TileConstructor> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileConstructor> TYPE = IType.createParameter();
|
||||
public static final TileDataParameter<Boolean, TileConstructor> DROP = new TileDataParameter<>(DataSerializers.BOOLEAN, false, t -> t.getNode().isDrop(), (t, v) -> {
|
||||
@@ -32,9 +32,4 @@ public class TileConstructor extends TileNode<NetworkNodeConstructor> {
|
||||
public NetworkNodeConstructor createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeConstructor(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeConstructor.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileCrafter extends TileNode<NetworkNodeCrafter> {
|
||||
public class TileCrafter extends NetworkNodeTile<NetworkNodeCrafter> {
|
||||
public static final TileDataParameter<String, TileCrafter> NAME = new TileDataParameter<>(DataSerializers.STRING, NetworkNodeCrafter.DEFAULT_NAME, t -> t.getNode().getName());
|
||||
public static final TileDataParameter<Integer, TileCrafter> MODE = new TileDataParameter<>(DataSerializers.VARINT, NetworkNodeCrafter.CrafterMode.IGNORE.ordinal(), t -> t.getNode().getMode().ordinal(), (t, v) -> t.getNode().setMode(NetworkNodeCrafter.CrafterMode.getById(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));
|
||||
@@ -29,11 +29,6 @@ public class TileCrafter extends TileNode<NetworkNodeCrafter> {
|
||||
return new NetworkNodeCrafter(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeCrafter.ID;
|
||||
}
|
||||
|
||||
/* TODO @Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||
return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing);
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TileCrafterManager extends TileNode<NetworkNodeCrafterManager> {
|
||||
public class TileCrafterManager extends NetworkNodeTile<NetworkNodeCrafterManager> {
|
||||
public static final TileDataParameter<Integer, TileCrafterManager> SIZE = new TileDataParameter<>(DataSerializers.VARINT, IGrid.SIZE_STRETCH, t -> t.getNode().getSize(), (t, v) -> {
|
||||
if (IGrid.isValidSize(v)) {
|
||||
t.getNode().setSize(v);
|
||||
@@ -35,9 +35,4 @@ public class TileCrafterManager extends TileNode<NetworkNodeCrafterManager> {
|
||||
public NetworkNodeCrafterManager createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeCrafterManager(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeCrafterManager.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileDestructor extends TileNode<NetworkNodeDestructor> {
|
||||
public class TileDestructor extends NetworkNodeTile<NetworkNodeDestructor> {
|
||||
public static final TileDataParameter<Integer, TileDestructor> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileDestructor> MODE = IFilterable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileDestructor> TYPE = IType.createParameter();
|
||||
@@ -35,9 +35,4 @@ public class TileDestructor extends TileNode<NetworkNodeDestructor> {
|
||||
public NetworkNodeDestructor createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeDestructor(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeDestructor.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileDetector extends TileNode<NetworkNodeDetector> {
|
||||
public class TileDetector extends NetworkNodeTile<NetworkNodeDetector> {
|
||||
private static final String NBT_POWERED = "Powered";
|
||||
|
||||
public static final TileDataParameter<Integer, TileDetector> COMPARE = IComparable.createParameter();
|
||||
@@ -60,9 +60,4 @@ public class TileDetector extends TileNode<NetworkNodeDetector> {
|
||||
public NetworkNodeDetector createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeDetector(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeDetector.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
||||
public class TileDiskDrive extends NetworkNodeTile<NetworkNodeDiskDrive> {
|
||||
public static final TileDataParameter<Integer, TileDiskDrive> PRIORITY = IPrioritizable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileDiskDrive> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileDiskDrive> MODE = IFilterable.createParameter();
|
||||
@@ -151,9 +151,4 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
|
||||
public NetworkNodeDiskDrive createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeDiskDrive(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeDiskDrive.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
|
||||
public class TileDiskManipulator extends NetworkNodeTile<NetworkNodeDiskManipulator> {
|
||||
public static final TileDataParameter<Integer, TileDiskManipulator> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileDiskManipulator> MODE = IFilterable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileDiskManipulator> TYPE = IType.createParameter();
|
||||
@@ -74,9 +74,4 @@ public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
|
||||
public NetworkNodeDiskManipulator createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeDiskManipulator(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeDiskManipulator.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileExporter extends TileNode<NetworkNodeExporter> {
|
||||
public class TileExporter extends NetworkNodeTile<NetworkNodeExporter> {
|
||||
public static final TileDataParameter<Integer, TileExporter> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileExporter> TYPE = IType.createParameter();
|
||||
|
||||
@@ -26,9 +26,4 @@ public class TileExporter extends TileNode<NetworkNodeExporter> {
|
||||
public NetworkNodeExporter createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeExporter(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeExporter.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileExternalStorage extends TileNode<NetworkNodeExternalStorage> {
|
||||
public class TileExternalStorage extends NetworkNodeTile<NetworkNodeExternalStorage> {
|
||||
public static final TileDataParameter<Integer, TileExternalStorage> PRIORITY = IPrioritizable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileExternalStorage> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileExternalStorage> MODE = IFilterable.createParameter();
|
||||
@@ -64,9 +64,4 @@ public class TileExternalStorage extends TileNode<NetworkNodeExternalStorage> {
|
||||
public NetworkNodeExternalStorage createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeExternalStorage(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeExternalStorage.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileFluidInterface extends TileNode<NetworkNodeFluidInterface> {
|
||||
public class TileFluidInterface extends NetworkNodeTile<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_OUT = new TileDataParameter<>(RSSerializers.FLUID_STACK_SERIALIZER, null, t -> t.getNode().getTankOut().getFluid());
|
||||
|
||||
@@ -43,9 +43,4 @@ public class TileFluidInterface extends TileNode<NetworkNodeFluidInterface> {
|
||||
public NetworkNodeFluidInterface createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeFluidInterface(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeFluidInterface.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileFluidStorage extends TileNode<NetworkNodeFluidStorage> {
|
||||
public class TileFluidStorage extends NetworkNodeTile<NetworkNodeFluidStorage> {
|
||||
public static final TileDataParameter<Integer, TileFluidStorage> PRIORITY = IPrioritizable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileFluidStorage> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileFluidStorage> MODE = IFilterable.createParameter();
|
||||
@@ -36,10 +36,5 @@ public class TileFluidStorage extends TileNode<NetworkNodeFluidStorage> {
|
||||
public NetworkNodeFluidStorage createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeFluidStorage(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeFluidStorage.ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileImporter extends TileNode<NetworkNodeImporter> {
|
||||
public class TileImporter extends NetworkNodeTile<NetworkNodeImporter> {
|
||||
public static final TileDataParameter<Integer, TileImporter> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileImporter> MODE = IFilterable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileImporter> TYPE = IType.createParameter();
|
||||
@@ -29,9 +29,4 @@ public class TileImporter extends TileNode<NetworkNodeImporter> {
|
||||
public NetworkNodeImporter createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeImporter(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeImporter.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileInterface extends TileNode<NetworkNodeInterface> {
|
||||
public class TileInterface extends NetworkNodeTile<NetworkNodeInterface> {
|
||||
public static final TileDataParameter<Integer, TileInterface> COMPARE = IComparable.createParameter();
|
||||
|
||||
public TileInterface() {
|
||||
@@ -34,9 +34,4 @@ public class TileInterface extends TileNode<NetworkNodeInterface> {
|
||||
public NetworkNodeInterface createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeInterface(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeInterface.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileNetworkReceiver extends TileNode<NetworkNodeNetworkReceiver> {
|
||||
public class TileNetworkReceiver extends NetworkNodeTile<NetworkNodeNetworkReceiver> {
|
||||
public TileNetworkReceiver() {
|
||||
super(RSTiles.NETWORK_RECEIVER);
|
||||
}
|
||||
@@ -17,9 +17,4 @@ public class TileNetworkReceiver extends TileNode<NetworkNodeNetworkReceiver> {
|
||||
public NetworkNodeNetworkReceiver createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeNetworkReceiver(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeNetworkReceiver.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileNetworkTransmitter extends TileNode<NetworkNodeNetworkTransmitter> {
|
||||
public class TileNetworkTransmitter extends NetworkNodeTile<NetworkNodeNetworkTransmitter> {
|
||||
public static final TileDataParameter<Integer, TileNetworkTransmitter> DISTANCE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> {
|
||||
NetworkNodeNetworkTransmitter transmitter = t.getNode();
|
||||
|
||||
@@ -31,11 +31,6 @@ public class TileNetworkTransmitter extends TileNode<NetworkNodeNetworkTransmitt
|
||||
return new NetworkNodeNetworkTransmitter(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeNetworkTransmitter.ID;
|
||||
}
|
||||
|
||||
/* TODO
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction facing) {
|
||||
|
||||
@@ -12,8 +12,8 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileReader extends TileNode<NetworkNodeReader> {
|
||||
static <T extends TileNode> TileDataParameter<String, T> createChannelParameter() {
|
||||
public class TileReader extends NetworkNodeTile<NetworkNodeReader> {
|
||||
static <T extends NetworkNodeTile> TileDataParameter<String, T> createChannelParameter() {
|
||||
return new TileDataParameter<>(DataSerializers.STRING, "", t -> ((IGuiReaderWriter) t.getNode()).getChannel(), (t, v) -> {
|
||||
((IGuiReaderWriter) t.getNode()).setChannel(v);
|
||||
|
||||
@@ -96,9 +96,4 @@ public class TileReader extends TileNode<NetworkNodeReader> {
|
||||
public NetworkNodeReader createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeReader(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeReader.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileRelay extends TileNode<NetworkNodeRelay> {
|
||||
public class TileRelay extends NetworkNodeTile<NetworkNodeRelay> {
|
||||
public TileRelay() {
|
||||
super(RSTiles.RELAY);
|
||||
}
|
||||
@@ -17,9 +17,4 @@ public class TileRelay extends TileNode<NetworkNodeRelay> {
|
||||
public NetworkNodeRelay createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeRelay(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeRelay.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileSecurityManager extends TileNode<NetworkNodeSecurityManager> {
|
||||
public class TileSecurityManager extends NetworkNodeTile<NetworkNodeSecurityManager> {
|
||||
public TileSecurityManager() {
|
||||
super(RSTiles.SECURITY_MANAGER);
|
||||
}
|
||||
@@ -17,9 +17,4 @@ public class TileSecurityManager extends TileNode<NetworkNodeSecurityManager> {
|
||||
public NetworkNodeSecurityManager createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeSecurityManager(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeSecurityManager.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileStorage extends TileNode<NetworkNodeStorage> {
|
||||
public class TileStorage extends NetworkNodeTile<NetworkNodeStorage> {
|
||||
public static final TileDataParameter<Integer, TileStorage> PRIORITY = IPrioritizable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileStorage> COMPARE = IComparable.createParameter();
|
||||
public static final TileDataParameter<Integer, TileStorage> MODE = IFilterable.createParameter();
|
||||
@@ -36,9 +36,4 @@ public class TileStorage extends TileNode<NetworkNodeStorage> {
|
||||
public NetworkNodeStorage createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeStorage(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeStorage.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,12 @@ import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class TileStorageMonitor extends TileNode<NetworkNodeStorageMonitor> {
|
||||
public class TileStorageMonitor extends NetworkNodeTile<NetworkNodeStorageMonitor> {
|
||||
public static final TileDataParameter<Integer, TileStorageMonitor> COMPARE = IComparable.createParameter();
|
||||
|
||||
private static final String NBT_STACK = "Stack";
|
||||
@@ -33,11 +32,6 @@ public class TileStorageMonitor extends TileNode<NetworkNodeStorageMonitor> {
|
||||
return new NetworkNodeStorageMonitor(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeStorageMonitor.ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundNBT writeUpdate(CompoundNBT tag) {
|
||||
super.writeUpdate(tag);
|
||||
@@ -61,14 +55,6 @@ public class TileStorageMonitor extends TileNode<NetworkNodeStorageMonitor> {
|
||||
amount = tag.getInt(NBT_AMOUNT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canCauseRenderUpdate(CompoundNBT tag) {
|
||||
Direction receivedDirection = Direction.byIndex(tag.getInt(NBT_DIRECTION));
|
||||
boolean receivedActive = tag.getBoolean(NBT_ACTIVE);
|
||||
|
||||
return receivedDirection != getDirection() || receivedActive != getNode().isActive();
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileWirelessTransmitter extends TileNode<NetworkNodeWirelessTransmitter> {
|
||||
public class TileWirelessTransmitter extends NetworkNodeTile<NetworkNodeWirelessTransmitter> {
|
||||
public static final TileDataParameter<Integer, TileWirelessTransmitter> RANGE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getRange());
|
||||
|
||||
public TileWirelessTransmitter() {
|
||||
@@ -23,9 +23,4 @@ public class TileWirelessTransmitter extends TileNode<NetworkNodeWirelessTransmi
|
||||
public NetworkNodeWirelessTransmitter createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeWirelessTransmitter(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeWirelessTransmitter.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileWriter extends TileNode<NetworkNodeWriter> {
|
||||
public class TileWriter extends NetworkNodeTile<NetworkNodeWriter> {
|
||||
public static final TileDataParameter<String, TileWriter> CHANNEL = TileReader.createChannelParameter();
|
||||
|
||||
public TileWriter() {
|
||||
@@ -84,9 +84,4 @@ public class TileWriter extends TileNode<NetworkNodeWriter> {
|
||||
public NetworkNodeWriter createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeWriter(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeWriter.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.tile.craftingmonitor;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSTiles;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCraftingMonitor;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
import com.raoulvdberge.refinedstorage.tile.NetworkNodeTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -12,7 +12,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TileCraftingMonitor extends TileNode<NetworkNodeCraftingMonitor> {
|
||||
public class TileCraftingMonitor extends NetworkNodeTile<NetworkNodeCraftingMonitor> {
|
||||
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())) {
|
||||
t.getNode().setTabSelected(Optional.empty());
|
||||
@@ -41,9 +41,4 @@ public class TileCraftingMonitor extends TileNode<NetworkNodeCraftingMonitor> {
|
||||
public NetworkNodeCraftingMonitor createNode(World world, BlockPos pos) {
|
||||
return new NetworkNodeCraftingMonitor(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeCraftingMonitor.ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.tile.direction;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class DirectionHandlerNetworkNode implements IDirectionHandler {
|
||||
private TileNode tile;
|
||||
|
||||
public DirectionHandlerNetworkNode(TileNode tile) {
|
||||
this.tile = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection(Direction direction) {
|
||||
tile.getNode().setDirection(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getDirection() {
|
||||
return tile.getNode().getDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToTileNbt(CompoundNBT tag) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromTileNbt(CompoundNBT tag) {
|
||||
// NO OP
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.tile.direction;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public class DirectionHandlerTile implements IDirectionHandler {
|
||||
private static final String NBT_DIRECTION = "Direction";
|
||||
|
||||
private Direction direction = Direction.NORTH;
|
||||
|
||||
@Override
|
||||
public void setDirection(Direction direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Direction getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToTileNbt(CompoundNBT tag) {
|
||||
tag.putInt(NBT_DIRECTION, direction.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromTileNbt(CompoundNBT tag) {
|
||||
if (tag.contains(NBT_DIRECTION)) {
|
||||
direction = Direction.byIndex(tag.getInt(NBT_DIRECTION));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.tile.direction;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
public interface IDirectionHandler {
|
||||
void setDirection(Direction direction);
|
||||
|
||||
Direction getDirection();
|
||||
|
||||
void writeToTileNbt(CompoundNBT tag);
|
||||
|
||||
void readFromTileNbt(CompoundNBT tag);
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeGrid;
|
||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
import com.raoulvdberge.refinedstorage.screen.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
import com.raoulvdberge.refinedstorage.tile.NetworkNodeTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class TileGrid extends TileNode<NetworkNodeGrid> {
|
||||
public class TileGrid extends NetworkNodeTile<NetworkNodeGrid> {
|
||||
public static final TileDataParameter<Integer, TileGrid> VIEW_TYPE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getViewType(), (t, v) -> {
|
||||
if (IGrid.isValidViewType(v)) {
|
||||
t.getNode().setViewType(v);
|
||||
@@ -93,11 +93,6 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
||||
return new NetworkNodeGrid(world, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return NetworkNodeGrid.ID;
|
||||
}
|
||||
|
||||
/* TODO
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable Direction side) {
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.raoulvdberge.refinedstorage.inventory.listener.ListenerTile;
|
||||
import com.raoulvdberge.refinedstorage.render.constants.ConstantsDisk;
|
||||
import com.raoulvdberge.refinedstorage.screen.BaseScreen;
|
||||
import com.raoulvdberge.refinedstorage.screen.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import com.raoulvdberge.refinedstorage.tile.BaseTile;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IRedstoneConfigurable;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
@@ -48,6 +48,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.network.datasync.DataSerializers;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
@@ -63,7 +64,7 @@ import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid, IRedstoneConfigurable, IStorageDiskContainerContext, IPortableGrid.IPortableGridRenderInfo {
|
||||
public class TilePortableGrid extends BaseTile implements IGrid, IPortableGrid, IRedstoneConfigurable, IStorageDiskContainerContext, IPortableGrid.IPortableGridRenderInfo {
|
||||
public static int FACTORY_ID;
|
||||
|
||||
public static final TileDataParameter<Integer, TilePortableGrid> REDSTONE_MODE = RedstoneMode.createParameter();
|
||||
@@ -705,7 +706,7 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap) {
|
||||
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction direction) {
|
||||
if (cap == CapabilityEnergy.ENERGY) {
|
||||
return energyStorageCap.cast();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user