Begin work on apiimpl/network/node

This commit is contained in:
raoulvdberge
2019-08-29 14:46:17 +02:00
parent 96ede30356
commit 8e1aa6738f
26 changed files with 271 additions and 306 deletions

View File

@@ -19,5 +19,5 @@ public interface IWirelessTransmitter {
/**
* @return the dimension in which the transmitter is
*/
int getDimension();
int getDimension(); // TODO: return dimension actual value instead?
}

View File

@@ -6,15 +6,14 @@ import com.raoulvdberge.refinedstorage.api.network.INetworkNodeVisitor;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
import com.raoulvdberge.refinedstorage.util.WorldUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
@@ -39,7 +38,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
protected UUID owner;
protected String version;
private EnumFacing direction = EnumFacing.NORTH;
private Direction direction = Direction.NORTH;
// Disable throttling for the first tick.
// This is to make sure couldUpdate is going to be correctly set.
@@ -75,9 +74,10 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
@Nonnull
@Override
public ItemStack getItemStack() {
IBlockState state = world.getBlockState(pos);
BlockState state = world.getBlockState(pos);
return new ItemStack(Item.getItemFromBlock(state.getBlock()), 1, state.getBlock().getMetaFromState(state));
// TODO: Fix.
return new ItemStack(Item.getItemFromBlock(state.getBlock()), 1);
}
@Override
@@ -162,10 +162,10 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
@Override
public CompoundNBT write(CompoundNBT tag) {
if (owner != null) {
tag.setUniqueId(NBT_OWNER, owner);
tag.putUniqueId(NBT_OWNER, owner);
}
tag.setString(NBT_VERSION, RS.VERSION);
tag.putString(NBT_VERSION, RS.VERSION);
tag.putInt(NBT_DIRECTION, direction.ordinal());
@@ -185,21 +185,15 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
owner = tag.getUniqueId(NBT_OWNER);
}
if (tag.hasKey(NBT_DIRECTION)) {
direction = EnumFacing.byIndex(tag.getInteger(NBT_DIRECTION));
if (tag.contains(NBT_DIRECTION)) {
direction = Direction.byIndex(tag.getInt(NBT_DIRECTION));
}
if (tag.hasKey(NBT_VERSION)) {
if (tag.contains(NBT_VERSION)) {
version = tag.getString(NBT_VERSION);
}
readConfiguration(tag);
// We do this after readConfiguration so the 1.6 migration calls see that version is null.
OneSixMigrationHelper.removalHook();
if (version == null) {
version = RS.VERSION;
}
}
public void readConfiguration(CompoundNBT tag) {
@@ -222,13 +216,13 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
return world;
}
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return true;
}
@Override
public void visit(Operator operator) {
for (EnumFacing facing : EnumFacing.VALUES) {
for (Direction facing : Direction.values()) {
if (canConduct(facing)) {
operator.apply(world, pos.offset(facing), facing.getOpposite());
}
@@ -240,11 +234,11 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
return world.getTileEntity(pos.offset(getDirection()));
}
public EnumFacing getDirection() {
public Direction getDirection() {
return direction;
}
public void setDirection(EnumFacing direction) {
public void setDirection(Direction direction) {
this.direction = direction;
onDirectionChanged();

View File

@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeCable;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
@@ -39,7 +39,7 @@ public class NetworkNodeCable extends NetworkNode implements ICoverable, INetwor
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return coverManager.canConduct(direction);
}
@@ -56,7 +56,7 @@ public class NetworkNodeCable extends NetworkNode implements ICoverable, INetwor
public void read(CompoundNBT tag) {
super.read(tag);
if (tag.hasKey(NBT_COVERS)) {
if (tag.contains(NBT_COVERS)) {
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
}
}

View File

@@ -31,7 +31,7 @@ import net.minecraft.nbt.NBTUtil;
import net.minecraft.server.management.PlayerProfileCache;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntitySkull;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
@@ -68,7 +68,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_CRAFTING, ItemUpgrade.TYPE_STACK);
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int type = IType.ITEMS;
private boolean drop = false;
@@ -223,9 +223,9 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
if (item.hasTagCompound()) {
CompoundNBT tag = item.getTagCompound();
if (tag.hasKey("SkullOwner", 10)) {
if (tag.contains("SkullOwner", 10)) {
playerInfo = NBTUtil.readGameProfileFromNBT(tag.getCompound("SkullOwner"));
} else if (tag.hasKey("SkullOwner", 8) && !tag.getString("SkullOwner").isEmpty()) {
} else if (tag.contains("SkullOwner", 8) && !tag.getString("SkullOwner").isEmpty()) {
playerInfo = new GameProfile(null, tag.getString("SkullOwner"));
}
}
@@ -266,7 +266,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
// From BlockDispenser#getDispensePosition
private double getDispensePositionY() {
return (double) pos.getY() + (getDirection() == EnumFacing.DOWN ? 0.45D : 0.5D) + 0.8D * (double) getDirection().getYOffset();
return (double) pos.getY() + (getDirection() == Direction.DOWN ? 0.45D : 0.5D) + 0.8D * (double) getDirection().getYOffset();
}
// From BlockDispenser#getDispensePosition
@@ -328,25 +328,25 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_TYPE)) {
type = tag.getInteger(NBT_TYPE);
if (tag.contains(NBT_TYPE)) {
type = tag.getInt(NBT_TYPE);
}
if (tag.hasKey(NBT_DROP)) {
if (tag.contains(NBT_DROP)) {
drop = tag.getBoolean(NBT_DROP);
}
if (tag.hasKey(NBT_COVERS)) {
if (tag.contains(NBT_COVERS)) {
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
}
StackUtils.readItems(itemFilters, 0, tag);
if (tag.hasKey(NBT_FLUID_FILTERS)) {
if (tag.contains(NBT_FLUID_FILTERS)) {
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
}
}
@@ -369,7 +369,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return coverManager.canConduct(direction);
}

View File

@@ -16,8 +16,8 @@ import com.raoulvdberge.refinedstorage.util.WorldUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.INameable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorldNameable;
import net.minecraft.world.World;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.IItemHandler;
@@ -180,17 +180,13 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
StackUtils.readItems(patternsInventory, 0, tag);
if (API.instance().getOneSixMigrationHelper().migratePatternInventory(patternsInventory)) {
markDirty();
}
this.invalidate();
this.reading = false;
StackUtils.readItems(upgrades, 1, tag);
if (tag.hasKey(NBT_DISPLAY_NAME)) {
if (tag.contains(NBT_DISPLAY_NAME)) {
displayName = tag.getString(NBT_DISPLAY_NAME);
}
@@ -198,15 +194,15 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
uuid = tag.getUniqueId(NBT_UUID);
}
if (tag.hasKey(NBT_MODE)) {
mode = CrafterMode.getById(tag.getInteger(NBT_MODE));
if (tag.contains(NBT_MODE)) {
mode = CrafterMode.getById(tag.getInt(NBT_MODE));
}
if (tag.hasKey(NBT_LOCKED)) {
if (tag.contains(NBT_LOCKED)) {
locked = tag.getBoolean(NBT_LOCKED);
}
if (tag.hasKey(NBT_WAS_POWERED)) {
if (tag.contains(NBT_WAS_POWERED)) {
wasPowered = tag.getBoolean(NBT_WAS_POWERED);
}
}
@@ -224,11 +220,11 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
StackUtils.writeItems(upgrades, 1, tag);
if (displayName != null) {
tag.setString(NBT_DISPLAY_NAME, displayName);
tag.putString(NBT_DISPLAY_NAME, displayName);
}
if (uuid != null) {
tag.setUniqueId(NBT_UUID, uuid);
tag.putUniqueId(NBT_UUID, uuid);
}
tag.putInt(NBT_MODE, mode.ordinal());
@@ -326,8 +322,8 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
TileEntity facing = getConnectedTile();
if (facing instanceof IWorldNameable && ((IWorldNameable) facing).getName() != null) {
return ((IWorldNameable) facing).getName();
if (facing instanceof INameable && ((INameable) facing).getName() != null) {
return ((INameable) facing).getName().getString(); // TODO: DOes this even work
}
if (facing != null) {

View File

@@ -34,7 +34,7 @@ public class NetworkNodeCrafterManager extends NetworkNode {
public void sendTo(ServerPlayerEntity player) {
if (network != null) {
RS.INSTANCE.network.sendTo(new MessageCrafterManagerSlotSizes(network.getCraftingManager().getNamedContainers()), player);
// TODO RS.INSTANCE.network.sendTo(new MessageCrafterManagerSlotSizes(network.getCraftingManager().getNamedContainers()), player);
}
}
@@ -60,12 +60,12 @@ public class NetworkNodeCrafterManager extends NetworkNode {
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_SIZE)) {
size = tag.getInteger(NBT_SIZE);
if (tag.contains(NBT_SIZE)) {
size = tag.getInt(NBT_SIZE);
}
if (tag.hasKey(NBT_SEARCH_BOX_MODE)) {
searchBoxMode = tag.getInteger(NBT_SEARCH_BOX_MODE);
if (tag.contains(NBT_SEARCH_BOX_MODE)) {
searchBoxMode = tag.getInt(NBT_SEARCH_BOX_MODE);
}
}

View File

@@ -82,7 +82,7 @@ public class NetworkNodeCraftingMonitor extends NetworkNode implements ICrafting
tag.putInt(NBT_TAB_PAGE, tabPage);
if (tabSelected.isPresent()) {
tag.setUniqueId(NBT_TAB_SELECTED, tabSelected.get());
tag.putUniqueId(NBT_TAB_SELECTED, tabSelected.get());
}
return tag;
@@ -92,8 +92,8 @@ public class NetworkNodeCraftingMonitor extends NetworkNode implements ICrafting
public void read(CompoundNBT tag) {
super.read(tag);
if (tag.hasKey(NBT_TAB_PAGE)) {
tabPage = tag.getInteger(NBT_TAB_PAGE);
if (tag.contains(NBT_TAB_PAGE)) {
tabPage = tag.getInt(NBT_TAB_PAGE);
}
if (tag.hasUniqueId(NBT_TAB_SELECTED)) {

View File

@@ -28,7 +28,7 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.server.management.PlayerProfileCache;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityShulkerBox;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
@@ -239,7 +239,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
StackUtils.readItems(upgrades, 1, tag);
if (tag.hasKey(NBT_COVERS)) {
if (tag.contains(NBT_COVERS)) {
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
}
}
@@ -280,25 +280,25 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_MODE)) {
mode = tag.getInteger(NBT_MODE);
if (tag.contains(NBT_MODE)) {
mode = tag.getInt(NBT_MODE);
}
if (tag.hasKey(NBT_TYPE)) {
type = tag.getInteger(NBT_TYPE);
if (tag.contains(NBT_TYPE)) {
type = tag.getInt(NBT_TYPE);
}
if (tag.hasKey(NBT_PICKUP)) {
if (tag.contains(NBT_PICKUP)) {
pickupItem = tag.getBoolean(NBT_PICKUP);
}
StackUtils.readItems(itemFilters, 0, tag);
if (tag.hasKey(NBT_FLUID_FILTERS)) {
if (tag.contains(NBT_FLUID_FILTERS)) {
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
}
@@ -346,7 +346,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return coverManager.canConduct(direction);
}

View File

@@ -39,7 +39,7 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
private ItemHandlerBase itemFilters = new ItemHandlerBase(1, new ListenerNetworkNode(this));
private FluidInventory fluidFilters = new FluidInventory(1, new ListenerNetworkNode(this));
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int type = IType.ITEMS;
private int mode = MODE_EQUAL;
private int amount = 0;
@@ -63,7 +63,7 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
if (powered != wasPowered) {
wasPowered = powered;
world.notifyNeighborsOfStateChange(pos, RSBlocks.DETECTOR, true);
world.notifyNeighborsOfStateChange(pos, RSBlocks.DETECTOR);
WorldUtils.updateBlock(world, pos);
}
@@ -85,9 +85,9 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
if (slot != null) {
FluidStack stack = network.getFluidStorageCache().getList().get(slot, compare);
powered = isPowered(stack == null ? null : stack.amount);
powered = isPowered(stack == null ? null : stack.getAmount());
} else {
powered = isPowered(network.getFluidStorageCache().getList().getStacks().stream().map(s -> s.amount).mapToInt(Number::intValue).sum());
powered = isPowered(network.getFluidStorageCache().getList().getStacks().stream().map(FluidStack::getAmount).mapToInt(Number::intValue).sum());
}
}
}
@@ -186,25 +186,25 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_MODE)) {
mode = tag.getInteger(NBT_MODE);
if (tag.contains(NBT_MODE)) {
mode = tag.getInt(NBT_MODE);
}
if (tag.hasKey(NBT_AMOUNT)) {
amount = tag.getInteger(NBT_AMOUNT);
if (tag.contains(NBT_AMOUNT)) {
amount = tag.getInt(NBT_AMOUNT);
}
if (tag.hasKey(NBT_TYPE)) {
type = tag.getInteger(NBT_TYPE);
if (tag.contains(NBT_TYPE)) {
type = tag.getInt(NBT_TYPE);
}
StackUtils.readItems(itemFilters, 0, tag);
if (tag.hasKey(NBT_FLUID_FILTERS)) {
if (tag.contains(NBT_FLUID_FILTERS)) {
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
}
}

View File

@@ -16,11 +16,11 @@ import com.raoulvdberge.refinedstorage.util.StackUtils;
import com.raoulvdberge.refinedstorage.util.WorldUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.IItemHandler;
@@ -43,7 +43,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_CRAFTING, ItemUpgrade.TYPE_STACK);
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int type = IType.ITEMS;
private CoverManager coverManager = new CoverManager(this);
@@ -123,22 +123,22 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
FluidStack stack = fluids[filterSlot];
if (stack != null) {
int toExtract = Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount();
int toExtract = FluidAttributes.BUCKET_VOLUME * upgrades.getItemInteractCount();
FluidStack stackInStorage = network.getFluidStorageCache().getList().get(stack, compare);
if (stackInStorage != null) {
toExtract = Math.min(toExtract, stackInStorage.amount);
toExtract = Math.min(toExtract, stackInStorage.getAmount());
FluidStack took = network.extractFluid(stack, toExtract, compare, Action.SIMULATE);
if (took != null) {
int filled = handler.fill(took, false);
int filled = handler.fill(took, IFluidHandler.FluidAction.SIMULATE);
if (filled > 0) {
took = network.extractFluid(stack, filled, compare, Action.PERFORM);
handler.fill(took, true);
handler.fill(took, IFluidHandler.FluidAction.EXECUTE);
}
}
} else if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
@@ -201,7 +201,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
StackUtils.readItems(upgrades, 1, tag);
if (tag.hasKey(NBT_COVERS)) {
if (tag.contains(NBT_COVERS)) {
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
}
}
@@ -210,17 +210,17 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_TYPE)) {
type = tag.getInteger(NBT_TYPE);
if (tag.contains(NBT_TYPE)) {
type = tag.getInt(NBT_TYPE);
}
StackUtils.readItems(itemFilters, 0, tag);
if (tag.hasKey(NBT_FLUID_FILTERS)) {
if (tag.contains(NBT_FLUID_FILTERS)) {
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
}
}
@@ -257,7 +257,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return coverManager.canConduct(direction);
}

View File

@@ -14,7 +14,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode;
@@ -26,7 +25,7 @@ import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
@@ -52,7 +51,7 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
private FluidInventory fluidFilters = new FluidInventory(9, new ListenerNetworkNode(this));
private int priority = 0;
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
private AccessType accessType = AccessType.INSERT_EXTRACT;
@@ -118,7 +117,7 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
public void read(CompoundNBT tag) {
super.read(tag);
if (tag.hasKey(NBT_COVERS)) {
if (tag.contains(NBT_COVERS)) {
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
}
}
@@ -156,29 +155,27 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
StackUtils.readItems(itemFilters, 0, tag);
if (tag.hasKey(NBT_FLUID_FILTERS)) {
if (tag.contains(NBT_FLUID_FILTERS)) {
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
}
if (tag.hasKey(NBT_PRIORITY)) {
priority = tag.getInteger(NBT_PRIORITY);
if (tag.contains(NBT_PRIORITY)) {
priority = tag.getInt(NBT_PRIORITY);
}
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_MODE)) {
mode = tag.getInteger(NBT_MODE);
if (tag.contains(NBT_MODE)) {
mode = tag.getInt(NBT_MODE);
}
if (tag.hasKey(NBT_TYPE)) {
type = tag.getInteger(NBT_TYPE);
if (tag.contains(NBT_TYPE)) {
type = tag.getInt(NBT_TYPE);
}
accessType = AccessTypeUtils.readAccessType(tag);
OneSixMigrationHelper.migrateEmptyWhitelistToEmptyBlacklist(version, this, itemFilters);
}
@Override
@@ -369,7 +366,7 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return coverManager.canConduct(direction);
}

View File

@@ -17,7 +17,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IType;
import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
@@ -162,7 +162,7 @@ public class NetworkNodeFluidInterface extends NetworkNode {
}
private boolean isActingAsStorage() {
for (EnumFacing facing : EnumFacing.VALUES) {
for (Direction facing : Direction.VALUES) {
INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing));
if (facingNode instanceof NetworkNodeExternalStorage &&
@@ -201,11 +201,11 @@ public class NetworkNodeFluidInterface extends NetworkNode {
StackUtils.readItems(upgrades, 0, tag);
StackUtils.readItems(in, 1, tag);
if (tag.hasKey(NBT_TANK_IN)) {
if (tag.contains(NBT_TANK_IN)) {
tankIn.readFromNBT(tag.getCompound(NBT_TANK_IN));
}
if (tag.hasKey(NBT_TANK_OUT)) {
if (tag.contains(NBT_TANK_OUT)) {
tankOut.readFromNBT(tag.getCompound(NBT_TANK_OUT));
}
}
@@ -228,7 +228,7 @@ public class NetworkNodeFluidInterface extends NetworkNode {
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_OUT)) {
if (tag.contains(NBT_OUT)) {
out.readFromNbt(tag.getCompound(NBT_OUT));
}
}

View File

@@ -27,18 +27,23 @@ import com.raoulvdberge.refinedstorage.tile.config.IType;
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.block.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.*;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.items.IItemHandler;
@@ -70,7 +75,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
private static final String NBT_PROCESSING_TYPE = "ProcessingType";
private static final String NBT_PROCESSING_MATRIX_FLUIDS = "ProcessingMatrixFluids";
private Container craftingContainer = new Container() {
private Container craftingContainer = new Container(ContainerType.CRAFTING, 0) {
@Override
public boolean canInteractWith(PlayerEntity player) {
return false;
@@ -84,10 +89,10 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
}
};
private IRecipe currentRecipe;
private InventoryCrafting matrix = new InventoryCrafting(craftingContainer, 3, 3);
private InventoryCraftResult result = new InventoryCraftResult();
private CraftingInventory matrix = new CraftingInventory(craftingContainer, 3, 3);
private CraftResultInventory result = new CraftResultInventory();
private ItemHandlerBase processingMatrix = new ItemHandlerBase(9 * 2, new ListenerNetworkNode(this));
private FluidInventory processingMatrixFluids = new FluidInventory(9 * 2, Fluid.BUCKET_VOLUME * 64, new ListenerNetworkNode(this));
private FluidInventory processingMatrixFluids = new FluidInventory(9 * 2, FluidAttributes.BUCKET_VOLUME * 64, new ListenerNetworkNode(this));
private Set<IGridCraftingListener> craftingListeners = new HashSet<>();
@@ -131,7 +136,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
// Only allow in slot 1 when it isn't a blank pattern
// This makes it so that written patterns can be re-inserted in slot 1 to be overwritten again
// This makes it so that blank patterns can't be inserted in slot 1 through hoppers.
if (slot == 0 || stack.getTagCompound() != null) {
if (slot == 0 || stack.getTag() != null) {
return super.insertItem(slot, stack, simulate);
}
@@ -224,9 +229,10 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
@Override
public GridType getGridType() {
if (type == null) {
IBlockState state = world.getBlockState(pos);
BlockState state = world.getBlockState(pos);
if (state.getBlock() == RSBlocks.GRID) {
type = (GridType) state.getValue(BlockGrid.TYPE);
type = state.get(BlockGrid.TYPE);
}
}
@@ -302,12 +308,12 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
}
@Override
public InventoryCrafting getCraftingMatrix() {
public CraftingInventory getCraftingMatrix() {
return matrix;
}
@Override
public InventoryCraftResult getCraftingResult() {
public CraftResultInventory getCraftingResult() {
return result;
}
@@ -322,7 +328,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
@Override
public void onCraftingMatrixChanged() {
if (currentRecipe == null || !currentRecipe.matches(matrix, world)) {
currentRecipe = CraftingManager.findMatchingRecipe(matrix, world);
currentRecipe = world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, matrix, world).orElse(null); // TODO: does this work?
}
if (currentRecipe == null) {
@@ -388,7 +394,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
// If we are connected, first try to get the possibilities from the network
if (network != null) {
for (ItemStack possibility : possibilities) {
ItemStack took = network.extractItem(possibility, 1, IComparer.COMPARE_NBT | (possibility.getItem().isDamageable() ? 0 : IComparer.COMPARE_DAMAGE), Action.PERFORM);
ItemStack took = network.extractItem(possibility, 1, IComparer.COMPARE_NBT, Action.PERFORM);
if (took != null) {
grid.getCraftingMatrix().setInventorySlotContents(i, StackUtils.nullToEmpty(took));
@@ -731,16 +737,16 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
StackUtils.readItems(filter, 2, tag);
StackUtils.readItems(processingMatrix, 3, tag);
if (tag.hasKey(NBT_PROCESSING_MATRIX_FLUIDS)) {
if (tag.contains(NBT_PROCESSING_MATRIX_FLUIDS)) {
processingMatrixFluids.readFromNbt(tag.getCompound(NBT_PROCESSING_MATRIX_FLUIDS));
}
if (tag.hasKey(NBT_TAB_SELECTED)) {
tabSelected = tag.getInteger(NBT_TAB_SELECTED);
if (tag.contains(NBT_TAB_SELECTED)) {
tabSelected = tag.getInt(NBT_TAB_SELECTED);
}
if (tag.hasKey(NBT_TAB_PAGE)) {
tabPage = tag.getInteger(NBT_TAB_PAGE);
if (tag.contains(NBT_TAB_PAGE)) {
tabPage = tag.getInt(NBT_TAB_PAGE);
}
}
@@ -786,36 +792,36 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_VIEW_TYPE)) {
viewType = tag.getInteger(NBT_VIEW_TYPE);
if (tag.contains(NBT_VIEW_TYPE)) {
viewType = tag.getInt(NBT_VIEW_TYPE);
}
if (tag.hasKey(NBT_SORTING_DIRECTION)) {
sortingDirection = tag.getInteger(NBT_SORTING_DIRECTION);
if (tag.contains(NBT_SORTING_DIRECTION)) {
sortingDirection = tag.getInt(NBT_SORTING_DIRECTION);
}
if (tag.hasKey(NBT_SORTING_TYPE)) {
sortingType = tag.getInteger(NBT_SORTING_TYPE);
if (tag.contains(NBT_SORTING_TYPE)) {
sortingType = tag.getInt(NBT_SORTING_TYPE);
}
if (tag.hasKey(NBT_SEARCH_BOX_MODE)) {
searchBoxMode = tag.getInteger(NBT_SEARCH_BOX_MODE);
if (tag.contains(NBT_SEARCH_BOX_MODE)) {
searchBoxMode = tag.getInt(NBT_SEARCH_BOX_MODE);
}
if (tag.hasKey(NBT_SIZE)) {
size = tag.getInteger(NBT_SIZE);
if (tag.contains(NBT_SIZE)) {
size = tag.getInt(NBT_SIZE);
}
if (tag.hasKey(NBT_OREDICT_PATTERN)) {
if (tag.contains(NBT_OREDICT_PATTERN)) {
oredictPattern = tag.getBoolean(NBT_OREDICT_PATTERN);
}
if (tag.hasKey(NBT_PROCESSING_PATTERN)) {
if (tag.contains(NBT_PROCESSING_PATTERN)) {
processingPattern = tag.getBoolean(NBT_PROCESSING_PATTERN);
}
if (tag.hasKey(NBT_PROCESSING_TYPE)) {
processingType = tag.getInteger(NBT_PROCESSING_TYPE);
if (tag.contains(NBT_PROCESSING_TYPE)) {
processingType = tag.getInt(NBT_PROCESSING_TYPE);
}
}

View File

@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerUpgrade;
@@ -20,11 +19,11 @@ import com.raoulvdberge.refinedstorage.util.WorldUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.items.IItemHandler;
@@ -47,7 +46,7 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK);
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
@@ -111,18 +110,19 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
IFluidHandler handler = WorldUtils.getFluidHandler(getFacingTile(), getDirection().getOpposite());
if (handler != null) {
FluidStack stack = handler.drain(Fluid.BUCKET_VOLUME, false);
FluidStack stack = handler.drain(FluidAttributes.BUCKET_VOLUME, IFluidHandler.FluidAction.SIMULATE);
if (stack != null && IFilterable.acceptsFluid(fluidFilters, mode, compare, stack) && network.insertFluid(stack, stack.amount, Action.SIMULATE) == null) {
FluidStack toDrain = handler.drain(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), false);
if (stack != null && IFilterable.acceptsFluid(fluidFilters, mode, compare, stack) && network.insertFluid(stack, stack.getAmount(), Action.SIMULATE) == null) {
FluidStack toDrain = handler.drain(FluidAttributes.BUCKET_VOLUME * upgrades.getItemInteractCount(), IFluidHandler.FluidAction.EXECUTE); // TODO: is this execute?
if (toDrain != null) {
FluidStack remainder = network.insertFluidTracked(toDrain, toDrain.amount);
FluidStack remainder = network.insertFluidTracked(toDrain, toDrain.getAmount());
if (remainder != null) {
toDrain.amount -= remainder.amount;
toDrain.shrink(remainder.getAmount());
}
handler.drain(toDrain, true);
handler.drain(toDrain, IFluidHandler.FluidAction.EXECUTE);
}
}
}
@@ -159,7 +159,7 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
StackUtils.readItems(upgrades, 1, tag);
if (tag.hasKey(NBT_COVERS)) {
if (tag.contains(NBT_COVERS)) {
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
}
}
@@ -199,25 +199,23 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_MODE)) {
mode = tag.getInteger(NBT_MODE);
if (tag.contains(NBT_MODE)) {
mode = tag.getInt(NBT_MODE);
}
if (tag.hasKey(NBT_TYPE)) {
type = tag.getInteger(NBT_TYPE);
if (tag.contains(NBT_TYPE)) {
type = tag.getInt(NBT_TYPE);
}
StackUtils.readItems(itemFilters, 0, tag);
if (tag.hasKey(NBT_FLUID_FILTERS)) {
if (tag.contains(NBT_FLUID_FILTERS)) {
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
}
OneSixMigrationHelper.migrateEmptyWhitelistToEmptyBlacklist(version, this, itemFilters);
}
public IItemHandler getUpgrades() {
@@ -230,7 +228,7 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return coverManager.canConduct(direction);
}

View File

@@ -16,7 +16,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IType;
import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
@@ -36,7 +36,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK, ItemUpgrade.TYPE_CRAFTING);
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int currentSlot = 0;
@@ -135,7 +135,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
}
private boolean isActingAsStorage() {
for (EnumFacing facing : EnumFacing.VALUES) {
for (Direction facing : Direction.values()) {
INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing));
if (facingNode instanceof NetworkNodeExternalStorage &&
@@ -203,8 +203,8 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
StackUtils.readItems(exportFilterItems, 1, tag);
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
}

View File

@@ -100,7 +100,7 @@ public class NetworkNodeNetworkTransmitter extends NetworkNode {
}
public boolean isSameDimension() {
return world.provider.getDimension() == receiverDimension;
return world.getDimension().getType().getId() == receiverDimension;
}
private boolean canTransmit() {
@@ -123,11 +123,12 @@ public class NetworkNodeNetworkTransmitter extends NetworkNode {
if (canTransmit()) {
if (!isSameDimension()) {
final World dimensionWorld = DimensionManager.getWorld(receiverDimension);
if (dimensionWorld != null) {
operator.apply(dimensionWorld, receiver, null);
}
// TODO final World dimensionWorld = DimensionManager.getWorld(receiverDimension);
// if (dimensionWorld != null) {
// operator.apply(dimensionWorld, receiver, null);
// }
} else {
operator.apply(world, receiver, null);
}

View File

@@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.tile.TileReader;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
@@ -71,11 +71,11 @@ public class NetworkNodeReader extends NetworkNode implements IReader, IGuiReade
public void read(CompoundNBT tag) {
super.read(tag);
if (tag.hasKey(NBT_CHANNEL)) {
if (tag.contains(NBT_CHANNEL)) {
channel = tag.getString(NBT_CHANNEL);
}
if (tag.hasKey(NBT_COVERS)) {
if (tag.contains(NBT_COVERS)) {
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
}
}
@@ -89,7 +89,7 @@ public class NetworkNodeReader extends NetworkNode implements IReader, IGuiReade
public CompoundNBT write(CompoundNBT tag) {
super.write(tag);
tag.setString(NBT_CHANNEL, channel);
tag.putString(NBT_CHANNEL, channel);
tag.put(NBT_COVERS, coverManager.writeToNbt());
@@ -97,7 +97,7 @@ public class NetworkNodeReader extends NetworkNode implements IReader, IGuiReade
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return coverManager.canConduct(direction);
}

View File

@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.node;
import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -38,7 +38,7 @@ public class NetworkNodeRelay extends NetworkNode {
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return canUpdate();
}

View File

@@ -15,7 +15,7 @@ import net.minecraft.inventory.InventoryHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
@@ -41,7 +41,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
private Map<String, Pair<ItemStack, Long>> deposits = new HashMap<>();
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int oldAmount = -1;
@@ -82,7 +82,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
ItemStack inserted = deposit.getKey();
long insertedAt = deposit.getValue();
if (MinecraftServer.getCurrentTimeMillis() - insertedAt < DEPOSIT_ALL_MAX_DELAY) {
if (System.currentTimeMillis() - insertedAt < DEPOSIT_ALL_MAX_DELAY) {
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
ItemStack toInsert = player.inventory.getStackInSlot(i);
@@ -109,13 +109,13 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
if (!filter.isEmpty() && API.instance().getComparer().isEqual(filter, toInsert, compare)) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, StackUtils.nullToEmpty(network.insertItemTracked(toInsert, toInsert.getCount())));
deposits.put(player.getGameProfile().getName(), Pair.of(toInsert, MinecraftServer.getCurrentTimeMillis()));
deposits.put(player.getGameProfile().getName(), Pair.of(toInsert, System.currentTimeMillis()));
}
return true;
}
public void extract(PlayerEntity player, EnumFacing side) {
public void extract(PlayerEntity player, Direction side) {
if (network == null || getDirection() != side) {
return;
}
@@ -178,8 +178,8 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
StackUtils.readItems(itemFilter, 0, tag);

View File

@@ -8,7 +8,7 @@ import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode;
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
@@ -62,7 +62,7 @@ public class NetworkNodeWirelessTransmitter extends NetworkNode implements IWire
@Override
public int getDimension() {
return world.provider.getDimension();
return world.getDimension().getType().getId();
}
public ItemHandlerBase getUpgrades() {
@@ -75,8 +75,8 @@ public class NetworkNodeWirelessTransmitter extends NetworkNode implements IWire
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
return direction != null && EnumFacing.DOWN.equals(direction);
public boolean canConduct(@Nullable Direction direction) {
return direction != null && Direction.DOWN.equals(direction);
}
@Override
@@ -86,6 +86,6 @@ public class NetworkNodeWirelessTransmitter extends NetworkNode implements IWire
@Override
public void visit(Operator operator) {
operator.apply(world, pos.offset(EnumFacing.DOWN), EnumFacing.UP);
operator.apply(world, pos.offset(Direction.DOWN), Direction.UP);
}
}

View File

@@ -9,7 +9,7 @@ import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
import com.raoulvdberge.refinedstorage.tile.TileWriter;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
@@ -45,7 +45,7 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
if (getRedstoneStrength() != lastRedstoneStrength) {
lastRedstoneStrength = getRedstoneStrength();
world.notifyNeighborsOfStateChange(pos, RSBlocks.WRITER, true);
world.notifyNeighborsOfStateChange(pos, RSBlocks.WRITER);
}
}
@@ -103,11 +103,11 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
public void read(CompoundNBT tag) {
super.read(tag);
if (tag.hasKey(NBT_CHANNEL)) {
if (tag.contains(NBT_CHANNEL)) {
channel = tag.getString(NBT_CHANNEL);
}
if (tag.hasKey(NBT_COVERS)) {
if (tag.contains(NBT_COVERS)) {
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
}
}
@@ -121,7 +121,7 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
public CompoundNBT write(CompoundNBT tag) {
super.write(tag);
tag.setString(NBT_CHANNEL, channel);
tag.putString(NBT_CHANNEL, channel);
tag.put(NBT_COVERS, coverManager.writeToNbt());
@@ -129,7 +129,7 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
}
@Override
public boolean canConduct(@Nullable EnumFacing direction) {
public boolean canConduct(@Nullable Direction direction) {
return coverManager.canConduct(direction);
}

View File

@@ -10,13 +10,14 @@ import com.raoulvdberge.refinedstorage.item.ItemCover;
import net.minecraft.block.Block;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.BlockStainedGlass;
import net.minecraft.block.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Direction;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.ItemStackHandler;
@@ -30,14 +31,14 @@ public class CoverManager {
private static final String NBT_ITEM = "Item";
private static final String NBT_TYPE = "Type";
private Map<EnumFacing, Cover> covers = new HashMap<>();
private Map<Direction, Cover> covers = new HashMap<>();
private NetworkNode node;
public CoverManager(NetworkNode node) {
this.node = node;
}
public boolean canConduct(EnumFacing direction) {
public boolean canConduct(Direction direction) {
Cover cover = getCover(direction);
if (cover != null && cover.getType() != CoverType.HOLLOW) {
return false;
@@ -56,15 +57,15 @@ public class CoverManager {
}
@Nullable
public Cover getCover(EnumFacing facing) {
public Cover getCover(Direction facing) {
return covers.get(facing);
}
public boolean hasCover(EnumFacing facing) {
public boolean hasCover(Direction facing) {
return covers.containsKey(facing);
}
public boolean setCover(EnumFacing facing, @Nullable Cover cover) {
public boolean setCover(Direction facing, @Nullable Cover cover) {
if (cover == null || (isValidCover(cover.getStack()) && !hasCover(facing))) {
if (cover != null) {
if (facing == node.getDirection() && !(node instanceof NetworkNodeCable) && cover.getType() != CoverType.HOLLOW) {
@@ -96,10 +97,10 @@ public class CoverManager {
for (int i = 0; i < list.size(); ++i) {
CompoundNBT tag = list.getCompound(i);
if (tag.hasKey(NBT_DIRECTION) && tag.hasKey(NBT_ITEM)) {
EnumFacing direction = EnumFacing.byIndex(tag.getInteger(NBT_DIRECTION));
ItemStack item = new ItemStack(tag.getCompound(NBT_ITEM));
int type = tag.hasKey(NBT_TYPE) ? tag.getInteger(NBT_TYPE) : 0;
if (tag.contains(NBT_DIRECTION) && tag.contains(NBT_ITEM)) {
Direction direction = Direction.byIndex(tag.getInt(NBT_DIRECTION));
ItemStack item = ItemStack.read(tag.getCompound(NBT_ITEM));
int type = tag.contains(NBT_TYPE) ? tag.getInt(NBT_TYPE) : 0;
if (type >= CoverType.values().length) {
type = 0;
@@ -115,7 +116,7 @@ public class CoverManager {
public ListNBT writeToNbt() {
ListNBT list = new ListNBT();
for (Map.Entry<EnumFacing, Cover> entry : covers.entrySet()) {
for (Map.Entry<Direction, Cover> entry : covers.entrySet()) {
CompoundNBT tag = new CompoundNBT();
tag.putInt(NBT_DIRECTION, entry.getKey().ordinal());
@@ -133,7 +134,7 @@ public class CoverManager {
int i = 0;
for (Map.Entry<EnumFacing, Cover> entry : covers.entrySet()) {
for (Map.Entry<Direction, Cover> entry : covers.entrySet()) {
ItemStack cover = entry.getValue().getType().createStack();
ItemCover.setItem(cover, entry.getValue().getStack());
@@ -152,7 +153,7 @@ public class CoverManager {
Block block = getBlock(item);
IBlockState state = getBlockState(item);
BlockState state = getBlockState(item);
return block != null && state != null && ((isModelSupported(state) && block.isTopSolid(state) && !block.getTickRandomly() && !block.hasTileEntity(state)) || block instanceof BlockGlass || block instanceof BlockStainedGlass);
}
@@ -182,7 +183,7 @@ public class CoverManager {
@Nullable
@SuppressWarnings("deprecation")
public static IBlockState getBlockState(@Nullable ItemStack item) {
public static BlockState getBlockState(@Nullable ItemStack item) {
Block block = getBlock(item);
if (block == null) {

View File

@@ -9,12 +9,10 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiStorage;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode;
@@ -29,8 +27,8 @@ import net.minecraft.nbt.CompoundNBT;
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;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.common.thread.EffectiveSide;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
@@ -58,7 +56,7 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
protected void onContentsChanged(int slot) {
super.onContentsChanged(slot);
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
if (EffectiveSide.get() == LogicalSide.SERVER) { // TODO : correct?
StackUtils.createStorages(
world,
getStackInSlot(slot),
@@ -87,7 +85,7 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
private AccessType accessType = AccessType.INSERT_EXTRACT;
private int priority = 0;
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
@@ -176,10 +174,6 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
super.read(tag);
StackUtils.readItems(disks, 0, tag);
if (API.instance().getOneSixMigrationHelper().migrateDiskInventory(world, disks)) {
markDirty();
}
}
@Override
@@ -219,29 +213,27 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
StackUtils.readItems(itemFilters, 1, tag);
if (tag.hasKey(NBT_FLUID_FILTERS)) {
if (tag.contains(NBT_FLUID_FILTERS)) {
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
}
if (tag.hasKey(NBT_PRIORITY)) {
priority = tag.getInteger(NBT_PRIORITY);
if (tag.contains(NBT_PRIORITY)) {
priority = tag.getInt(NBT_PRIORITY);
}
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_MODE)) {
mode = tag.getInteger(NBT_MODE);
if (tag.contains(NBT_MODE)) {
mode = tag.getInt(NBT_MODE);
}
if (tag.hasKey(NBT_TYPE)) {
type = tag.getInteger(NBT_TYPE);
if (tag.contains(NBT_TYPE)) {
type = tag.getInt(NBT_TYPE);
}
accessType = AccessTypeUtils.readAccessType(tag);
OneSixMigrationHelper.migrateEmptyWhitelistToEmptyBlacklist(version, this, itemFilters);
}
@Override

View File

@@ -6,10 +6,8 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerContext;
import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.diskdrive.NetworkNodeDiskDrive;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerProxy;
@@ -26,10 +24,10 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.LogicalSide;
import net.minecraftforge.fml.common.thread.EffectiveSide;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
@@ -49,7 +47,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
private static final String NBT_IO_MODE = "IOMode";
private static final String NBT_FLUID_FILTERS = "FluidFilters";
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
private int ioMode = IO_MODE_INSERT;
@@ -63,7 +61,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
int count = super.getItemInteractCount();
if (type == IType.FLUIDS) {
count *= Fluid.BUCKET_VOLUME;
count *= FluidAttributes.BUCKET_VOLUME;
}
return count;
@@ -75,7 +73,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
protected void onContentsChanged(int slot) {
super.onContentsChanged(slot);
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
if (EffectiveSide.get() == LogicalSide.SERVER) { // TODO: correct?
StackUtils.createStorages(
world,
getStackInSlot(slot),
@@ -96,7 +94,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
protected void onContentsChanged(int slot) {
super.onContentsChanged(slot);
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
if (EffectiveSide.get() == LogicalSide.SERVER) { // TODO: correct?
StackUtils.createStorages(
world,
getStackInSlot(slot),
@@ -288,10 +286,10 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
return;
}
FluidStack remainder = network.insertFluid(extracted, extracted.amount, Action.PERFORM);
FluidStack remainder = network.insertFluid(extracted, extracted.getAmount(), Action.PERFORM);
if (remainder != null) {
storage.insert(remainder, remainder.amount, Action.PERFORM);
storage.insert(remainder, remainder.getAmount(), Action.PERFORM);
}
}
@@ -319,7 +317,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
continue;
}
FluidStack remainder = network.insertFluid(extracted, extracted.amount, Action.SIMULATE);
FluidStack remainder = network.insertFluid(extracted, extracted.getAmount(), Action.SIMULATE);
if (remainder == null) { // A fluid could be inserted (no remainders when trying to). This disk isn't done.
return false;
}
@@ -337,7 +335,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
int j = 0;
while ((toExtract == null || toExtract.amount == 0) && j < networkFluids.size()) {
while ((toExtract == null || toExtract.getAmount() == 0) && j < networkFluids.size()) {
toExtract = networkFluids.get(j++);
}
@@ -363,10 +361,10 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
return;
}
FluidStack remainder = storage.insert(extracted, extracted.amount, Action.PERFORM);
FluidStack remainder = storage.insert(extracted, extracted.getAmount(), Action.PERFORM);
if (remainder != null) {
network.insertFluid(remainder, remainder.amount, Action.PERFORM);
network.insertFluid(remainder, remainder.getAmount(), Action.PERFORM);
}
}
@@ -466,14 +464,6 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
StackUtils.readItems(upgrades, 3, tag);
StackUtils.readItems(inputDisks, 4, tag);
StackUtils.readItems(outputDisks, 5, tag);
if (API.instance().getOneSixMigrationHelper().migrateDiskInventory(world, inputDisks)) {
markDirty();
}
if (API.instance().getOneSixMigrationHelper().migrateDiskInventory(world, outputDisks)) {
markDirty();
}
}
@Override
@@ -513,27 +503,25 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
StackUtils.readItems(itemFilters, 1, tag);
if (tag.hasKey(NBT_FLUID_FILTERS)) {
if (tag.contains(NBT_FLUID_FILTERS)) {
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
}
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_MODE)) {
mode = tag.getInteger(NBT_MODE);
if (tag.contains(NBT_MODE)) {
mode = tag.getInt(NBT_MODE);
}
if (tag.hasKey(NBT_TYPE)) {
type = tag.getInteger(NBT_TYPE);
if (tag.contains(NBT_TYPE)) {
type = tag.getInt(NBT_TYPE);
}
if (tag.hasKey(NBT_IO_MODE)) {
ioMode = tag.getInteger(NBT_IO_MODE);
if (tag.contains(NBT_IO_MODE)) {
ioMode = tag.getInt(NBT_IO_MODE);
}
OneSixMigrationHelper.migrateEmptyWhitelistToEmptyBlacklist(version, this, itemFilters);
}
@Override

View File

@@ -13,7 +13,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiStorage;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheFluid;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.block.BlockFluidStorage;
import com.raoulvdberge.refinedstorage.block.enums.FluidStorageType;
import com.raoulvdberge.refinedstorage.inventory.fluid.FluidInventory;
@@ -25,7 +24,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
import com.raoulvdberge.refinedstorage.tile.config.IPrioritizable;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
@@ -95,7 +94,7 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
public CompoundNBT write(CompoundNBT tag) {
super.write(tag);
tag.setUniqueId(NBT_ID, storageId);
tag.putUniqueId(NBT_ID, storageId);
return tag;
}
@@ -109,8 +108,6 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
loadStorage();
}
OneSixMigrationHelper.migrateFluidStorageBlock(this, tag);
}
public void loadStorage() {
@@ -156,32 +153,31 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
public void readConfiguration(CompoundNBT tag) {
super.readConfiguration(tag);
if (tag.hasKey(NBT_FILTERS)) {
if (tag.contains(NBT_FILTERS)) {
filters.readFromNbt(tag.getCompound(NBT_FILTERS));
}
if (tag.hasKey(NBT_PRIORITY)) {
priority = tag.getInteger(NBT_PRIORITY);
if (tag.contains(NBT_PRIORITY)) {
priority = tag.getInt(NBT_PRIORITY);
}
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_MODE)) {
mode = tag.getInteger(NBT_MODE);
if (tag.contains(NBT_MODE)) {
mode = tag.getInt(NBT_MODE);
}
accessType = AccessTypeUtils.readAccessType(tag);
OneSixMigrationHelper.migrateEmptyWhitelistToEmptyBlacklist(version, this, null);
}
public FluidStorageType getType() {
if (type == null && world != null) {
IBlockState state = world.getBlockState(pos);
BlockState state = world.getBlockState(pos);
if (state.getBlock() == RSBlocks.FLUID_STORAGE) {
type = (FluidStorageType) state.getValue(BlockFluidStorage.TYPE);
type = state.get(BlockFluidStorage.TYPE);
}
}

View File

@@ -13,7 +13,6 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiStorage;
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNode;
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageCacheItem;
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
import com.raoulvdberge.refinedstorage.block.BlockStorage;
import com.raoulvdberge.refinedstorage.block.enums.ItemStorageType;
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
@@ -26,7 +25,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IPrioritizable;
import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.BlockPos;
@@ -50,7 +49,7 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
private AccessType accessType = AccessType.INSERT_EXTRACT;
private int priority = 0;
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int compare = IComparer.COMPARE_NBT;
private int mode = IFilterable.BLACKLIST;
private UUID storageId = UUID.randomUUID();
@@ -95,7 +94,7 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
public CompoundNBT write(CompoundNBT tag) {
super.write(tag);
tag.setUniqueId(NBT_ID, storageId);
tag.putUniqueId(NBT_ID, storageId);
return tag;
}
@@ -109,8 +108,6 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
loadStorage();
}
OneSixMigrationHelper.migrateItemStorageBlock(this, tag);
}
public void loadStorage() {
@@ -159,28 +156,27 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
StackUtils.readItems(filters, 0, tag);
if (tag.hasKey(NBT_PRIORITY)) {
priority = tag.getInteger(NBT_PRIORITY);
if (tag.contains(NBT_PRIORITY)) {
priority = tag.getInt(NBT_PRIORITY);
}
if (tag.hasKey(NBT_COMPARE)) {
compare = tag.getInteger(NBT_COMPARE);
if (tag.contains(NBT_COMPARE)) {
compare = tag.getInt(NBT_COMPARE);
}
if (tag.hasKey(NBT_MODE)) {
mode = tag.getInteger(NBT_MODE);
if (tag.contains(NBT_MODE)) {
mode = tag.getInt(NBT_MODE);
}
accessType = AccessTypeUtils.readAccessType(tag);
OneSixMigrationHelper.migrateEmptyWhitelistToEmptyBlacklist(version, this, filters);
}
public ItemStorageType getType() {
if (type == null && world != null) {
IBlockState state = world.getBlockState(pos);
BlockState state = world.getBlockState(pos);
if (state.getBlock() == RSBlocks.STORAGE) {
type = (ItemStorageType) state.getValue(BlockStorage.TYPE);
type = (ItemStorageType) state.get(BlockStorage.TYPE);
}
}