This should be the fix for #986 - "Disks Disappearing"

This commit is contained in:
raoulvdberge
2017-05-25 01:25:05 +02:00
parent 89cacb9fa5
commit 3ddd78a1ef
72 changed files with 433 additions and 377 deletions

View File

@@ -1,5 +1,8 @@
# Refined Storage Changelog
### 1.4.9
- Fixed bug where inventory data was lost sometimes upon opening the world (raoulvdberge)
### 1.4.8
- Fixed missing config categories in ingame config (raoulvdberge)
- Fixed Controller not working anymore after changing redstone setting (raoulvdberge)

View File

@@ -0,0 +1,12 @@
package com.raoulvdberge.refinedstorage.api.network.node;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public interface INetworkNodeFactory {
@Nonnull
INetworkNode create(NBTTagCompound tag, World world, BlockPos pos);
}

View File

@@ -1,9 +1,6 @@
package com.raoulvdberge.refinedstorage.api.network.node;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable;
import java.util.function.Function;
/**
* This registry holds factories for reading and writing network nodes from and to NBT.
@@ -15,7 +12,7 @@ public interface INetworkNodeRegistry {
* @param id the id, as specified in {@link INetworkNode#getId()}
* @param factory the factory
*/
void add(String id, Function<NBTTagCompound, INetworkNode> factory);
void add(String id, INetworkNodeFactory factory);
/**
* Returns a factory from the registry.
@@ -24,5 +21,5 @@ public interface INetworkNodeRegistry {
* @return the factory, or null if no factory was found
*/
@Nullable
Function<NBTTagCompound, INetworkNode> get(String id);
INetworkNodeFactory get(String id);
}

View File

@@ -103,6 +103,8 @@ public class API implements IRSAPI {
instance = new NetworkNodeManager(NetworkNodeManager.NAME);
storage.setData(NetworkNodeManager.NAME, instance);
} else {
instance.tryReadNodes(world);
}
return instance;

View File

@@ -2,18 +2,19 @@ package com.raoulvdberge.refinedstorage.apiimpl.network;
import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeFactory;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldSavedData;
import net.minecraftforge.common.util.Constants;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
public class NetworkNodeManager extends WorldSavedData implements INetworkNodeManager {
public static final String NAME = "refinedstorage_nodes";
@@ -23,6 +24,10 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
private static final String NBT_NODE_DATA = "Data";
private static final String NBT_NODE_POS = "Pos";
// @TODO: Actually store dimension ID instead of using this ugly hack
private boolean canReadNodes;
private NBTTagList nodesTag;
private ConcurrentHashMap<BlockPos, INetworkNode> nodes = new ConcurrentHashMap<>();
public NetworkNodeManager(String s) {
@@ -34,25 +39,40 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
ConcurrentHashMap<BlockPos, INetworkNode> newNodes = new ConcurrentHashMap<>();
if (tag.hasKey(NBT_NODES)) {
NBTTagList list = tag.getTagList(NBT_NODES, Constants.NBT.TAG_COMPOUND);
this.nodesTag = tag.getTagList(NBT_NODES, Constants.NBT.TAG_COMPOUND);
this.canReadNodes = true;
int toRead = list.tagCount();
RSUtils.debugLog("Stored nodes, waiting for actual read call...");
} else {
RSUtils.debugLog("Cannot read nodes, as there is no 'nodes' tag on this WorldSavedData");
}
RSUtils.debugLog("Reading " + toRead + " nodes...");
this.nodes = newNodes;
}
public void tryReadNodes(World world) {
if (canReadNodes) {
canReadNodes = false;
nodes.clear();
int toRead = nodesTag.tagCount();
RSUtils.debugLog("Reading " + toRead + " nodes for dimension " + world.provider.getDimension() + "...");
int read = 0;
for (int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound nodeTag = list.getCompoundTagAt(i);
for (int i = 0; i < nodesTag.tagCount(); ++i) {
NBTTagCompound nodeTag = nodesTag.getCompoundTagAt(i);
String id = nodeTag.getString(NBT_NODE_ID);
NBTTagCompound data = nodeTag.getCompoundTag(NBT_NODE_DATA);
BlockPos pos = BlockPos.fromLong(nodeTag.getLong(NBT_NODE_POS));
Function<NBTTagCompound, INetworkNode> factory = API.instance().getNetworkNodeRegistry().get(id);
INetworkNodeFactory factory = API.instance().getNetworkNodeRegistry().get(id);
if (factory != null) {
newNodes.put(pos, factory.apply(data));
nodes.put(pos, factory.create(data, world, pos));
RSUtils.debugLog("Node at " + pos + " read... (" + (++read) + "/" + toRead + ")");
} else {
@@ -60,12 +80,8 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
}
}
RSUtils.debugLog("Read " + read + " nodes out of " + toRead + " to read");
} else {
RSUtils.debugLog("Cannot read nodes, as there is no 'nodes' tag on this WorldSavedData");
RSUtils.debugLog("Read " + read + " nodes out of " + toRead + " to read for dimension " + world.provider.getDimension());
}
this.nodes = newNodes;
}
@Override

View File

@@ -1,25 +1,23 @@
package com.raoulvdberge.refinedstorage.apiimpl.network;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeFactory;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeRegistry;
import net.minecraft.nbt.NBTTagCompound;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
public class NetworkNodeRegistry implements INetworkNodeRegistry {
private Map<String, Function<NBTTagCompound, INetworkNode>> factories = new HashMap<>();
private Map<String, INetworkNodeFactory> factories = new HashMap<>();
@Override
public void add(String id, Function<NBTTagCompound, INetworkNode> factory) {
public void add(String id, INetworkNodeFactory factory) {
factories.put(id, factory);
}
@Override
@Nullable
public Function<NBTTagCompound, INetworkNode> get(String id) {
public INetworkNodeFactory get(String id) {
return factories.get(id);
}
}

View File

@@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.api.network.INetworkNeighborhoodAware;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.util.IWrenchable;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileBase;
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
@@ -24,15 +24,17 @@ import javax.annotation.Nullable;
public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodAware, IWrenchable {
@Nullable
protected INetwork network;
protected INetworkNodeContainer container;
protected World world;
protected BlockPos pos;
protected int ticks;
protected RedstoneMode redstoneMode = RedstoneMode.IGNORE;
private boolean couldUpdate;
private boolean active;
public NetworkNode(INetworkNodeContainer container) {
this.container = container;
public NetworkNode(World world, BlockPos pos) {
this.world = world;
this.pos = pos;
}
public RedstoneMode getRedstoneMode() {
@@ -45,19 +47,10 @@ public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodA
markDirty();
}
@Nullable
public INetworkNodeContainer getContainer() {
return container;
}
public void setContainer(INetworkNodeContainer container) {
this.container = container;
}
@Nonnull
@Override
public ItemStack getItemStack() {
IBlockState state = container.world().getBlockState(container.pos());
IBlockState state = world.getBlockState(pos);
return new ItemStack(Item.getItemFromBlock(state.getBlock()), 1, state.getBlock().getMetaFromState(state));
}
@@ -82,14 +75,14 @@ public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodA
@Override
public void markDirty() {
if (container.world() != null && !container.world().isRemote) {
API.instance().getNetworkNodeManager(container.world()).markForSaving();
if (world != null && !world.isRemote) {
API.instance().getNetworkNodeManager(world).markForSaving();
}
}
@Override
public boolean canUpdate() {
return redstoneMode.isEnabled(container.world(), container.pos());
return redstoneMode.isEnabled(world, pos);
}
@Override
@@ -102,7 +95,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodA
couldUpdate = canUpdate;
if (hasConnectivityState()) {
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
if (network != null) {
@@ -146,12 +139,12 @@ public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodA
@Override
public BlockPos getPos() {
return container.pos();
return pos;
}
@Override
public World getWorld() {
return container.world();
return world;
}
public boolean canConduct(@Nullable EnumFacing direction) {
@@ -162,13 +155,18 @@ public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodA
public void walkNeighborhood(Operator operator) {
for (EnumFacing facing : EnumFacing.VALUES) {
if (canConduct(facing)) {
operator.apply(container.world(), container.pos().offset(facing), facing.getOpposite());
operator.apply(world, pos.offset(facing), facing.getOpposite());
}
}
}
public TileEntity getFacingTile() {
return container.world().getTileEntity(container.pos().offset(container.getDirection()));
return world.getTileEntity(pos.offset(getDirection()));
}
// @TODO: Caching
public EnumFacing getDirection() {
return ((TileBase) world.getTileEntity(pos)).getDirection();
}
@Nullable

View File

@@ -4,8 +4,9 @@ import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.block.BlockCable;
import com.raoulvdberge.refinedstorage.integration.mcmp.IntegrationMCMP;
import com.raoulvdberge.refinedstorage.integration.mcmp.RSMCMPAddon;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
import java.util.Collections;
@@ -13,8 +14,8 @@ import java.util.Collections;
public class NetworkNodeCable extends NetworkNode {
public static final String ID = "cable";
public NetworkNodeCable(INetworkNodeContainer container) {
super(container);
public NetworkNodeCable(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -30,8 +31,8 @@ public class NetworkNodeCable extends NetworkNode {
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
if (IntegrationMCMP.isLoaded() && direction != null) {
return RSMCMPAddon.hasConnectionWith(container.world().getTileEntity(container.pos()), Collections.singletonList(BlockCable.getCableExtensionAABB(direction)))
&& RSMCMPAddon.hasConnectionWith(container.world().getTileEntity(container.pos().offset(direction)), Collections.singletonList(BlockCable.getCableExtensionAABB(direction.getOpposite())));
return RSMCMPAddon.hasConnectionWith(world.getTileEntity(pos), Collections.singletonList(BlockCable.getCableExtensionAABB(direction)))
&& RSMCMPAddon.hasConnectionWith(world.getTileEntity(pos.offset(direction)), Collections.singletonList(BlockCable.getCableExtensionAABB(direction.getOpposite())));
}
return true;

View File

@@ -10,7 +10,6 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileConstructor;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IType;
@@ -33,6 +32,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.BlockSnapshot;
@@ -57,7 +57,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
super.onContentsChanged(slot);
item = getStackInSlot(slot).isEmpty() ? null : getStackInSlot(slot).copy();
block = SlotFilter.getBlockState(container.world(), container.pos().offset(container.getDirection()), getStackInSlot(slot));
block = SlotFilter.getBlockState(world, pos.offset(getDirection()), getStackInSlot(slot));
}
};
@@ -72,8 +72,8 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
private IBlockState block;
private ItemStack item;
public NetworkNodeConstructor(INetworkNodeContainer container) {
super(container);
public NetworkNodeConstructor(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -98,7 +98,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
ItemStack took = network.extractItem(item, 1, false);
if (took != null) {
container.world().spawnEntity(new EntityFireworkRocket(container.world(), getDispensePositionX(), getDispensePositionY(), getDispensePositionZ(), took));
world.spawnEntity(new EntityFireworkRocket(world, getDispensePositionX(), getDispensePositionY(), getDispensePositionZ(), took));
}
} else {
dropItem();
@@ -108,11 +108,11 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
FluidStack stack = fluidFilters.getFluidStackInSlot(0);
if (stack != null && stack.getFluid().canBePlacedInWorld()) {
BlockPos front = container.pos().offset(container.getDirection());
BlockPos front = pos.offset(getDirection());
Block block = stack.getFluid().getBlock();
if (container.world().isAirBlock(front) && block.canPlaceBlockAt(container.world(), front)) {
if (world.isAirBlock(front) && block.canPlaceBlockAt(world, front)) {
FluidStack stored = network.getFluidStorageCache().getList().get(stack, compare);
if (stored != null && stored.amount >= Fluid.BUCKET_VOLUME) {
@@ -131,7 +131,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
return;
}
container.world().setBlockState(front, state, 1 | 2);
world.setBlockState(front, state, 1 | 2);
}
}
}
@@ -141,19 +141,19 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
}
private boolean canPlace(BlockPos pos, IBlockState state) {
BlockEvent.PlaceEvent e = new BlockEvent.PlaceEvent(new BlockSnapshot(container.world(), pos, state), container.world().getBlockState(container.pos()), FakePlayerFactory.getMinecraft((WorldServer) container.world()), EnumHand.MAIN_HAND);
BlockEvent.PlaceEvent e = new BlockEvent.PlaceEvent(new BlockSnapshot(world, pos, state), world.getBlockState(pos), FakePlayerFactory.getMinecraft((WorldServer) world), EnumHand.MAIN_HAND);
return !MinecraftForge.EVENT_BUS.post(e);
}
private void placeBlock() {
BlockPos front = container.pos().offset(container.getDirection());
BlockPos front = pos.offset(getDirection());
if (container.world().isAirBlock(front) && block.getBlock().canPlaceBlockAt(container.world(), front)) {
if (world.isAirBlock(front) && block.getBlock().canPlaceBlockAt(world, front)) {
ItemStack took = network.extractItem(itemFilters.getStackInSlot(0), 1, compare, true);
if (took != null) {
IBlockState state = block.getBlock().getStateForPlacement(container.world(), front, container.getDirection(), 0.5F, 0.5F, 0.5F, took.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) container.world()), EnumHand.MAIN_HAND);
IBlockState state = block.getBlock().getStateForPlacement(world, front, getDirection(), 0.5F, 0.5F, 0.5F, took.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) world), EnumHand.MAIN_HAND);
if (!canPlace(front, state)) {
return;
@@ -164,29 +164,29 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
if (item.getItem() instanceof ItemBlock) {
((ItemBlock) item.getItem()).placeBlockAt(
took,
FakePlayerFactory.getMinecraft((WorldServer) container.world()),
container.world(),
FakePlayerFactory.getMinecraft((WorldServer) world),
world,
front,
container.getDirection(),
getDirection(),
0,
0,
0,
state
);
} else {
container.world().setBlockState(front, state, 1 | 2);
world.setBlockState(front, state, 1 | 2);
state.getBlock().onBlockPlacedBy(container.world(), front, state, FakePlayerFactory.getMinecraft((WorldServer) container.world()), took);
state.getBlock().onBlockPlacedBy(world, front, state, FakePlayerFactory.getMinecraft((WorldServer) world), took);
}
// From ItemBlock#onItemUse
SoundType blockSound = block.getBlock().getSoundType(state, container.world(), container.pos(), null);
container.world().playSound(null, front, blockSound.getPlaceSound(), SoundCategory.BLOCKS, (blockSound.getVolume() + 1.0F) / 2.0F, blockSound.getPitch() * 0.8F);
SoundType blockSound = block.getBlock().getSoundType(state, world, pos, null);
world.playSound(null, front, blockSound.getPlaceSound(), SoundCategory.BLOCKS, (blockSound.getVolume() + 1.0F) / 2.0F, blockSound.getPitch() * 0.8F);
if (block.getBlock() == Blocks.SKULL) {
container.world().setBlockState(front, container.world().getBlockState(front).withProperty(BlockSkull.FACING, container.getDirection()));
world.setBlockState(front, world.getBlockState(front).withProperty(BlockSkull.FACING, getDirection()));
TileEntity tile = container.world().getTileEntity(front);
TileEntity tile = world.getTileEntity(front);
if (tile instanceof TileEntitySkull) {
TileEntitySkull skullTile = (TileEntitySkull) tile;
@@ -209,7 +209,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
skullTile.setType(item.getMetadata());
}
Blocks.SKULL.checkWitherSpawn(container.world(), front, skullTile);
Blocks.SKULL.checkWitherSpawn(world, front, skullTile);
}
}
@@ -225,7 +225,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
ItemStack took = network.extractItem(item, upgrades.getItemInteractCount(), false);
if (took != null) {
BehaviorDefaultDispenseItem.doDispense(container.world(), took, 6, container.getDirection(), new PositionImpl(getDispensePositionX(), getDispensePositionY(), getDispensePositionZ()));
BehaviorDefaultDispenseItem.doDispense(world, took, 6, getDirection(), new PositionImpl(getDispensePositionX(), getDispensePositionY(), getDispensePositionZ()));
} else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
ItemStack craft = itemFilters.getStackInSlot(0);
@@ -235,17 +235,17 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
// From BlockDispenser#getDispensePosition
private double getDispensePositionX() {
return (double) container.pos().getX() + 0.5D + 0.8D * (double) container.getDirection().getFrontOffsetX();
return (double) pos.getX() + 0.5D + 0.8D * (double) getDirection().getFrontOffsetX();
}
// From BlockDispenser#getDispensePosition
private double getDispensePositionY() {
return (double) container.pos().getY() + (container.getDirection() == EnumFacing.DOWN ? 0.45D : 0.5D) + 0.8D * (double) container.getDirection().getFrontOffsetY();
return (double) pos.getY() + (getDirection() == EnumFacing.DOWN ? 0.45D : 0.5D) + 0.8D * (double) getDirection().getFrontOffsetY();
}
// From BlockDispenser#getDispensePosition
private double getDispensePositionZ() {
return (double) container.pos().getZ() + 0.5D + 0.8D * (double) container.getDirection().getFrontOffsetZ();
return (double) pos.getZ() + 0.5D + 0.8D * (double) getDirection().getFrontOffsetZ();
}
@Override
@@ -339,7 +339,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
@Override
public int getType() {
return container.world().isRemote ? TileConstructor.TYPE.getValue() : type;
return world.isRemote ? TileConstructor.TYPE.getValue() : type;
}
@Override

View File

@@ -11,10 +11,10 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
@@ -30,8 +30,8 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
private ItemHandlerBase patterns = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this), s -> {
// We can only validate the crafting pattern if the world exists.
// If the world doesn't exist, this is probably called while reading and in that case it doesn't matter.
if (container.world() != null) {
return s.getItem() instanceof ICraftingPatternProvider && ((ICraftingPatternProvider) s.getItem()).create(container.world(), s, this).isValid();
if (world != null) {
return s.getItem() instanceof ICraftingPatternProvider && ((ICraftingPatternProvider) s.getItem()).create(world, s, this).isValid();
}
return true;
@@ -40,7 +40,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
protected void onContentsChanged(int slot) {
super.onContentsChanged(slot);
if (container.world() != null && !container.world().isRemote) {
if (world != null && !world.isRemote) {
rebuildPatterns();
}
@@ -57,8 +57,8 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
private boolean triggeredAutocrafting = false;
private boolean blocked = false;
public NetworkNodeCrafter(INetworkNodeContainer container) {
super(container);
public NetworkNodeCrafter(World world, BlockPos pos) {
super(world, pos);
}
private void rebuildPatterns() {
@@ -68,7 +68,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
ItemStack patternStack = patterns.getStackInSlot(i);
if (!patternStack.isEmpty()) {
ICraftingPattern pattern = ((ICraftingPatternProvider) patternStack.getItem()).create(container.world(), patternStack, this);
ICraftingPattern pattern = ((ICraftingPatternProvider) patternStack.getItem()).create(world, patternStack, this);
if (pattern.isValid()) {
actualPatterns.add(pattern);
@@ -98,7 +98,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
rebuildPatterns();
}
if (network != null && triggeredAutocrafting && container.world().isBlockPowered(container.pos())) {
if (network != null && triggeredAutocrafting && world.isBlockPowered(pos)) {
for (ICraftingPattern pattern : actualPatterns) {
for (ItemStack output : pattern.getOutputs()) {
network.getCraftingManager().schedule(output, 1, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT);
@@ -113,7 +113,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
if (!state) {
network.getCraftingManager().getTasks().stream()
.filter(task -> task.getPattern().getContainer().getPosition().equals(container.pos()))
.filter(task -> task.getPattern().getContainer().getPosition().equals(pos))
.forEach(task -> network.getCraftingManager().cancel(task));
}
@@ -174,7 +174,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
@Override
public IItemHandler getFacingInventory() {
return RSUtils.getItemHandler(getFacingTile(), container.getDirection().getOpposite());
return RSUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
}
@Override
@@ -184,7 +184,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
@Override
public BlockPos getPosition() {
return container.pos();
return pos;
}
public IItemHandler getPatternItems() {

View File

@@ -6,7 +6,6 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFilter;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.item.filter.Filter;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.ICraftingMonitor;
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
@@ -15,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nullable;
@@ -38,8 +38,8 @@ public class NetworkNodeCraftingMonitor extends NetworkNode implements ICrafting
}
});
public NetworkNodeCraftingMonitor(INetworkNodeContainer container) {
super(container);
public NetworkNodeCraftingMonitor(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -120,7 +120,7 @@ public class NetworkNodeCraftingMonitor extends NetworkNode implements ICrafting
@Override
public boolean canViewAutomated() {
return container.world().isRemote ? TileCraftingMonitor.VIEW_AUTOMATED.getValue() : viewAutomated;
return world.isRemote ? TileCraftingMonitor.VIEW_AUTOMATED.getValue() : viewAutomated;
}
@Override

View File

@@ -8,7 +8,6 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileDestructor;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
@@ -23,6 +22,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.MinecraftForge;
@@ -60,8 +60,8 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
private int type = IType.ITEMS;
private boolean pickupItem = false;
public NetworkNodeDestructor(INetworkNodeContainer container) {
super(container);
public NetworkNodeDestructor(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -74,12 +74,12 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
super.update();
if (network != null && canUpdate() && ticks % upgrades.getSpeed(BASE_SPEED, 4) == 0) {
BlockPos front = container.pos().offset(container.getDirection());
BlockPos front = pos.offset(getDirection());
if (pickupItem && type == IType.ITEMS) {
List<Entity> droppedItems = new ArrayList<>();
Chunk chunk = container.world().getChunkFromBlockCoords(front);
Chunk chunk = world.getChunkFromBlockCoords(front);
chunk.getEntitiesWithinAABBForEntity(null, new AxisAlignedBB(front), droppedItems, null);
for (Entity entity : droppedItems) {
@@ -89,25 +89,25 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
if (IFilterable.canTake(itemFilters, mode, compare, droppedItem) && network.insertItem(droppedItem, droppedItem.getCount(), true) == null) {
network.insertItemTracked(droppedItem.copy(), droppedItem.getCount());
container.world().removeEntity(entity);
world.removeEntity(entity);
break;
}
}
}
} else if (type == IType.ITEMS) {
IBlockState frontBlockState = container.world().getBlockState(front);
IBlockState frontBlockState = world.getBlockState(front);
Block frontBlock = frontBlockState.getBlock();
ItemStack frontStack = frontBlock.getPickBlock(frontBlockState, null, container.world(), front, null);
ItemStack frontStack = frontBlock.getPickBlock(frontBlockState, null, world, front, null);
if (!frontStack.isEmpty()) {
if (IFilterable.canTake(itemFilters, mode, compare, frontStack) && frontBlockState.getBlockHardness(container.world(), front) != -1.0) {
if (IFilterable.canTake(itemFilters, mode, compare, frontStack) && frontBlockState.getBlockHardness(world, front) != -1.0) {
List<ItemStack> drops;
if (upgrades.hasUpgrade(ItemUpgrade.TYPE_SILK_TOUCH) && frontBlock.canSilkHarvest(container.world(), front, frontBlockState, null)) {
if (upgrades.hasUpgrade(ItemUpgrade.TYPE_SILK_TOUCH) && frontBlock.canSilkHarvest(world, front, frontBlockState, null)) {
drops = Collections.singletonList(frontStack);
} else {
drops = frontBlock.getDrops(container.world(), front, frontBlockState, upgrades.getFortuneLevel());
drops = frontBlock.getDrops(world, front, frontBlockState, upgrades.getFortuneLevel());
}
for (ItemStack drop : drops) {
@@ -116,17 +116,17 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
}
}
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(container.world(), front, frontBlockState, FakePlayerFactory.getMinecraft((WorldServer) container.world()));
BlockEvent.BreakEvent e = new BlockEvent.BreakEvent(world, front, frontBlockState, FakePlayerFactory.getMinecraft((WorldServer) world));
if (!MinecraftForge.EVENT_BUS.post(e)) {
container.world().playEvent(null, 2001, front, Block.getStateId(frontBlockState));
container.world().setBlockToAir(front);
world.playEvent(null, 2001, front, Block.getStateId(frontBlockState));
world.setBlockToAir(front);
for (ItemStack drop : drops) {
// We check if the controller isn't null here because when a destructor faces a node and removes it
// it will essentially remove this block itself from the network without knowing
if (network == null) {
InventoryHelper.spawnItemStack(container.world(), front.getX(), front.getY(), front.getZ(), drop);
InventoryHelper.spawnItemStack(world, front.getX(), front.getY(), front.getZ(), drop);
} else {
network.insertItemTracked(drop, drop.getCount());
}
@@ -135,14 +135,14 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
}
}
} else if (type == IType.FLUIDS) {
Block frontBlock = container.world().getBlockState(front).getBlock();
Block frontBlock = world.getBlockState(front).getBlock();
IFluidHandler handler = null;
if (frontBlock instanceof BlockLiquid) {
handler = new BlockLiquidWrapper((BlockLiquid) frontBlock, container.world(), front);
handler = new BlockLiquidWrapper((BlockLiquid) frontBlock, world, front);
} else if (frontBlock instanceof IFluidBlock) {
handler = new FluidBlockWrapper((IFluidBlock) frontBlock, container.world(), front);
handler = new FluidBlockWrapper((IFluidBlock) frontBlock, world, front);
}
if (handler != null) {
@@ -262,7 +262,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
@Override
public int getType() {
return container.world().isRemote ? TileDestructor.TYPE.getValue() : type;
return world.isRemote ? TileDestructor.TYPE.getValue() : type;
}
@Override

View File

@@ -10,13 +10,14 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileDetector;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IType;
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.IItemHandler;
@@ -46,8 +47,8 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
private boolean powered = false;
private boolean wasPowered;
public NetworkNodeDetector(INetworkNodeContainer container) {
super(container);
public NetworkNodeDetector(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -62,9 +63,9 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
if (powered != wasPowered) {
wasPowered = powered;
container.world().notifyNeighborsOfStateChange(container.pos(), RSBlocks.DETECTOR, true);
world.notifyNeighborsOfStateChange(pos, RSBlocks.DETECTOR, true);
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
if (network != null && canUpdate() && ticks % SPEED == 0) {
@@ -235,7 +236,7 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
@Override
public int getType() {
return container.world().isRemote ? TileDetector.TYPE.getValue() : type;
return world.isRemote ? TileDetector.TYPE.getValue() : type;
}
@Override

View File

@@ -14,12 +14,13 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.item.filter.ItemFilter;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileExporter;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
@@ -47,8 +48,8 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
private ICraftingTask[] craftOnlyTask = new ICraftingTask[9];
private Integer[] craftOnlyToExtract = new Integer[9];
public NetworkNodeExporter(INetworkNodeContainer container) {
super(container);
public NetworkNodeExporter(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -62,7 +63,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
if (network != null && canUpdate() && ticks % upgrades.getSpeed() == 0) {
if (type == IType.ITEMS) {
IItemHandler handler = RSUtils.getItemHandler(getFacingTile(), container.getDirection().getOpposite());
IItemHandler handler = RSUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
if (handler != null) {
for (int i = 0; i < itemFilters.getSlots(); ++i) {
@@ -82,7 +83,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
}
}
} else if (type == IType.FLUIDS) {
IFluidHandler handler = RSUtils.getFluidHandler(getFacingTile(), container.getDirection().getOpposite());
IFluidHandler handler = RSUtils.getFluidHandler(getFacingTile(), getDirection().getOpposite());
if (handler != null) {
for (FluidStack stack : fluidFilters.getFluids()) {
@@ -187,11 +188,11 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
}
} else {
if (IntegrationCyclopsCore.isLoaded()
&& SlotlessItemHandlerHelper.isSlotless(getFacingTile(), container.getDirection().getOpposite())
&& SlotlessItemHandlerHelper.insertItem(getFacingTile(), container.getDirection().getOpposite(), took, true).isEmpty()) {
&& SlotlessItemHandlerHelper.isSlotless(getFacingTile(), getDirection().getOpposite())
&& SlotlessItemHandlerHelper.insertItem(getFacingTile(), getDirection().getOpposite(), took, true).isEmpty()) {
took = network.extractItem(slot, upgrades.getItemInteractCount(), compare, false);
SlotlessItemHandlerHelper.insertItem(getFacingTile(), container.getDirection().getOpposite(), took, false);
SlotlessItemHandlerHelper.insertItem(getFacingTile(), getDirection().getOpposite(), took, false);
} else if (ItemHandlerHelper.insertItem(handler, took, true).isEmpty()) {
took = network.extractItem(slot, upgrades.getItemInteractCount(), compare, false);
@@ -284,7 +285,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
@Override
public int getType() {
return container.world().isRemote ? TileExporter.TYPE.getValue() : type;
return world.isRemote ? TileExporter.TYPE.getValue() : type;
}
@Override
@@ -299,7 +300,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
}
public boolean isRegulator() {
return container.world().isRemote ? TileExporter.REGULATOR.getValue() : regulator;
return world.isRemote ? TileExporter.REGULATOR.getValue() : regulator;
}
public ItemHandlerBase getItemFilters() {

View File

@@ -5,11 +5,12 @@ import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.inventory.*;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
@@ -33,8 +34,8 @@ public class NetworkNodeFluidInterface extends NetworkNode implements IComparabl
protected void onContentsChanged() {
super.onContentsChanged();
if (container.world() != null && !container.world().isRemote) {
((TileFluidInterface) container.world().getTileEntity(container.pos())).getDataManager().sendParameterToWatchers(TileFluidInterface.TANK_IN);
if (world != null && !world.isRemote) {
((TileFluidInterface) world.getTileEntity(pos)).getDataManager().sendParameterToWatchers(TileFluidInterface.TANK_IN);
}
markDirty();
@@ -46,8 +47,8 @@ public class NetworkNodeFluidInterface extends NetworkNode implements IComparabl
protected void onContentsChanged() {
super.onContentsChanged();
if (container.world() != null && !container.world().isRemote) {
((TileFluidInterface) container.world().getTileEntity(container.pos())).getDataManager().sendParameterToWatchers(TileFluidInterface.TANK_OUT);
if (world != null && !world.isRemote) {
((TileFluidInterface) world.getTileEntity(pos)).getDataManager().sendParameterToWatchers(TileFluidInterface.TANK_OUT);
}
markDirty();
@@ -61,8 +62,8 @@ public class NetworkNodeFluidInterface extends NetworkNode implements IComparabl
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK);
public NetworkNodeFluidInterface(INetworkNodeContainer container) {
super(container);
public NetworkNodeFluidInterface(World world, BlockPos pos) {
super(world, pos);
tankIn.setCanDrain(false);
tankIn.setCanFill(true);

View File

@@ -13,12 +13,13 @@ import com.raoulvdberge.refinedstorage.block.BlockFluidStorage;
import com.raoulvdberge.refinedstorage.block.FluidStorageType;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileFluidStorage;
import com.raoulvdberge.refinedstorage.tile.config.*;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnull;
@@ -75,8 +76,8 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
private int mode = IFilterable.WHITELIST;
private boolean voidExcess = false;
public NetworkNodeFluidStorage(INetworkNodeContainer container) {
super(container);
public NetworkNodeFluidStorage(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -197,8 +198,8 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
}
public FluidStorageType getType() {
if (type == null && container.world() != null && container.world().getBlockState(container.pos()).getBlock() == RSBlocks.FLUID_STORAGE) {
type = (FluidStorageType) container.world().getBlockState(container.pos()).getValue(BlockFluidStorage.TYPE);
if (type == null && world != null && world.getBlockState(pos).getBlock() == RSBlocks.FLUID_STORAGE) {
type = (FluidStorageType) world.getBlockState(pos).getValue(BlockFluidStorage.TYPE);
}
return type == null ? FluidStorageType.TYPE_64K : type;

View File

@@ -16,7 +16,6 @@ import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
import com.raoulvdberge.refinedstorage.item.ItemPattern;
import com.raoulvdberge.refinedstorage.item.filter.Filter;
import com.raoulvdberge.refinedstorage.item.filter.FilterTab;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import com.raoulvdberge.refinedstorage.tile.grid.IGrid;
@@ -28,6 +27,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
@@ -100,8 +101,8 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
private boolean oredictPattern = false;
public NetworkNodeGrid(INetworkNodeContainer container) {
super(container);
public NetworkNodeGrid(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -153,8 +154,8 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
}
public GridType getType() {
if (type == null && container.world().getBlockState(container.pos()).getBlock() == RSBlocks.GRID) {
type = (GridType) container.world().getBlockState(container.pos()).getValue(BlockGrid.TYPE);
if (type == null && world.getBlockState(pos).getBlock() == RSBlocks.GRID) {
type = (GridType) world.getBlockState(pos).getValue(BlockGrid.TYPE);
}
return type == null ? GridType.NORMAL : type;
@@ -206,7 +207,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
@Override
public void onCraftingMatrixChanged() {
result.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(matrix, container.world()));
result.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(matrix, world));
markDirty();
}
@@ -302,7 +303,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
@Override
public void onCrafted(EntityPlayer player) {
NonNullList<ItemStack> remainder = CraftingManager.getInstance().getRemainingItems(matrix, container.world());
NonNullList<ItemStack> remainder = CraftingManager.getInstance().getRemainingItems(matrix, world);
for (int i = 0; i < matrix.getSizeInventory(); ++i) {
ItemStack slot = matrix.getStackInSlot(i);
@@ -391,32 +392,32 @@ public class NetworkNodeGrid extends NetworkNode implements IGrid {
@Override
public int getViewType() {
return container.world().isRemote ? TileGrid.VIEW_TYPE.getValue() : viewType;
return world.isRemote ? TileGrid.VIEW_TYPE.getValue() : viewType;
}
@Override
public int getSortingDirection() {
return container.world().isRemote ? TileGrid.SORTING_DIRECTION.getValue() : sortingDirection;
return world.isRemote ? TileGrid.SORTING_DIRECTION.getValue() : sortingDirection;
}
@Override
public int getSortingType() {
return container.world().isRemote ? TileGrid.SORTING_TYPE.getValue() : sortingType;
return world.isRemote ? TileGrid.SORTING_TYPE.getValue() : sortingType;
}
@Override
public int getSearchBoxMode() {
return container.world().isRemote ? TileGrid.SEARCH_BOX_MODE.getValue() : searchBoxMode;
return world.isRemote ? TileGrid.SEARCH_BOX_MODE.getValue() : searchBoxMode;
}
@Override
public int getSize() {
return container.world().isRemote ? TileGrid.SIZE.getValue() : size;
return world.isRemote ? TileGrid.SIZE.getValue() : size;
}
@Override
public int getTabSelected() {
return container.world().isRemote ? TileGrid.TAB_SELECTED.getValue() : tabSelected;
return world.isRemote ? TileGrid.TAB_SELECTED.getValue() : tabSelected;
}
@Override

View File

@@ -8,12 +8,13 @@ import com.raoulvdberge.refinedstorage.integration.cyclopscore.IntegrationCyclop
import com.raoulvdberge.refinedstorage.integration.cyclopscore.SlotlessItemHandlerHelper;
import com.raoulvdberge.refinedstorage.inventory.*;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileImporter;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
import com.raoulvdberge.refinedstorage.tile.config.IType;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
@@ -37,8 +38,8 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
private int currentSlot;
public NetworkNodeImporter(INetworkNodeContainer container) {
super(container);
public NetworkNodeImporter(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -56,12 +57,12 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
if (type == IType.ITEMS) {
IImportingBehavior behavior = ImportingBehaviorItemHandler.INSTANCE;
if (IntegrationCyclopsCore.isLoaded() && SlotlessItemHandlerHelper.isSlotless(getFacingTile(), container.getDirection().getOpposite())) {
if (IntegrationCyclopsCore.isLoaded() && SlotlessItemHandlerHelper.isSlotless(getFacingTile(), getDirection().getOpposite())) {
behavior = ImportingBehaviorCyclops.INSTANCE;
}
currentSlot = behavior.doImport(getFacingTile(), container.getDirection().getOpposite(), currentSlot, itemFilters, mode, compare, ticks, upgrades, network);
currentSlot = behavior.doImport(getFacingTile(), getDirection().getOpposite(), currentSlot, itemFilters, mode, compare, ticks, upgrades, network);
} else if (type == IType.FLUIDS && ticks % upgrades.getSpeed() == 0) {
IFluidHandler handler = RSUtils.getFluidHandler(getFacingTile(), container.getDirection().getOpposite());
IFluidHandler handler = RSUtils.getFluidHandler(getFacingTile(), getDirection().getOpposite());
if (handler != null) {
FluidStack stack = handler.drain(Fluid.BUCKET_VOLUME, false);
@@ -171,7 +172,7 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
@Override
public int getType() {
return container.world().isRemote ? TileImporter.TYPE.getValue() : type;
return world.isRemote ? TileImporter.TYPE.getValue() : type;
}
@Override

View File

@@ -9,10 +9,11 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerProxy;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
@@ -34,8 +35,8 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
private int currentSlot = 0;
public NetworkNodeInterface(INetworkNodeContainer container) {
super(container);
public NetworkNodeInterface(World world, BlockPos pos) {
super(world, pos);
}
@Override

View File

@@ -1,13 +1,14 @@
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class NetworkNodeNetworkReceiver extends NetworkNode {
public static final String ID = "network_receiver";
public NetworkNodeNetworkReceiver(INetworkNodeContainer container) {
super(container);
public NetworkNodeNetworkReceiver(World world, BlockPos pos) {
super(world, pos);
}
@Override

View File

@@ -9,7 +9,6 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
import com.raoulvdberge.refinedstorage.item.ItemNetworkCard;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
@@ -57,8 +56,8 @@ public class NetworkNodeNetworkTransmitter extends NetworkNode {
private BlockPos receiver;
private int receiverDimension;
public NetworkNodeNetworkTransmitter(INetworkNodeContainer container) {
super(container);
public NetworkNodeNetworkTransmitter(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -119,11 +118,11 @@ public class NetworkNodeNetworkTransmitter extends NetworkNode {
return 0;
}
return (int) Math.sqrt(Math.pow(container.pos().getX() - receiver.getX(), 2) + Math.pow(container.pos().getY() - receiver.getY(), 2) + Math.pow(container.pos().getZ() - receiver.getZ(), 2));
return (int) Math.sqrt(Math.pow(pos.getX() - receiver.getX(), 2) + Math.pow(pos.getY() - receiver.getY(), 2) + Math.pow(pos.getZ() - receiver.getZ(), 2));
}
public boolean isSameDimension() {
return container.world().provider.getDimension() == receiverDimension;
return world.provider.getDimension() == receiverDimension;
}
public boolean isDimensionSupported() {
@@ -155,7 +154,7 @@ public class NetworkNodeNetworkTransmitter extends NetworkNode {
operator.apply(dimensionWorld, receiver, null);
}
} else {
operator.apply(container.world(), receiver, null);
operator.apply(world, receiver, null);
}
}
}

View File

@@ -2,12 +2,13 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.node;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReader;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileReader;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class NetworkNodeReader extends NetworkNode implements IReader, IGuiReaderWriter {
public static final String ID = "reader";
@@ -16,8 +17,8 @@ public class NetworkNodeReader extends NetworkNode implements IReader, IGuiReade
private String channel = "";
public NetworkNodeReader(INetworkNodeContainer container) {
super(container);
public NetworkNodeReader(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -27,7 +28,7 @@ public class NetworkNodeReader extends NetworkNode implements IReader, IGuiReade
@Override
public int getRedstoneStrength() {
return container.world().getRedstonePower(container.pos().offset(container.getDirection()), container.getDirection());
return world.getRedstonePower(pos.offset(getDirection()), getDirection());
}
@Override

View File

@@ -1,17 +1,18 @@
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
public class NetworkNodeRelay extends NetworkNode {
public static final String ID = "relay";
public NetworkNodeRelay(INetworkNodeContainer container) {
super(container);
public NetworkNodeRelay(World world, BlockPos pos) {
super(world, pos);
this.redstoneMode = RedstoneMode.LOW;
}

View File

@@ -12,9 +12,10 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemValidatorBasic;
import com.raoulvdberge.refinedstorage.item.ItemSecurityCard;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
@@ -35,7 +36,7 @@ public class NetworkNodeSecurityManager extends NetworkNode implements ISecurity
protected void onContentsChanged(int slot) {
super.onContentsChanged(slot);
if (container.world() != null && !container.world().isRemote) {
if (world != null && !world.isRemote) {
rebuildCards();
}
@@ -49,8 +50,8 @@ public class NetworkNodeSecurityManager extends NetworkNode implements ISecurity
@Nullable
private UUID owner;
public NetworkNodeSecurityManager(INetworkNodeContainer container) {
super(container);
public NetworkNodeSecurityManager(World world, BlockPos pos) {
super(world, pos);
}
@Override

View File

@@ -11,9 +11,10 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerProxy;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
@@ -57,8 +58,8 @@ public class NetworkNodeSolderer extends NetworkNode {
private boolean wasWorking = false;
private int progress = 0;
public NetworkNodeSolderer(INetworkNodeContainer container) {
super(container);
public NetworkNodeSolderer(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -75,7 +76,7 @@ public class NetworkNodeSolderer extends NetworkNode {
markDirty();
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
if (network == null || !canUpdate()) {

View File

@@ -13,12 +13,13 @@ import com.raoulvdberge.refinedstorage.block.BlockStorage;
import com.raoulvdberge.refinedstorage.block.ItemStorageType;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileStorage;
import com.raoulvdberge.refinedstorage.tile.config.*;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.ItemHandlerHelper;
@@ -74,8 +75,8 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
private int mode = IFilterable.WHITELIST;
private boolean voidExcess = false;
public NetworkNodeStorage(INetworkNodeContainer container) {
super(container);
public NetworkNodeStorage(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -192,8 +193,8 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
}
public ItemStorageType getType() {
if (type == null && container.world() != null && container.world().getBlockState(container.pos()).getBlock() == RSBlocks.STORAGE) {
type = (ItemStorageType) container.world().getBlockState(container.pos()).getValue(BlockStorage.TYPE);
if (type == null && world != null && world.getBlockState(pos).getBlock() == RSBlocks.STORAGE) {
type = (ItemStorageType) world.getBlockState(pos).getValue(BlockStorage.TYPE);
}
return type == null ? ItemStorageType.TYPE_1K : type;

View File

@@ -7,7 +7,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileStorageMonitor;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IType;
@@ -18,6 +17,8 @@ import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.items.IItemHandler;
import org.apache.commons.lang3.tuple.Pair;
@@ -38,7 +39,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
public void onContentsChanged(int slot) {
super.onContentsChanged(slot);
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
};
@@ -47,7 +48,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
public void onContentsChanged(int slot) {
super.onContentsChanged(slot);
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
};
@@ -58,8 +59,8 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
private int oldAmount = -1;
public NetworkNodeStorageMonitor(INetworkNodeContainer container) {
super(container);
public NetworkNodeStorageMonitor(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -73,7 +74,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
} else if (oldAmount != newAmount) {
oldAmount = newAmount;
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
}
@@ -129,7 +130,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
}
public void extract(EntityPlayer player, EnumFacing side) {
if (type != IType.ITEMS || network == null || container.getDirection() != side) {
if (type != IType.ITEMS || network == null || getDirection() != side) {
return;
}
@@ -146,7 +147,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
if (result != null) {
if (!player.inventory.addItemStackToInventory(result.copy())) {
InventoryHelper.spawnItemStack(container.world(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), result);
InventoryHelper.spawnItemStack(world, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), result);
}
}
}
@@ -171,21 +172,21 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
public void setCompare(int compare) {
this.compare = compare;
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
markDirty();
}
@Override
public int getType() {
return container.world().isRemote ? TileStorageMonitor.TYPE.getValue() : type;
return world.isRemote ? TileStorageMonitor.TYPE.getValue() : type;
}
@Override
public void setType(int type) {
this.type = type;
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
markDirty();
}

View File

@@ -7,10 +7,10 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nullable;
@@ -20,8 +20,8 @@ public class NetworkNodeWirelessTransmitter extends NetworkNode implements IWire
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_RANGE);
public NetworkNodeWirelessTransmitter(INetworkNodeContainer container) {
super(container);
public NetworkNodeWirelessTransmitter(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -57,12 +57,12 @@ public class NetworkNodeWirelessTransmitter extends NetworkNode implements IWire
@Override
public BlockPos getOrigin() {
return container.pos();
return pos;
}
@Override
public int getDimension() {
return container.world().provider.getDimension();
return world.provider.getDimension();
}
public ItemHandlerBase getUpgrades() {
@@ -86,6 +86,6 @@ public class NetworkNodeWirelessTransmitter extends NetworkNode implements IWire
@Override
public void walkNeighborhood(Operator operator) {
operator.apply(container.world(), container.pos().offset(EnumFacing.DOWN), EnumFacing.UP);
operator.apply(world, pos.offset(EnumFacing.DOWN), EnumFacing.UP);
}
}

View File

@@ -5,13 +5,13 @@ import com.raoulvdberge.refinedstorage.RSBlocks;
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandler;
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IWriter;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileWriter;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReaderWriter {
public static final String ID = "writer";
@@ -23,8 +23,8 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
private int redstoneStrength;
private int lastRedstoneStrength;
public NetworkNodeWriter(INetworkNodeContainer container) {
super(container);
public NetworkNodeWriter(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -39,7 +39,7 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
if (getRedstoneStrength() != lastRedstoneStrength) {
lastRedstoneStrength = getRedstoneStrength();
container.world().notifyNeighborsOfStateChange(container.pos(), RSBlocks.WRITER, true);
world.notifyNeighborsOfStateChange(pos, RSBlocks.WRITER, true);
}
}
@@ -53,11 +53,6 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
redstoneStrength = strength;
}
@Override
public EnumFacing getDirection() {
return container.getDirection();
}
@Override
public String getTitle() {
return "gui.refinedstorage:writer";

View File

@@ -10,12 +10,13 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
import com.raoulvdberge.refinedstorage.tile.config.*;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
@@ -55,7 +56,7 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
network.getFluidStorageCache().invalidate();
}
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
}
@@ -86,8 +87,8 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
private int type = IType.ITEMS;
private boolean voidExcess = false;
public NetworkNodeDiskDrive(INetworkNodeContainer container) {
super(container);
public NetworkNodeDiskDrive(World world, BlockPos pos) {
super(world, pos);
}
public IStorageDisk[] getItemStorages() {
@@ -132,7 +133,7 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
network.getItemStorageCache().invalidate();
network.getFluidStorageCache().invalidate();
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
@Override
@@ -363,7 +364,7 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
@Override
public int getType() {
return container.world().isRemote ? TileDiskDrive.TYPE.getValue() : type;
return world.isRemote ? TileDiskDrive.TYPE.getValue() : type;
}
@Override

View File

@@ -31,7 +31,7 @@ public class StorageFluidDiskDrive implements IStorageDisk<FluidStack> {
if (lastState != currentState) {
lastState = currentState;
RSUtils.updateBlock(diskDrive.getContainer().world(), diskDrive.getContainer().pos());
RSUtils.updateBlock(diskDrive.getWorld(), diskDrive.getPos());
}
},
diskDrive::getVoidExcess,

View File

@@ -31,7 +31,7 @@ public class StorageItemDiskDrive implements IStorageDisk<ItemStack> {
if (lastState != currentState) {
lastState = currentState;
RSUtils.updateBlock(diskDrive.getContainer().world(), diskDrive.getContainer().pos());
RSUtils.updateBlock(diskDrive.getWorld(), diskDrive.getPos());
}
},
diskDrive::getVoidExcess,

View File

@@ -11,13 +11,14 @@ import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerUpgrade;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileDiskManipulator;
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
import com.raoulvdberge.refinedstorage.tile.config.IType;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
@@ -64,7 +65,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
s -> new StorageFluidDiskManipulator(NetworkNodeDiskManipulator.this, s)
);
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
}
@@ -98,13 +99,13 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
s -> new StorageFluidDiskManipulator(NetworkNodeDiskManipulator.this, s)
);
RSUtils.updateBlock(container.world(), container.pos());
RSUtils.updateBlock(world, pos);
}
}
};
public NetworkNodeDiskManipulator(INetworkNodeContainer container) {
super(container);
public NetworkNodeDiskManipulator(World world, BlockPos pos) {
super(world, pos);
}
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
@@ -358,7 +359,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
@Override
public int getType() {
return container.world().isRemote ? TileDiskManipulator.TYPE.getValue() : type;
return world.isRemote ? TileDiskManipulator.TYPE.getValue() : type;
}
@Override

View File

@@ -31,7 +31,7 @@ public class StorageFluidDiskManipulator implements IStorageDisk<FluidStack> {
if (lastState != currentState) {
lastState = currentState;
RSUtils.updateBlock(diskManipulator.getContainer().world(), diskManipulator.getContainer().pos());
RSUtils.updateBlock(diskManipulator.getWorld(), diskManipulator.getPos());
}
},
() -> false,

View File

@@ -31,7 +31,7 @@ public class StorageItemDiskManipulator implements IStorageDisk<ItemStack> {
if (lastState != currentState) {
lastState = currentState;
RSUtils.updateBlock(diskManipulator.getContainer().world(), diskManipulator.getContainer().pos());
RSUtils.updateBlock(diskManipulator.getWorld(), diskManipulator.getPos());
}
},
() -> false,

View File

@@ -15,7 +15,6 @@ import com.raoulvdberge.refinedstorage.integration.cyclopscore.IntegrationCyclop
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerFluid;
import com.raoulvdberge.refinedstorage.inventory.ItemHandlerListenerNetworkNode;
import com.raoulvdberge.refinedstorage.tile.INetworkNodeContainer;
import com.raoulvdberge.refinedstorage.tile.TileExternalStorage;
import com.raoulvdberge.refinedstorage.tile.TileNode;
import com.raoulvdberge.refinedstorage.tile.config.*;
@@ -23,6 +22,8 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.IItemHandler;
@@ -51,8 +52,8 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
private List<StorageItemExternal> itemStorages = new ArrayList<>();
private List<StorageFluidExternal> fluidStorages = new ArrayList<>();
public NetworkNodeExternalStorage(INetworkNodeContainer container) {
super(container);
public NetworkNodeExternalStorage(World world, BlockPos pos) {
super(world, pos);
}
@Override
@@ -207,20 +208,20 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
return f instanceof IDrawer ? (IDrawer) f : null;
}));
} else if (IntegrationCyclopsCore.isLoaded() && StorageItemCyclops.isValid(facing, container.getDirection().getOpposite())) {
} else if (IntegrationCyclopsCore.isLoaded() && StorageItemCyclops.isValid(facing, getDirection().getOpposite())) {
itemStorages.add(new StorageItemCyclops(this));
} else if (!(facing instanceof TileNode)) {
IItemHandler itemHandler = RSUtils.getItemHandler(facing, container.getDirection().getOpposite());
IItemHandler itemHandler = RSUtils.getItemHandler(facing, getDirection().getOpposite());
if (itemHandler != null) {
itemStorages.add(new StorageItemItemHandler(this, () -> RSUtils.getItemHandler(getFacingTile(), container.getDirection().getOpposite())));
itemStorages.add(new StorageItemItemHandler(this, () -> RSUtils.getItemHandler(getFacingTile(), getDirection().getOpposite())));
}
}
} else if (type == IType.FLUIDS) {
IFluidHandler fluidHandler = RSUtils.getFluidHandler(facing, container.getDirection().getOpposite());
IFluidHandler fluidHandler = RSUtils.getFluidHandler(facing, getDirection().getOpposite());
if (fluidHandler != null) {
fluidStorages.add(new StorageFluidExternal(this, () -> RSUtils.getFluidHandler(getFacingTile(), container.getDirection().getOpposite())));
fluidStorages.add(new StorageFluidExternal(this, () -> RSUtils.getFluidHandler(getFacingTile(), getDirection().getOpposite())));
}
}
@@ -312,7 +313,7 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
@Override
public int getType() {
return container.world().isRemote ? TileExternalStorage.TYPE.getValue() : type;
return world.isRemote ? TileExternalStorage.TYPE.getValue() : type;
}
@Override

View File

@@ -29,7 +29,7 @@ public class StorageItemCyclops extends StorageItemExternal {
public StorageItemCyclops(NetworkNodeExternalStorage externalStorage) {
this.externalStorage = externalStorage;
this.opposite = externalStorage.getContainer().getDirection().getOpposite();
this.opposite = externalStorage.getDirection().getOpposite();
this.cyclopsInv = () -> {
TileEntity f = externalStorage.getFacingTile();

View File

@@ -31,18 +31,6 @@ public abstract class BlockNode extends BlockBase {
return true;
}
@Override
public void onBlockAdded(World world, BlockPos pos, IBlockState state) {
super.onBlockAdded(world, pos, state);
RSUtils.debugLog("Node block placed at " + pos + "!");
INetworkNodeManager manager = API.instance().getNetworkNodeManager(world);
manager.setNode(pos, ((TileNode) createTileEntity(world, state)).createNode());
manager.markForSaving();
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);

View File

@@ -38,7 +38,7 @@ public class SlotFilterType extends SlotFilter {
@Override
@Nonnull
public ItemStack getStack() {
return (type.getType() == IType.ITEMS || !((NetworkNode) type).getContainer().world().isRemote) ? super.getStack() : ItemStack.EMPTY;
return (type.getType() == IType.ITEMS || !((NetworkNode) type).getWorld().isRemote) ? super.getStack() : ItemStack.EMPTY;
}
public ItemStack getRealStack() {

View File

@@ -867,10 +867,10 @@ public class ProxyCommon {
TileBase tileInstance = tile.newInstance();
if (tileInstance instanceof TileNode) {
String nodeId = ((TileNode) tileInstance).createNode().getId();
String nodeId = ((TileNode) tileInstance).createNode(null, null).getId();
API.instance().getNetworkNodeRegistry().add(nodeId, tag -> {
NetworkNode node = ((TileNode) tileInstance).createNode();
API.instance().getNetworkNodeRegistry().add(nodeId, (tag, world, pos) -> {
NetworkNode node = ((TileNode) tileInstance).createNode(world, pos);
node.read(tag);

View File

@@ -1,15 +0,0 @@
package com.raoulvdberge.refinedstorage.tile;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public interface INetworkNodeContainer {
EnumFacing getDirection();
void setDirection(EnumFacing direction);
World world();
BlockPos pos();
}

View File

@@ -24,7 +24,7 @@ public abstract class TileBase extends TileEntity {
public void setDirection(EnumFacing direction) {
this.direction = direction;
world.notifyNeighborsOfStateChange(pos, getWorld().getBlockState(pos).getBlock(), true);
world.notifyNeighborsOfStateChange(pos, world.getBlockState(pos).getBlock(), true);
markDirty();
}
@@ -59,7 +59,7 @@ public abstract class TileBase extends TileEntity {
direction = EnumFacing.getFront(tag.getInteger(NBT_DIRECTION));
if (doRender) {
RSUtils.updateBlock(getWorld(), pos);
RSUtils.updateBlock(world, pos);
}
}
@@ -114,13 +114,13 @@ public abstract class TileBase extends TileEntity {
@Override
public boolean equals(Object o) {
return o instanceof TileBase && ((TileBase) o).getPos().equals(pos) && ((TileBase) o).getWorld().provider.getDimension() == getWorld().provider.getDimension();
return o instanceof TileBase && ((TileBase) o).getPos().equals(pos) && ((TileBase) o).world.provider.getDimension() == world.provider.getDimension();
}
@Override
public int hashCode() {
int result = pos.hashCode();
result = 31 * result + getWorld().provider.getDimension();
result = 31 * result + world.provider.getDimension();
return result;
}
}

View File

@@ -1,13 +1,15 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class TileCable extends TileNode<NetworkNodeCable> {
@Override
@Nonnull
public NetworkNodeCable createNode() {
return new NetworkNodeCable(this);
public NetworkNodeCable createNode(World world, BlockPos pos) {
return new NetworkNodeCable(world, pos);
}
}

View File

@@ -7,6 +7,8 @@ import com.raoulvdberge.refinedstorage.tile.data.ITileDataConsumer;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -34,7 +36,7 @@ public class TileConstructor extends TileNode<NetworkNodeConstructor> {
@Override
@Nonnull
public NetworkNodeConstructor createNode() {
return new NetworkNodeConstructor(this);
public NetworkNodeConstructor createNode(World world, BlockPos pos) {
return new NetworkNodeConstructor(world, pos);
}
}

View File

@@ -191,7 +191,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
@Override
public boolean canRun() {
return energy.getEnergyStored() > 0 && redstoneMode.isEnabled(getWorld(), pos);
return energy.getEnergyStored() > 0 && redstoneMode.isEnabled(world, pos);
}
@Override
@@ -211,7 +211,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
@Override
public void update() {
if (!getWorld().isRemote) {
if (!world.isRemote) {
if (canRun()) {
craftingManager.update();
@@ -285,7 +285,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
public void invalidate() {
super.invalidate();
if (getWorld() != null && !getWorld().isRemote) {
if (world != null && !world.isRemote) {
nodeGraph.disconnectAll();
}
}
@@ -302,7 +302,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
@Override
public void sendItemStorageToClient() {
getWorld().getMinecraftServer().getPlayerList().getPlayers().stream()
world.getMinecraftServer().getPlayerList().getPlayers().stream()
.filter(player -> isWatchingGrid(player, GridType.NORMAL, GridType.CRAFTING, GridType.PATTERN))
.forEach(this::sendItemStorageToClient);
}
@@ -314,14 +314,14 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
@Override
public void sendItemStorageDeltaToClient(ItemStack stack, int delta) {
getWorld().getMinecraftServer().getPlayerList().getPlayers().stream()
world.getMinecraftServer().getPlayerList().getPlayers().stream()
.filter(player -> isWatchingGrid(player, GridType.NORMAL, GridType.CRAFTING, GridType.PATTERN))
.forEach(player -> RS.INSTANCE.network.sendTo(new MessageGridItemDelta(this, stack, delta), player));
}
@Override
public void sendFluidStorageToClient() {
getWorld().getMinecraftServer().getPlayerList().getPlayers().stream()
world.getMinecraftServer().getPlayerList().getPlayers().stream()
.filter(player -> isWatchingGrid(player, GridType.FLUID))
.forEach(this::sendFluidStorageToClient);
}
@@ -333,7 +333,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
@Override
public void sendFluidStorageDeltaToClient(FluidStack stack, int delta) {
getWorld().getMinecraftServer().getPlayerList().getPlayers().stream()
world.getMinecraftServer().getPlayerList().getPlayers().stream()
.filter(player -> isWatchingGrid(player, GridType.FLUID))
.forEach(player -> RS.INSTANCE.network.sendTo(new MessageGridFluidDelta(stack, delta), player));
}
@@ -357,7 +357,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
@Override
public void sendCraftingMonitorUpdate() {
getWorld().getMinecraftServer().getPlayerList().getPlayers().stream()
world.getMinecraftServer().getPlayerList().getPlayers().stream()
.filter(player -> player.openContainer instanceof ContainerCraftingMonitor && pos.equals(((ContainerCraftingMonitor) player.openContainer).getCraftingMonitor().getNetworkPosition()))
.forEach(player -> RS.INSTANCE.network.sendTo(new MessageCraftingMonitorElements(((ContainerCraftingMonitor) player.openContainer).getCraftingMonitor()), player));
}
@@ -396,7 +396,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
@Override
public void sendReaderWriterChannelUpdate() {
getWorld().getMinecraftServer().getPlayerList().getPlayers().stream()
world.getMinecraftServer().getPlayerList().getPlayers().stream()
.filter(player -> player.openContainer instanceof ContainerReaderWriter &&
((ContainerReaderWriter) player.openContainer).getReaderWriter().getNetwork() != null &&
pos.equals(((ContainerReaderWriter) player.openContainer).getReaderWriter().getNetwork().getPosition()))
@@ -590,7 +590,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
@Override
public World world() {
return getWorld();
return world;
}
@Override
@@ -701,7 +701,7 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
@Nonnull
@Override
public ItemStack getItemStack() {
IBlockState state = getWorld().getBlockState(pos);
IBlockState state = world.getBlockState(pos);
Item item = Item.getItemFromBlock(state.getBlock());
@@ -729,8 +729,8 @@ public class TileController extends TileBase implements ITickable, INetwork, IRe
}
public ControllerType getType() {
if (type == null && getWorld().getBlockState(pos).getBlock() == RSBlocks.CONTROLLER) {
this.type = (ControllerType) getWorld().getBlockState(pos).getValue(BlockController.TYPE);
if (type == null && world.getBlockState(pos).getBlock() == RSBlocks.CONTROLLER) {
this.type = (ControllerType) world.getBlockState(pos).getValue(BlockController.TYPE);
}
return type == null ? ControllerType.NORMAL : type;

View File

@@ -5,6 +5,8 @@ import com.raoulvdberge.refinedstorage.tile.data.ITileDataConsumer;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -28,7 +30,7 @@ public class TileCrafter extends TileNode<NetworkNodeCrafter> {
@Override
@Nonnull
public NetworkNodeCrafter createNode() {
return new NetworkNodeCrafter(this);
public NetworkNodeCrafter createNode(World world, BlockPos pos) {
return new NetworkNodeCrafter(world, pos);
}
}

View File

@@ -8,6 +8,8 @@ import com.raoulvdberge.refinedstorage.tile.data.ITileDataConsumer;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -37,7 +39,7 @@ public class TileDestructor extends TileNode<NetworkNodeDestructor> {
@Override
@Nonnull
public NetworkNodeDestructor createNode() {
return new NetworkNodeDestructor(this);
public NetworkNodeDestructor createNode(World world, BlockPos pos) {
return new NetworkNodeDestructor(world, pos);
}
}

View File

@@ -11,6 +11,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
@@ -83,7 +85,7 @@ public class TileDetector extends TileNode<NetworkNodeDetector> {
@Override
@Nonnull
public NetworkNodeDetector createNode() {
return new NetworkNodeDetector(this);
public NetworkNodeDetector createNode(World world, BlockPos pos) {
return new NetworkNodeDetector(world, pos);
}
}

View File

@@ -9,6 +9,8 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
@@ -163,7 +165,7 @@ public class TileDiskDrive extends TileNode<NetworkNodeDiskDrive> {
@Override
@Nonnull
public NetworkNodeDiskDrive createNode() {
return new NetworkNodeDiskDrive(this);
public NetworkNodeDiskDrive createNode(World world, BlockPos pos) {
return new NetworkNodeDiskDrive(world, pos);
}
}

View File

@@ -10,6 +10,8 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
@@ -81,7 +83,7 @@ public class TileDiskManipulator extends TileNode<NetworkNodeDiskManipulator> {
@Override
@Nonnull
public NetworkNodeDiskManipulator createNode() {
return new NetworkNodeDiskManipulator(this);
public NetworkNodeDiskManipulator createNode(World world, BlockPos pos) {
return new NetworkNodeDiskManipulator(world, pos);
}
}

View File

@@ -12,6 +12,8 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -39,7 +41,7 @@ public class TileExporter extends TileNode<NetworkNodeExporter> {
exporter.setRegulator(value);
exporter.markDirty();
tile.getWorld().getMinecraftServer().getPlayerList().getPlayers().stream()
tile.world.getMinecraftServer().getPlayerList().getPlayers().stream()
.filter(player -> player.openContainer instanceof ContainerExporter && ((ContainerExporter) player.openContainer).getTile().getPos().equals(tile.getPos()))
.forEach(player -> {
((ContainerExporter) player.openContainer).initSlots();
@@ -78,7 +80,7 @@ public class TileExporter extends TileNode<NetworkNodeExporter> {
@Override
@Nonnull
public NetworkNodeExporter createNode() {
return new NetworkNodeExporter(this);
public NetworkNodeExporter createNode(World world, BlockPos pos) {
return new NetworkNodeExporter(world, pos);
}
}

View File

@@ -8,6 +8,8 @@ import com.raoulvdberge.refinedstorage.tile.config.*;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -64,7 +66,7 @@ public class TileExternalStorage extends TileNode<NetworkNodeExternalStorage> {
@Override
@Nonnull
public NetworkNodeExternalStorage createNode() {
return new NetworkNodeExternalStorage(this);
public NetworkNodeExternalStorage createNode(World world, BlockPos pos) {
return new NetworkNodeExternalStorage(world, pos);
}
}

View File

@@ -6,6 +6,8 @@ import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.RSSerializers;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
@@ -52,7 +54,7 @@ public class TileFluidInterface extends TileNode<NetworkNodeFluidInterface> {
@Override
@Nonnull
public NetworkNodeFluidInterface createNode() {
return new NetworkNodeFluidInterface(this);
public NetworkNodeFluidInterface createNode(World world, BlockPos pos) {
return new NetworkNodeFluidInterface(world, pos);
}
}

View File

@@ -6,6 +6,8 @@ import com.raoulvdberge.refinedstorage.tile.config.*;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -33,8 +35,8 @@ public class TileFluidStorage extends TileNode<NetworkNodeFluidStorage> {
@Override
@Nonnull
public NetworkNodeFluidStorage createNode() {
return new NetworkNodeFluidStorage(this);
public NetworkNodeFluidStorage createNode(World world, BlockPos pos) {
return new NetworkNodeFluidStorage(world, pos);
}
}

View File

@@ -5,6 +5,8 @@ import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
import com.raoulvdberge.refinedstorage.tile.config.IType;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -21,7 +23,7 @@ public class TileImporter extends TileNode<NetworkNodeImporter> {
@Override
@Nonnull
public NetworkNodeImporter createNode() {
return new NetworkNodeImporter(this);
public NetworkNodeImporter createNode(World world, BlockPos pos) {
return new NetworkNodeImporter(world, pos);
}
}

View File

@@ -4,6 +4,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeInterface
import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
@@ -33,7 +35,7 @@ public class TileInterface extends TileNode<NetworkNodeInterface> {
@Override
@Nonnull
public NetworkNodeInterface createNode() {
return new NetworkNodeInterface(this);
public NetworkNodeInterface createNode(World world, BlockPos pos) {
return new NetworkNodeInterface(world, pos);
}
}

View File

@@ -1,13 +1,15 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeNetworkReceiver;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class TileNetworkReceiver extends TileNode<NetworkNodeNetworkReceiver> {
@Override
@Nonnull
public NetworkNodeNetworkReceiver createNode() {
return new NetworkNodeNetworkReceiver(this);
public NetworkNodeNetworkReceiver createNode(World world, BlockPos pos) {
return new NetworkNodeNetworkReceiver(world, pos);
}
}

View File

@@ -5,6 +5,8 @@ import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
@@ -43,8 +45,8 @@ public class TileNetworkTransmitter extends TileNode<NetworkNodeNetworkTransmitt
@Override
@Nonnull
public NetworkNodeNetworkTransmitter createNode() {
return new NetworkNodeNetworkTransmitter(this);
public NetworkNodeNetworkTransmitter createNode(World world, BlockPos pos) {
return new NetworkNodeNetworkTransmitter(world, pos);
}
@Override

View File

@@ -1,6 +1,7 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
import com.raoulvdberge.refinedstorage.api.util.IWrenchable;
import com.raoulvdberge.refinedstorage.apiimpl.API;
@@ -19,7 +20,7 @@ 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>, INetworkNodeContainer, IRedstoneConfigurable, IWrenchable {
public abstract class TileNode<N extends NetworkNode> extends TileBase implements INetworkNodeProxy<N>, IRedstoneConfigurable, IWrenchable {
public static final TileDataParameter<Integer> REDSTONE_MODE = RedstoneMode.createParameter();
private NBTTagCompound legacyTag;
@@ -32,16 +33,6 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
dataManager.addWatchedParameter(REDSTONE_MODE);
}
@Override
public World world() {
return getWorld();
}
@Override
public BlockPos pos() {
return pos;
}
@Override
public RedstoneMode getRedstoneMode() {
return getNode().getRedstoneMode();
@@ -94,22 +85,25 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
@Nonnull
@SuppressWarnings("unchecked")
public N getNode() {
if (getWorld().isRemote) {
if (world.isRemote) {
if (clientNode == null) {
clientNode = createNode();
clientNode = createNode(world, pos);
}
return clientNode;
}
NetworkNode node = (NetworkNode) API.instance().getNetworkNodeManager(getWorld()).getNode(pos);
INetworkNodeManager manager = API.instance().getNetworkNodeManager(world);
NetworkNode node = (NetworkNode) manager.getNode(pos);
// @TODO: This is a hack to support previous broken versions that have no nodes for some tiles due to a bug.
// This should actually be called in Block#onBlockAdded.
if (node == null) {
throw new IllegalStateException("Node cannot be null at " + pos + "!");
}
RSUtils.debugLog("Creating node at " + pos);
if (node.getContainer().world() == null) {
node.setContainer(this);
manager.setNode(pos, node = createNode(world, pos));
manager.markForSaving();
}
if (legacyTag != null) {
@@ -144,7 +138,8 @@ public abstract class TileNode<N extends NetworkNode> extends TileBase implement
this.legacyTag = null;
}
public abstract N createNode();
// @TODO: This needs to be redone. Perhaps we need to reuse the node registry for this.
public abstract N createNode(World world, BlockPos pos);
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing side) {

View File

@@ -14,6 +14,8 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.client.Minecraft;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
@@ -134,7 +136,7 @@ public class TileReader extends TileNode<NetworkNodeReader> {
@Override
@Nonnull
public NetworkNodeReader createNode() {
return new NetworkNodeReader(this);
public NetworkNodeReader createNode(World world, BlockPos pos) {
return new NetworkNodeReader(world, pos);
}
}

View File

@@ -1,13 +1,15 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeRelay;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class TileRelay extends TileNode<NetworkNodeRelay> {
@Override
@Nonnull
public NetworkNodeRelay createNode() {
return new NetworkNodeRelay(this);
public NetworkNodeRelay createNode(World world, BlockPos pos) {
return new NetworkNodeRelay(world, pos);
}
}

View File

@@ -1,13 +1,15 @@
package com.raoulvdberge.refinedstorage.tile;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeSecurityManager;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
public class TileSecurityManager extends TileNode<NetworkNodeSecurityManager> {
@Override
@Nonnull
public NetworkNodeSecurityManager createNode() {
return new NetworkNodeSecurityManager(this);
public NetworkNodeSecurityManager createNode(World world, BlockPos pos) {
return new NetworkNodeSecurityManager(world, pos);
}
}

View File

@@ -6,6 +6,8 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
@@ -87,7 +89,7 @@ public class TileSolderer extends TileNode<NetworkNodeSolderer> {
@Override
@Nonnull
public NetworkNodeSolderer createNode() {
return new NetworkNodeSolderer(this);
public NetworkNodeSolderer createNode(World world, BlockPos pos) {
return new NetworkNodeSolderer(world, pos);
}
}

View File

@@ -6,6 +6,8 @@ import com.raoulvdberge.refinedstorage.tile.config.*;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -33,7 +35,7 @@ public class TileStorage extends TileNode<NetworkNodeStorage> {
@Override
@Nonnull
public NetworkNodeStorage createNode() {
return new NetworkNodeStorage(this);
public NetworkNodeStorage createNode(World world, BlockPos pos) {
return new NetworkNodeStorage(world, pos);
}
}

View File

@@ -7,6 +7,8 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nullable;
@@ -29,8 +31,8 @@ public class TileStorageMonitor extends TileNode<NetworkNodeStorageMonitor> {
}
@Override
public NetworkNodeStorageMonitor createNode() {
return new NetworkNodeStorageMonitor(this);
public NetworkNodeStorageMonitor createNode(World world, BlockPos pos) {
return new NetworkNodeStorageMonitor(world, pos);
}
@Override

View File

@@ -4,6 +4,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWirelessT
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -21,7 +23,7 @@ public class TileWirelessTransmitter extends TileNode<NetworkNodeWirelessTransmi
@Override
@Nonnull
public NetworkNodeWirelessTransmitter createNode() {
return new NetworkNodeWirelessTransmitter(this);
public NetworkNodeWirelessTransmitter createNode(World world, BlockPos pos) {
return new NetworkNodeWirelessTransmitter(world, pos);
}
}

View File

@@ -8,6 +8,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeWriter;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
@@ -108,7 +110,7 @@ public class TileWriter extends TileNode<NetworkNodeWriter> {
@Override
@Nonnull
public NetworkNodeWriter createNode() {
return new NetworkNodeWriter(this);
public NetworkNodeWriter createNode(World world, BlockPos pos) {
return new NetworkNodeWriter(world, pos);
}
}

View File

@@ -25,7 +25,7 @@ public interface IType {
if (value == 0 || value == 1) {
((IType) tile.getNode()).setType(value);
tile.getWorld().playerEntities.stream()
tile.world.playerEntities.stream()
.filter(p -> p.openContainer instanceof ContainerBase && ((ContainerBase) p.openContainer).getTile().getPos().equals(tile.getPos()))
.forEach(p -> p.openContainer.detectAndSendChanges());
}

View File

@@ -6,6 +6,8 @@ import com.raoulvdberge.refinedstorage.tile.data.ITileDataConsumer;
import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -33,7 +35,7 @@ public class TileCraftingMonitor extends TileNode<NetworkNodeCraftingMonitor> {
@Override
@Nonnull
public NetworkNodeCraftingMonitor createNode() {
return new NetworkNodeCraftingMonitor(this);
public NetworkNodeCraftingMonitor createNode(World world, BlockPos pos) {
return new NetworkNodeCraftingMonitor(world, pos);
}
}

View File

@@ -15,7 +15,7 @@ public class ContainerListener {
if (container instanceof ContainerBase) {
TileBase tile = ((ContainerBase) container).getTile();
if (tile != null && !tile.getWorld().isRemote) {
if (tile != null && !tile.world.isRemote) {
TileDataManager manager = tile.getDataManager();
manager.sendParametersTo((EntityPlayerMP) e.getEntityPlayer());
@@ -44,7 +44,7 @@ public class ContainerListener {
if (container instanceof ContainerBase) {
TileBase tile = ((ContainerBase) container).getTile();
if (tile != null && !tile.getWorld().isRemote) {
if (tile != null && !tile.world.isRemote) {
tile.getDataManager().getWatchers().remove(e.getEntityPlayer());
}
}

View File

@@ -8,6 +8,8 @@ import com.raoulvdberge.refinedstorage.tile.data.ITileDataProducer;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.client.Minecraft;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
@@ -141,7 +143,7 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
@Override
@Nonnull
public NetworkNodeGrid createNode() {
return new NetworkNodeGrid(this);
public NetworkNodeGrid createNode(World world, BlockPos pos) {
return new NetworkNodeGrid(world, pos);
}
}

View File

@@ -208,8 +208,8 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
}
public PortableGridType getPortableType() {
if (type == null && getWorld().getBlockState(pos).getBlock() == RSBlocks.PORTABLE_GRID) {
this.type = (PortableGridType) getWorld().getBlockState(pos).getValue(BlockPortableGrid.TYPE);
if (type == null && world.getBlockState(pos).getBlock() == RSBlocks.PORTABLE_GRID) {
this.type = (PortableGridType) world.getBlockState(pos).getValue(BlockPortableGrid.TYPE);
}
return type == null ? PortableGridType.NORMAL : type;
@@ -294,27 +294,27 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
@Override
public int getSortingType() {
return getWorld().isRemote ? SORTING_TYPE.getValue() : sortingType;
return world.isRemote ? SORTING_TYPE.getValue() : sortingType;
}
@Override
public int getSortingDirection() {
return getWorld().isRemote ? SORTING_DIRECTION.getValue() : sortingDirection;
return world.isRemote ? SORTING_DIRECTION.getValue() : sortingDirection;
}
@Override
public int getSearchBoxMode() {
return getWorld().isRemote ? SEARCH_BOX_MODE.getValue() : searchBoxMode;
return world.isRemote ? SEARCH_BOX_MODE.getValue() : searchBoxMode;
}
@Override
public int getTabSelected() {
return getWorld().isRemote ? TAB_SELECTED.getValue() : tabSelected;
return world.isRemote ? TAB_SELECTED.getValue() : tabSelected;
}
@Override
public int getSize() {
return getWorld().isRemote ? SIZE.getValue() : size;
return world.isRemote ? SIZE.getValue() : size;
}
public void setSortingType(int sortingType) {
@@ -424,15 +424,15 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
@Override
public boolean isActive() {
int stored = !getWorld().isRemote ? energyStorage.getEnergyStored() : ENERGY_STORED.getValue();
int stored = !world.isRemote ? energyStorage.getEnergyStored() : ENERGY_STORED.getValue();
if (getPortableType() != PortableGridType.CREATIVE && RS.INSTANCE.config.portableGridUsesEnergy && stored <= RS.INSTANCE.config.portableGridOpenUsage) {
return false;
}
RedstoneMode redstoneMode = !getWorld().isRemote ? this.redstoneMode : RedstoneMode.getById(REDSTONE_MODE.getValue());
RedstoneMode redstoneMode = !world.isRemote ? this.redstoneMode : RedstoneMode.getById(REDSTONE_MODE.getValue());
return redstoneMode.isEnabled(getWorld(), pos);
return redstoneMode.isEnabled(world, pos);
}
@Override
@@ -452,7 +452,7 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
@Override
public void drainEnergy(int energy) {
if (RS.INSTANCE.config.portableGridUsesEnergy && getPortableType() != PortableGridType.CREATIVE && redstoneMode.isEnabled(getWorld(), pos)) {
if (RS.INSTANCE.config.portableGridUsesEnergy && getPortableType() != PortableGridType.CREATIVE && redstoneMode.isEnabled(world, pos)) {
energyStorage.extractEnergyInternal(energy);
}
}