Fix errors in apiimpl pkg, but not in apiimpl/network/node pkg yet
This commit is contained in:
@@ -21,7 +21,6 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskSync;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IExternalStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IOneSixMigrationHelper;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IQuantityFormatter;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -196,15 +195,6 @@ public interface IRSAPI {
|
||||
*/
|
||||
ICraftingRequestInfo createCraftingRequestInfo(CompoundNBT tag) throws CraftingTaskReadException;
|
||||
|
||||
/**
|
||||
* Returns a helper for the 1.6.x migration.
|
||||
* Will be removed in 1.7.x!
|
||||
*
|
||||
* @return the 1.6.x migration helper
|
||||
*/
|
||||
@Nonnull
|
||||
IOneSixMigrationHelper getOneSixMigrationHelper();
|
||||
|
||||
/**
|
||||
* @param renderHandler the render handler to add
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.api.autocrafting.preview;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -42,7 +43,7 @@ public interface ICraftingPreviewElement<T> {
|
||||
/**
|
||||
* @param buf buffer to write to
|
||||
*/
|
||||
void writeToByteBuf(ByteBuf buf);
|
||||
void writeToByteBuf(PacketBuffer buf);
|
||||
|
||||
/**
|
||||
* Returns the id of this element, used for serialization and deserialization over the network.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.raoulvdberge.refinedstorage.api.network.grid;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -20,7 +21,7 @@ public interface IGridFactory {
|
||||
* @return the grid, or null if a problem occurred
|
||||
*/
|
||||
@Nullable
|
||||
IGrid createFromStack(ServerPlayerEntity player, ItemStack stack);
|
||||
IGrid createFromStack(PlayerEntity player, ItemStack stack);
|
||||
|
||||
/**
|
||||
* Creates a grid from a block. Used when {@link #getType()} is BLOCK.
|
||||
@@ -30,7 +31,7 @@ public interface IGridFactory {
|
||||
* @return the grid, or null if a problem occurred
|
||||
*/
|
||||
@Nullable
|
||||
IGrid createFromBlock(ServerPlayerEntity player, BlockPos pos);
|
||||
IGrid createFromBlock(PlayerEntity player, BlockPos pos);
|
||||
|
||||
/**
|
||||
* Returns a possible tile for this grid if {@link #getType()} is BLOCK.
|
||||
|
||||
@@ -9,9 +9,8 @@ import javax.annotation.Nullable;
|
||||
* Utilities for comparing item and fluid stacks.
|
||||
*/
|
||||
public interface IComparer {
|
||||
int COMPARE_DAMAGE = 1;
|
||||
int COMPARE_NBT = 2;
|
||||
int COMPARE_QUANTITY = 4;
|
||||
int COMPARE_NBT = 1;
|
||||
int COMPARE_QUANTITY = 2;
|
||||
|
||||
/**
|
||||
* Compares two stacks by the given flags.
|
||||
@@ -31,7 +30,7 @@ public interface IComparer {
|
||||
* @return true if the left and right stack are the same, false otherwise
|
||||
*/
|
||||
default boolean isEqual(@Nullable ItemStack left, @Nullable ItemStack right) {
|
||||
return isEqual(left, right, COMPARE_NBT | COMPARE_DAMAGE | COMPARE_QUANTITY);
|
||||
return isEqual(left, right, COMPARE_NBT | COMPARE_QUANTITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,7 +41,7 @@ public interface IComparer {
|
||||
* @return true if the left and right stack are the same, false otherwise
|
||||
*/
|
||||
default boolean isEqualNoQuantity(@Nullable ItemStack left, @Nullable ItemStack right) {
|
||||
return isEqual(left, right, COMPARE_NBT | COMPARE_DAMAGE);
|
||||
return isEqual(left, right, COMPARE_NBT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.api.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A helper for the changes in 1.6.
|
||||
*/
|
||||
public interface IOneSixMigrationHelper {
|
||||
/**
|
||||
* Migrates this disk over to the new 1.6 format *IF POSSIBLE*.
|
||||
* The given disk item needs to implement {@link com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider}!
|
||||
* This will call {@link com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider#setId(ItemStack, UUID)} on the disk, so make sure
|
||||
* a call to this method clears previous 1.5 and lower data, or this method will keep migrating constantly!
|
||||
* <p>
|
||||
* This will *ONLY* work with disks that were made using the IStorageDiskBehavior 1.5 API.
|
||||
* If you were using another method, you'll have to implement the migration code yourself.
|
||||
*
|
||||
* @param world the world
|
||||
* @param disk the disk to attempt to migrate
|
||||
* @return true if it migrated, false otherwise
|
||||
*/
|
||||
boolean migrateDisk(World world, ItemStack disk);
|
||||
|
||||
/**
|
||||
* Migrates an entire disk inventory.
|
||||
* Loops over every slot in the inventory and calls {@link #migrateDisk(World, ItemStack)}.
|
||||
* All the docs from {@link #migrateDisk(World, ItemStack)} apply here as well!
|
||||
* Don't forget to mark your tile dirty if this call returns true!
|
||||
*
|
||||
* @param world the world
|
||||
* @param handler the inventory
|
||||
* @return true if it migrated something in the inventory, false otherwise
|
||||
*/
|
||||
boolean migrateDiskInventory(World world, IItemHandlerModifiable handler);
|
||||
|
||||
/**
|
||||
* Migrates an entire pattern inventory.
|
||||
* Returns true if there were changes, and the caller should then mark their inventory dirty.
|
||||
*
|
||||
* @param handler the pattern inventory
|
||||
* @return true if a pattern has been converted, false otherwise
|
||||
*/
|
||||
boolean migratePatternInventory(IItemHandler handler);
|
||||
|
||||
/**
|
||||
* Migrates a single pattern stack.
|
||||
* Returns true if the stack was modified, and the caller should then mark their inventory dirty.
|
||||
* You most likely need {@link #migratePatternInventory(IItemHandler)}.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
* @return true if the pattern has been converted, false otherwise
|
||||
*/
|
||||
boolean migratePattern(ItemStack pattern);
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridManager;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeManager;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeRegistry;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterChannel;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHandlerRegistry;
|
||||
@@ -38,16 +37,14 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.*;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.*;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
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.minecraft.world.storage.MapStorage;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.discovery.ASMDataTable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -66,7 +63,6 @@ public class API implements IRSAPI {
|
||||
private IGridManager gridManager = new GridManager();
|
||||
private IStorageDiskRegistry storageDiskRegistry = new StorageDiskRegistry();
|
||||
private IStorageDiskSync storageDiskSync = new StorageDiskSync();
|
||||
private IOneSixMigrationHelper oneSixMigrationHelper = new OneSixMigrationHelper();
|
||||
private Map<StorageType, TreeSet<IExternalStorageProvider>> externalStorageProviders = new HashMap<>();
|
||||
private List<ICraftingPatternRenderHandler> patternRenderHandlers = new LinkedList<>();
|
||||
|
||||
@@ -74,7 +70,7 @@ public class API implements IRSAPI {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void deliver(ASMDataTable asmDataTable) {
|
||||
/* TODO API DELIVERY public static void deliver(ASMDataTable asmDataTable) {
|
||||
String annotationClassName = RSAPIInject.class.getCanonicalName();
|
||||
|
||||
Set<ASMDataTable.ASMData> asmDataSet = asmDataTable.getAll(annotationClassName);
|
||||
@@ -91,7 +87,7 @@ public class API implements IRSAPI {
|
||||
throw new RuntimeException("Failed to set: {}" + asmData.getClassName() + "." + asmData.getObjectName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@@ -117,6 +113,7 @@ public class API implements IRSAPI {
|
||||
throw new IllegalArgumentException("Attempting to access network node manager on the client");
|
||||
}
|
||||
|
||||
/* TODO: Saving
|
||||
MapStorage storage = world.getPerWorldStorage();
|
||||
NetworkNodeManager instance = (NetworkNodeManager) storage.getOrLoadData(NetworkNodeManager.class, NetworkNodeManager.NAME);
|
||||
|
||||
@@ -126,9 +123,9 @@ public class API implements IRSAPI {
|
||||
storage.setData(NetworkNodeManager.NAME, instance);
|
||||
} else {
|
||||
instance.tryReadNodes(world);
|
||||
}
|
||||
}*/
|
||||
|
||||
return instance;
|
||||
return new NetworkNodeManager("ABC");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -197,7 +194,7 @@ public class API implements IRSAPI {
|
||||
if (world.isRemote) {
|
||||
throw new IllegalArgumentException("Attempting to access storage disk manager on the client");
|
||||
}
|
||||
|
||||
/* TODO: Saving!
|
||||
MapStorage storage = world.getMapStorage();
|
||||
StorageDiskManager instance = (StorageDiskManager) storage.getOrLoadData(StorageDiskManager.class, StorageDiskManager.NAME);
|
||||
|
||||
@@ -207,9 +204,9 @@ public class API implements IRSAPI {
|
||||
storage.setData(StorageDiskManager.NAME, instance);
|
||||
} else {
|
||||
instance.tryReadDisks(world);
|
||||
}
|
||||
} */
|
||||
|
||||
return instance;
|
||||
return new StorageDiskManager("ABC");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -253,16 +250,10 @@ public class API implements IRSAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingRequestInfo createCraftingRequestInfo(NBTTagCompound tag) throws CraftingTaskReadException {
|
||||
public ICraftingRequestInfo createCraftingRequestInfo(CompoundNBT tag) throws CraftingTaskReadException {
|
||||
return new CraftingRequestInfo(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IOneSixMigrationHelper getOneSixMigrationHelper() {
|
||||
return oneSixMigrationHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPatternRenderHandler(ICraftingPatternRenderHandler renderHandler) {
|
||||
patternRenderHandlers.add(renderHandler);
|
||||
@@ -275,18 +266,19 @@ public class API implements IRSAPI {
|
||||
|
||||
@Override
|
||||
public void discoverNode(World world, BlockPos pos) {
|
||||
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||
for (Direction facing : Direction.values()) {
|
||||
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
||||
|
||||
if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite())) {
|
||||
INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite());
|
||||
INetworkNode node = nodeProxy.getNode();
|
||||
if (tile != null) {
|
||||
tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite()).ifPresent(nodeProxy -> {
|
||||
INetworkNode node = nodeProxy.getNode();
|
||||
|
||||
if (node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().world(), node.getNetwork().getPosition());
|
||||
if (node.getNetwork() != null) {
|
||||
node.getNetwork().getNodeGraph().invalidate(Action.PERFORM, node.getNetwork().world(), node.getNetwork().getPosition());
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,20 +286,19 @@ public class API implements IRSAPI {
|
||||
@Override
|
||||
public int getItemStackHashCode(ItemStack stack) {
|
||||
int result = stack.getItem().hashCode();
|
||||
result = 31 * result + (stack.getItemDamage() + 1);
|
||||
|
||||
if (stack.hasTagCompound()) {
|
||||
result = getHashCode(stack.getTagCompound(), result);
|
||||
if (stack.hasTag()) {
|
||||
result = getHashCode(stack.getTag(), result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getHashCode(NBTBase tag, int result) {
|
||||
if (tag instanceof NBTTagCompound) {
|
||||
result = getHashCode((NBTTagCompound) tag, result);
|
||||
} else if (tag instanceof NBTTagList) {
|
||||
result = getHashCode((NBTTagList) tag, result);
|
||||
private int getHashCode(INBT tag, int result) {
|
||||
if (tag instanceof CompoundNBT) {
|
||||
result = getHashCode((CompoundNBT) tag, result);
|
||||
} else if (tag instanceof ListNBT) {
|
||||
result = getHashCode((ListNBT) tag, result);
|
||||
} else {
|
||||
result = 31 * result + tag.hashCode();
|
||||
}
|
||||
@@ -315,17 +306,17 @@ public class API implements IRSAPI {
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getHashCode(NBTTagCompound tag, int result) {
|
||||
for (String key : tag.getKeySet()) {
|
||||
private int getHashCode(CompoundNBT tag, int result) {
|
||||
for (String key : tag.keySet()) {
|
||||
result = 31 * result + key.hashCode();
|
||||
result = getHashCode(tag.getTag(key), result);
|
||||
result = getHashCode(tag.get(key), result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getHashCode(NBTTagList tag, int result) {
|
||||
for (int i = 0; i < tag.tagCount(); ++i) {
|
||||
private int getHashCode(ListNBT tag, int result) {
|
||||
for (int i = 0; i < tag.size(); ++i) {
|
||||
result = getHashCode(tag.get(i), result);
|
||||
}
|
||||
|
||||
@@ -336,8 +327,8 @@ public class API implements IRSAPI {
|
||||
public int getFluidStackHashCode(FluidStack stack) {
|
||||
int result = stack.getFluid().hashCode();
|
||||
|
||||
if (stack.tag != null) {
|
||||
result = getHashCode(stack.tag, result);
|
||||
if (stack.getTag() != null) {
|
||||
result = getHashCode(stack.getTag(), result);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -346,7 +337,7 @@ public class API implements IRSAPI {
|
||||
@Override
|
||||
public int getNetworkNodeHashCode(INetworkNode node) {
|
||||
int result = node.getPos().hashCode();
|
||||
result = 31 * result + node.getWorld().provider.getDimension();
|
||||
result = 31 * result + node.getWorld().getDimension().getType().getId();
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -363,7 +354,7 @@ public class API implements IRSAPI {
|
||||
|
||||
INetworkNode rightNode = (INetworkNode) right;
|
||||
|
||||
if (left.getWorld().provider.getDimension() != rightNode.getWorld().provider.getDimension()) {
|
||||
if (left.getWorld().getDimension().getType().getId() != rightNode.getWorld().getDimension().getType().getId()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileController;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -42,7 +42,7 @@ public class CraftingManager implements ICraftingManager {
|
||||
private Map<UUID, ICraftingTask> tasks = new LinkedHashMap<>();
|
||||
private List<ICraftingTask> tasksToAdd = new ArrayList<>();
|
||||
private List<UUID> tasksToCancel = new ArrayList<>();
|
||||
private NBTTagList tasksToRead;
|
||||
private ListNBT tasksToRead;
|
||||
|
||||
private Map<Object, Long> throttledRequesters = new HashMap<>();
|
||||
|
||||
@@ -127,11 +127,11 @@ public class CraftingManager implements ICraftingManager {
|
||||
public void update() {
|
||||
if (network.canRun()) {
|
||||
if (tasksToRead != null) {
|
||||
for (int i = 0; i < tasksToRead.tagCount(); ++i) {
|
||||
NBTTagCompound taskTag = tasksToRead.getCompoundTagAt(i);
|
||||
for (int i = 0; i < tasksToRead.size(); ++i) {
|
||||
CompoundNBT taskTag = tasksToRead.getCompound(i);
|
||||
|
||||
String taskType = taskTag.getString(NBT_TASK_TYPE);
|
||||
NBTTagCompound taskData = taskTag.getCompoundTag(NBT_TASK_DATA);
|
||||
CompoundNBT taskData = taskTag.getCompound(NBT_TASK_DATA);
|
||||
|
||||
ICraftingTaskFactory factory = API.instance().getCraftingTaskRegistry().get(taskType);
|
||||
if (factory != null) {
|
||||
@@ -187,24 +187,24 @@ public class CraftingManager implements ICraftingManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNbt(NBTTagCompound tag) {
|
||||
this.tasksToRead = tag.getTagList(NBT_TASKS, Constants.NBT.TAG_COMPOUND);
|
||||
public void readFromNbt(CompoundNBT tag) {
|
||||
this.tasksToRead = tag.getList(NBT_TASKS, Constants.NBT.TAG_COMPOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt(NBTTagCompound tag) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (ICraftingTask task : tasks.values()) {
|
||||
NBTTagCompound taskTag = new NBTTagCompound();
|
||||
CompoundNBT taskTag = new CompoundNBT();
|
||||
|
||||
taskTag.setString(NBT_TASK_TYPE, task.getPattern().getId());
|
||||
taskTag.setTag(NBT_TASK_DATA, task.writeToNbt(new NBTTagCompound()));
|
||||
taskTag.putString(NBT_TASK_TYPE, task.getPattern().getId());
|
||||
taskTag.put(NBT_TASK_DATA, task.writeToNbt(new CompoundNBT()));
|
||||
|
||||
list.appendTag(taskTag);
|
||||
list.add(taskTag);
|
||||
}
|
||||
|
||||
tag.setTag(NBT_TASKS, list);
|
||||
tag.put(NBT_TASKS, list);
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -302,7 +302,7 @@ public class CraftingManager implements ICraftingManager {
|
||||
OneSixMigrationHelper.removalHook(); // Remove @Nullable source
|
||||
|
||||
if (source != null) {
|
||||
throttledRequesters.put(source, MinecraftServer.getCurrentTimeMillis());
|
||||
throttledRequesters.put(source, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ public class CraftingManager implements ICraftingManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
return MinecraftServer.getCurrentTimeMillis() - throttledSince < THROTTLE_DELAY_MS;
|
||||
return System.currentTimeMillis() - throttledSince < THROTTLE_DELAY_MS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,17 +7,15 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.registry.CraftingTaskFactory;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -58,7 +56,8 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
|
||||
ores.add(input.copy());
|
||||
|
||||
for (int id : OreDictionary.getOreIDs(input)) {
|
||||
// TODO: OREDICT
|
||||
/*for (int id : OreDictionary.getOreIDs(input)) {
|
||||
String name = OreDictionary.getOreName(id);
|
||||
|
||||
for (ItemStack ore : OreDictionary.getOres(name)) {
|
||||
@@ -68,10 +67,10 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
ores.add(ore.copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// Fix item count
|
||||
for (ItemStack ore: ores) {
|
||||
for (ItemStack ore : ores) {
|
||||
ore.setCount(input.getCount());
|
||||
}
|
||||
|
||||
@@ -102,7 +101,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
InventoryCrafting inv = new InventoryCraftingDummy();
|
||||
CraftingInventory inv = new CraftingInventoryDummy();
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
ItemStack input = ItemPattern.getInputSlot(stack, i);
|
||||
@@ -114,7 +113,8 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
}
|
||||
}
|
||||
|
||||
for (IRecipe r : CraftingManager.REGISTRY) {
|
||||
// TODO: better way of collecting recipes
|
||||
for (IRecipe r : world.getRecipeManager().getRecipes()) {
|
||||
if (r.matches(inv, world)) {
|
||||
this.recipe = r;
|
||||
|
||||
@@ -132,7 +132,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
inputs.clear();
|
||||
|
||||
for (int i = 0; i < recipe.getIngredients().size(); ++i) {
|
||||
inputs.add(i, NonNullList.from(ItemStack.EMPTY, recipe.getIngredients().get(i).getMatchingStacks()));
|
||||
inputs.add(i, NonNullList.from(ItemStack.EMPTY, ((Ingredient) recipe.getIngredients().get(i)).getMatchingStacks()));
|
||||
}
|
||||
} else {
|
||||
this.valid = false;
|
||||
@@ -190,7 +190,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.size() + ")");
|
||||
}
|
||||
|
||||
InventoryCrafting inv = new InventoryCraftingDummy();
|
||||
CraftingInventory inv = new CraftingInventoryDummy();
|
||||
|
||||
for (int i = 0; i < took.size(); ++i) {
|
||||
inv.setInventorySlotContents(i, took.get(i));
|
||||
@@ -223,7 +223,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
throw new IllegalArgumentException("The items that are taken (" + took.size() + ") should match the inputs for this pattern (" + inputs.size() + ")");
|
||||
}
|
||||
|
||||
InventoryCrafting inv = new InventoryCraftingDummy();
|
||||
CraftingInventory inv = new CraftingInventoryDummy();
|
||||
|
||||
for (int i = 0; i < took.size(); ++i) {
|
||||
inv.setInventorySlotContents(i, took.get(i));
|
||||
@@ -349,11 +349,11 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
return result;
|
||||
}
|
||||
|
||||
private class InventoryCraftingDummy extends InventoryCrafting {
|
||||
public InventoryCraftingDummy() {
|
||||
super(new Container() {
|
||||
class CraftingInventoryDummy extends CraftingInventory {
|
||||
public CraftingInventoryDummy() {
|
||||
super(new Container(null, 0) {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
public boolean canInteractWith(PlayerEntity player) {
|
||||
return true;
|
||||
}
|
||||
}, 3, 3);
|
||||
|
||||
@@ -3,14 +3,13 @@ package com.raoulvdberge.refinedstorage.apiimpl.autocrafting;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternChain;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPatternChainList;
|
||||
import gnu.trove.map.hash.TCustomHashMap;
|
||||
import gnu.trove.strategy.HashingStrategy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CraftingPatternChainList implements ICraftingPatternChainList {
|
||||
private Map<ICraftingPattern, CraftingPatternChain> map = new TCustomHashMap<>(new HashingStrategy<ICraftingPattern>() {
|
||||
/*private Map<ICraftingPattern, CraftingPatternChain> map = new TCustomHashMap<>(new HashingStrategy<ICraftingPattern>() {
|
||||
@Override
|
||||
public int computeHashCode(ICraftingPattern pattern) {
|
||||
return pattern.getChainHashCode();
|
||||
@@ -20,7 +19,9 @@ public class CraftingPatternChainList implements ICraftingPatternChainList {
|
||||
public boolean equals(ICraftingPattern left, ICraftingPattern right) {
|
||||
return left.canBeInChainWith(right);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
// TODO: broken
|
||||
private Map<ICraftingPattern, CraftingPatternChain> map = new HashMap<>();
|
||||
|
||||
public CraftingPatternChainList(List<ICraftingPattern> patterns) {
|
||||
for (ICraftingPattern pattern : patterns) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadExc
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInfo;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -16,15 +16,15 @@ public class CraftingRequestInfo implements ICraftingRequestInfo {
|
||||
private ItemStack item;
|
||||
private FluidStack fluid;
|
||||
|
||||
public CraftingRequestInfo(NBTTagCompound tag) throws CraftingTaskReadException {
|
||||
public CraftingRequestInfo(CompoundNBT tag) throws CraftingTaskReadException {
|
||||
if (!tag.getBoolean(NBT_FLUID)) {
|
||||
item = StackUtils.deserializeStackFromNbt(tag.getCompoundTag(NBT_STACK));
|
||||
item = StackUtils.deserializeStackFromNbt(tag.getCompound(NBT_STACK));
|
||||
|
||||
if (item.isEmpty()) {
|
||||
throw new CraftingTaskReadException("Extractor stack is empty");
|
||||
}
|
||||
} else {
|
||||
fluid = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag(NBT_STACK));
|
||||
fluid = FluidStack.loadFluidStackFromNBT(tag.getCompound(NBT_STACK));
|
||||
|
||||
if (fluid == null) {
|
||||
throw new CraftingTaskReadException("Extractor fluid stack is emty");
|
||||
@@ -53,15 +53,15 @@ public class CraftingRequestInfo implements ICraftingRequestInfo {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
tag.setBoolean(NBT_FLUID, fluid != null);
|
||||
tag.putBoolean(NBT_FLUID, fluid != null);
|
||||
|
||||
if (fluid != null) {
|
||||
tag.setTag(NBT_STACK, fluid.writeToNBT(new NBTTagCompound()));
|
||||
tag.put(NBT_STACK, fluid.writeToNBT(new CompoundNBT()));
|
||||
} else {
|
||||
tag.setTag(NBT_STACK, StackUtils.serializeStackToNbt(item));
|
||||
tag.put(NBT_STACK, StackUtils.serializeStackToNbt(item));
|
||||
}
|
||||
|
||||
return tag;
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -41,8 +41,8 @@ public class CraftingMonitorElementError implements ICraftingMonitorElement {
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buf) {
|
||||
ByteBufUtils.writeUTF8String(buf, base.getId());
|
||||
ByteBufUtils.writeUTF8String(buf, message);
|
||||
ByteBufUtil.writeUtf8(buf, base.getId());
|
||||
ByteBufUtil.writeUtf8(buf, message);
|
||||
|
||||
base.write(buf);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class CraftingMonitorElementFluidRender implements ICraftingMonitorElemen
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void draw(int x, int y, IElementDrawers drawers) {
|
||||
if (missing > 0) {
|
||||
drawers.getOverlayDrawer().draw(x, y, COLOR_MISSING);
|
||||
@@ -53,10 +53,11 @@ public class CraftingMonitorElementFluidRender implements ICraftingMonitorElemen
|
||||
|
||||
drawers.getFluidDrawer().draw(x + 4, y + 6, stack);
|
||||
|
||||
float scale = drawers.getFontRenderer().getUnicodeFlag() ? 1F : 0.5F;
|
||||
// TODO float scale = drawers.getFontRenderer().getUnicodeFlag() ? 1F : 0.5F;
|
||||
float scale = 1F;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
GlStateManager.scalef(scale, scale, 1);
|
||||
|
||||
int yy = y + 7;
|
||||
|
||||
@@ -99,7 +100,7 @@ public class CraftingMonitorElementFluidRender implements ICraftingMonitorElemen
|
||||
@Nullable
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return stack.getLocalizedName();
|
||||
return I18n.format(stack.getTranslationKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.craftingmonitor;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorElement;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -40,7 +40,7 @@ public class CraftingMonitorElementItemRender implements ICraftingMonitorElement
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void draw(int x, int y, IElementDrawers drawers) {
|
||||
if (missing > 0) {
|
||||
drawers.getOverlayDrawer().draw(x, y, COLOR_MISSING);
|
||||
@@ -54,10 +54,11 @@ public class CraftingMonitorElementItemRender implements ICraftingMonitorElement
|
||||
|
||||
drawers.getItemDrawer().draw(x + 4, y + 6, stack);
|
||||
|
||||
float scale = drawers.getFontRenderer().getUnicodeFlag() ? 1F : 0.5F;
|
||||
// TODO float scale = drawers.getFontRenderer().getUnicodeFlag() ? 1F : 0.5F;
|
||||
float scale = 1F;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
GlStateManager.scalef(scale, scale, 1);
|
||||
|
||||
int yy = y + 7;
|
||||
|
||||
|
||||
@@ -3,11 +3,10 @@ package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskErrorType;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
public class CraftingPreviewElementError implements ICraftingPreviewElement<ItemStack> {
|
||||
public static final String ID = "error";
|
||||
@@ -45,28 +44,30 @@ public class CraftingPreviewElementError implements ICraftingPreviewElement<Item
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: Rename to writeToBuffer.
|
||||
@Override
|
||||
public void writeToByteBuf(ByteBuf buf) {
|
||||
public void writeToByteBuf(PacketBuffer buf) {
|
||||
buf.writeInt(type.ordinal());
|
||||
// TODO can't we use writeItemStack here?
|
||||
buf.writeInt(Item.getIdFromItem(stack.getItem()));
|
||||
buf.writeInt(stack.getMetadata());
|
||||
ByteBufUtils.writeTag(buf, stack.getTagCompound());
|
||||
buf.writeCompoundTag(stack.getTag());
|
||||
}
|
||||
|
||||
public CraftingTaskErrorType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static CraftingPreviewElementError fromByteBuf(ByteBuf buf) {
|
||||
// TODO: Rename to fromBuffer
|
||||
public static CraftingPreviewElementError fromByteBuf(PacketBuffer buf) {
|
||||
int errorIdx = buf.readInt();
|
||||
CraftingTaskErrorType error = errorIdx >= 0 && errorIdx < CraftingTaskErrorType.values().length ? CraftingTaskErrorType.values()[errorIdx] : CraftingTaskErrorType.TOO_COMPLEX;
|
||||
|
||||
// TODO can't we use readItemStack here?
|
||||
Item item = Item.getItemById(buf.readInt());
|
||||
int meta = buf.readInt();
|
||||
NBTTagCompound tag = ByteBufUtils.readTag(buf);
|
||||
CompoundNBT tag = buf.readCompoundTag();
|
||||
|
||||
ItemStack stack = new ItemStack(item, 1, meta);
|
||||
stack.setTagCompound(tag);
|
||||
ItemStack stack = new ItemStack(item, 1);
|
||||
stack.put(tag);
|
||||
|
||||
return new CraftingPreviewElementError(error, stack);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class CraftingPreviewElementFluidStack implements ICraftingPreviewElement<FluidStack> {
|
||||
public static final String ID = "fluid_renderer";
|
||||
@@ -35,23 +31,23 @@ public class CraftingPreviewElementFluidStack implements ICraftingPreviewElement
|
||||
this.toCraft = toCraft;
|
||||
}
|
||||
|
||||
// TODO ren
|
||||
@Override
|
||||
public void writeToByteBuf(ByteBuf buf) {
|
||||
ByteBufUtils.writeUTF8String(buf, FluidRegistry.getFluidName(stack));
|
||||
ByteBufUtils.writeTag(buf, stack.tag);
|
||||
public void writeToByteBuf(PacketBuffer buf) {
|
||||
stack.writeToPacket(buf);
|
||||
buf.writeInt(available);
|
||||
buf.writeBoolean(missing);
|
||||
buf.writeInt(toCraft);
|
||||
}
|
||||
|
||||
public static CraftingPreviewElementFluidStack fromByteBuf(ByteBuf buf) {
|
||||
Fluid fluid = FluidRegistry.getFluid(ByteBufUtils.readUTF8String(buf));
|
||||
NBTTagCompound tag = ByteBufUtils.readTag(buf);
|
||||
//TODO ren
|
||||
public static CraftingPreviewElementFluidStack fromByteBuf(PacketBuffer buf) {
|
||||
FluidStack stack = FluidStack.readFromPacket(buf);
|
||||
int available = buf.readInt();
|
||||
boolean missing = buf.readBoolean();
|
||||
int toCraft = buf.readInt();
|
||||
|
||||
return new CraftingPreviewElementFluidStack(new FluidStack(fluid, 1, tag), available, missing, toCraft);
|
||||
return new CraftingPreviewElementFluidStack(stack, available, missing, toCraft);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,7 +56,7 @@ public class CraftingPreviewElementFluidStack implements ICraftingPreviewElement
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void draw(int x, int y, IElementDrawers drawers) {
|
||||
if (missing) {
|
||||
drawers.getOverlayDrawer().draw(x, y, 0xFFF2DEDE);
|
||||
@@ -71,12 +67,14 @@ public class CraftingPreviewElementFluidStack implements ICraftingPreviewElement
|
||||
|
||||
drawers.getFluidDrawer().draw(x, y, getElement());
|
||||
|
||||
float scale = drawers.getFontRenderer().getUnicodeFlag() ? 1F : 0.5F;
|
||||
// TODO
|
||||
//float scale = drawers.getFontRenderer().getUnicodeFlag() ? 1F : 0.5F;
|
||||
float scale = 1F;
|
||||
|
||||
y += 2;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
GlStateManager.scalef(scale, scale, 1);
|
||||
|
||||
if (getToCraft() > 0) {
|
||||
String format = hasMissing() ? "gui.refinedstorage:crafting_preview.missing" : "gui.refinedstorage:crafting_preview.to_craft";
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreviewElement;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawers;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
public class CraftingPreviewElementItemStack implements ICraftingPreviewElement<ItemStack> {
|
||||
@@ -34,26 +33,29 @@ public class CraftingPreviewElementItemStack implements ICraftingPreviewElement<
|
||||
this.toCraft = toCraft;
|
||||
}
|
||||
|
||||
// TODO ren
|
||||
@Override
|
||||
public void writeToByteBuf(ByteBuf buf) {
|
||||
public void writeToByteBuf(PacketBuffer buf) {
|
||||
// TODO can't we use writeItemSTack
|
||||
buf.writeInt(Item.getIdFromItem(stack.getItem()));
|
||||
buf.writeInt(stack.getMetadata());
|
||||
ByteBufUtils.writeTag(buf, stack.getTagCompound());
|
||||
buf.writeCompoundTag(stack.getTag());
|
||||
buf.writeInt(available);
|
||||
buf.writeBoolean(missing);
|
||||
buf.writeInt(toCraft);
|
||||
}
|
||||
|
||||
public static CraftingPreviewElementItemStack fromByteBuf(ByteBuf buf) {
|
||||
// TODO ren
|
||||
public static CraftingPreviewElementItemStack fromByteBuf(PacketBuffer buf) {
|
||||
// TODO readItemStack
|
||||
|
||||
Item item = Item.getItemById(buf.readInt());
|
||||
int meta = buf.readInt();
|
||||
NBTTagCompound tag = ByteBufUtils.readTag(buf);
|
||||
CompoundNBT tag = buf.readCompoundTag();
|
||||
int available = buf.readInt();
|
||||
boolean missing = buf.readBoolean();
|
||||
int toCraft = buf.readInt();
|
||||
|
||||
ItemStack stack = new ItemStack(item, 1, meta);
|
||||
stack.setTagCompound(tag);
|
||||
ItemStack stack = new ItemStack(item, 1);
|
||||
stack.put(tag);
|
||||
|
||||
return new CraftingPreviewElementItemStack(stack, available, missing, toCraft);
|
||||
}
|
||||
@@ -64,7 +66,7 @@ public class CraftingPreviewElementItemStack implements ICraftingPreviewElement<
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void draw(int x, int y, IElementDrawers drawers) {
|
||||
if (missing) {
|
||||
drawers.getOverlayDrawer().draw(x, y, 0xFFF2DEDE);
|
||||
@@ -75,12 +77,13 @@ public class CraftingPreviewElementItemStack implements ICraftingPreviewElement<
|
||||
|
||||
drawers.getItemDrawer().draw(x, y, getElement());
|
||||
|
||||
float scale = drawers.getFontRenderer().getUnicodeFlag() ? 1F : 0.5F;
|
||||
// TODO float scale = drawers.getFontRenderer().getUnicodeFlag() ? 1F : 0.5F;
|
||||
float scale = 1F;
|
||||
|
||||
y += 2;
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(scale, scale, 1);
|
||||
GlStateManager.scalef(scale, scale, 1);
|
||||
|
||||
if (getToCraft() > 0) {
|
||||
String format = hasMissing() ? "gui.refinedstorage:crafting_preview.missing" : "gui.refinedstorage:crafting_preview.to_craft";
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingRequestInf
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.task.CraftingTask;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CraftingTaskFactory implements ICraftingTaskFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICraftingTask createFromNbt(INetwork network, NBTTagCompound tag) throws CraftingTaskReadException {
|
||||
public ICraftingTask createFromNbt(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
return new CraftingTask(network, tag);
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
@@ -29,16 +29,16 @@ class Crafting {
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
public Crafting(INetwork network, NBTTagCompound tag) throws CraftingTaskReadException {
|
||||
this.pattern = CraftingTask.readPatternFromNbt(tag.getCompoundTag(NBT_PATTERN), network.world());
|
||||
this.toExtract = CraftingTask.readItemStackList(tag.getTagList(NBT_TO_EXTRACT, Constants.NBT.TAG_COMPOUND));
|
||||
public Crafting(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
this.pattern = CraftingTask.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.world());
|
||||
this.toExtract = CraftingTask.readItemStackList(tag.getList(NBT_TO_EXTRACT, Constants.NBT.TAG_COMPOUND));
|
||||
this.root = tag.getBoolean(NBT_ROOT);
|
||||
|
||||
this.took = NonNullList.create();
|
||||
|
||||
NBTTagList tookList = tag.getTagList(NBT_TOOK, Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < tookList.tagCount(); ++i) {
|
||||
ItemStack stack = StackUtils.deserializeStackFromNbt(tookList.getCompoundTagAt(i));
|
||||
ListNBT tookList = tag.getList(NBT_TOOK, Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < tookList.size(); ++i) {
|
||||
ItemStack stack = StackUtils.deserializeStackFromNbt(tookList.getCompound(i));
|
||||
|
||||
// Can be empty.
|
||||
took.add(stack);
|
||||
@@ -61,19 +61,19 @@ class Crafting {
|
||||
return toExtract;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNbt() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
tag.setTag(NBT_PATTERN, CraftingTask.writePatternToNbt(pattern));
|
||||
tag.setTag(NBT_TO_EXTRACT, CraftingTask.writeItemStackList(toExtract));
|
||||
tag.setBoolean(NBT_ROOT, root);
|
||||
tag.put(NBT_PATTERN, CraftingTask.writePatternToNbt(pattern));
|
||||
tag.put(NBT_TO_EXTRACT, CraftingTask.writeItemStackList(toExtract));
|
||||
tag.putBoolean(NBT_ROOT, root);
|
||||
|
||||
NBTTagList tookList = new NBTTagList();
|
||||
ListNBT tookList = new ListNBT();
|
||||
for (ItemStack took : this.took) {
|
||||
tookList.appendTag(StackUtils.serializeStackToNbt(took));
|
||||
tookList.add(StackUtils.serializeStackToNbt(took));
|
||||
}
|
||||
|
||||
tag.setTag(NBT_TOOK, tookList);
|
||||
tag.put(NBT_TOOK, tookList);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -26,13 +26,15 @@ import com.raoulvdberge.refinedstorage.apiimpl.storage.disk.StorageDiskItem;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -105,98 +107,98 @@ public class CraftingTask implements ICraftingTask {
|
||||
this.internalFluidStorage = new StorageDiskFluid(network.world(), -1);
|
||||
}
|
||||
|
||||
public CraftingTask(INetwork network, NBTTagCompound tag) throws CraftingTaskReadException {
|
||||
public CraftingTask(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
OneSixMigrationHelper.removalHook();
|
||||
|
||||
if (!tag.hasKey(NBT_INTERNAL_STORAGE)) {
|
||||
if (!tag.contains(NBT_INTERNAL_STORAGE)) {
|
||||
throw new CraftingTaskReadException("Couldn't read crafting task from before RS v1.6.4, skipping...");
|
||||
}
|
||||
|
||||
this.network = network;
|
||||
|
||||
this.requested = API.instance().createCraftingRequestInfo(tag.getCompoundTag(NBT_REQUESTED));
|
||||
this.quantity = tag.getInteger(NBT_QUANTITY);
|
||||
this.pattern = readPatternFromNbt(tag.getCompoundTag(NBT_PATTERN), network.world());
|
||||
this.ticks = tag.getInteger(NBT_TICKS);
|
||||
this.requested = API.instance().createCraftingRequestInfo(tag.getCompound(NBT_REQUESTED));
|
||||
this.quantity = tag.getInt(NBT_QUANTITY);
|
||||
this.pattern = readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.world());
|
||||
this.ticks = tag.getInt(NBT_TICKS);
|
||||
this.id = tag.getUniqueId(NBT_ID);
|
||||
this.executionStarted = tag.getLong(NBT_EXECUTION_STARTED);
|
||||
|
||||
if (tag.hasKey(NBT_TOTAL_STEPS)) {
|
||||
this.totalSteps = tag.getInteger(NBT_TOTAL_STEPS);
|
||||
if (tag.contains(NBT_TOTAL_STEPS)) {
|
||||
this.totalSteps = tag.getInt(NBT_TOTAL_STEPS);
|
||||
}
|
||||
|
||||
StorageDiskFactoryItem factoryItem = new StorageDiskFactoryItem();
|
||||
StorageDiskFactoryFluid factoryFluid = new StorageDiskFactoryFluid();
|
||||
|
||||
this.internalStorage = factoryItem.createFromNbt(network.world(), tag.getCompoundTag(NBT_INTERNAL_STORAGE));
|
||||
this.internalFluidStorage = factoryFluid.createFromNbt(network.world(), tag.getCompoundTag(NBT_INTERNAL_FLUID_STORAGE));
|
||||
this.internalStorage = factoryItem.createFromNbt(network.world(), tag.getCompound(NBT_INTERNAL_STORAGE));
|
||||
this.internalFluidStorage = factoryFluid.createFromNbt(network.world(), tag.getCompound(NBT_INTERNAL_FLUID_STORAGE));
|
||||
|
||||
this.toExtractInitial = readItemStackList(tag.getTagList(NBT_TO_EXTRACT_INITIAL, Constants.NBT.TAG_COMPOUND));
|
||||
this.toExtractInitialFluids = readFluidStackList(tag.getTagList(NBT_TO_EXTRACT_INITIAL_FLUIDS, Constants.NBT.TAG_COMPOUND));
|
||||
this.toExtractInitial = readItemStackList(tag.getList(NBT_TO_EXTRACT_INITIAL, Constants.NBT.TAG_COMPOUND));
|
||||
this.toExtractInitialFluids = readFluidStackList(tag.getList(NBT_TO_EXTRACT_INITIAL_FLUIDS, Constants.NBT.TAG_COMPOUND));
|
||||
|
||||
NBTTagList craftingList = tag.getTagList(NBT_CRAFTING, Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < craftingList.tagCount(); ++i) {
|
||||
crafting.add(new Crafting(network, craftingList.getCompoundTagAt(i)));
|
||||
ListNBT craftingList = tag.getList(NBT_CRAFTING, Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < craftingList.size(); ++i) {
|
||||
crafting.add(new Crafting(network, craftingList.getCompound(i)));
|
||||
}
|
||||
|
||||
NBTTagList processingList = tag.getTagList(NBT_PROCESSING, Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < processingList.tagCount(); ++i) {
|
||||
processing.add(new Processing(network, processingList.getCompoundTagAt(i)));
|
||||
ListNBT processingList = tag.getList(NBT_PROCESSING, Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < processingList.size(); ++i) {
|
||||
processing.add(new Processing(network, processingList.getCompound(i)));
|
||||
}
|
||||
|
||||
this.missing = readItemStackList(tag.getTagList(NBT_MISSING, Constants.NBT.TAG_COMPOUND));
|
||||
this.missingFluids = readFluidStackList(tag.getTagList(NBT_MISSING_FLUIDS, Constants.NBT.TAG_COMPOUND));
|
||||
this.missing = readItemStackList(tag.getList(NBT_MISSING, Constants.NBT.TAG_COMPOUND));
|
||||
this.missingFluids = readFluidStackList(tag.getList(NBT_MISSING_FLUIDS, Constants.NBT.TAG_COMPOUND));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt(NBTTagCompound tag) {
|
||||
tag.setTag(NBT_REQUESTED, requested.writeToNbt());
|
||||
tag.setInteger(NBT_QUANTITY, quantity);
|
||||
tag.setTag(NBT_PATTERN, writePatternToNbt(pattern));
|
||||
tag.setInteger(NBT_TICKS, ticks);
|
||||
tag.setUniqueId(NBT_ID, id);
|
||||
tag.setLong(NBT_EXECUTION_STARTED, executionStarted);
|
||||
tag.setTag(NBT_INTERNAL_STORAGE, internalStorage.writeToNbt());
|
||||
tag.setTag(NBT_INTERNAL_FLUID_STORAGE, internalFluidStorage.writeToNbt());
|
||||
tag.setTag(NBT_TO_EXTRACT_INITIAL, writeItemStackList(toExtractInitial));
|
||||
tag.setTag(NBT_TO_EXTRACT_INITIAL_FLUIDS, writeFluidStackList(toExtractInitialFluids));
|
||||
tag.setInteger(NBT_TOTAL_STEPS, totalSteps);
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
tag.put(NBT_REQUESTED, requested.writeToNbt());
|
||||
tag.putInt(NBT_QUANTITY, quantity);
|
||||
tag.put(NBT_PATTERN, writePatternToNbt(pattern));
|
||||
tag.putInt(NBT_TICKS, ticks);
|
||||
tag.putUniqueId(NBT_ID, id);
|
||||
tag.putLong(NBT_EXECUTION_STARTED, executionStarted);
|
||||
tag.put(NBT_INTERNAL_STORAGE, internalStorage.writeToNbt());
|
||||
tag.put(NBT_INTERNAL_FLUID_STORAGE, internalFluidStorage.writeToNbt());
|
||||
tag.put(NBT_TO_EXTRACT_INITIAL, writeItemStackList(toExtractInitial));
|
||||
tag.put(NBT_TO_EXTRACT_INITIAL_FLUIDS, writeFluidStackList(toExtractInitialFluids));
|
||||
tag.putInt(NBT_TOTAL_STEPS, totalSteps);
|
||||
|
||||
NBTTagList craftingList = new NBTTagList();
|
||||
ListNBT craftingList = new ListNBT();
|
||||
for (Crafting crafting : this.crafting) {
|
||||
craftingList.appendTag(crafting.writeToNbt());
|
||||
craftingList.add(crafting.writeToNbt());
|
||||
}
|
||||
|
||||
tag.setTag(NBT_CRAFTING, craftingList);
|
||||
tag.put(NBT_CRAFTING, craftingList);
|
||||
|
||||
NBTTagList processingList = new NBTTagList();
|
||||
ListNBT processingList = new ListNBT();
|
||||
for (Processing processing : this.processing) {
|
||||
processingList.appendTag(processing.writeToNbt());
|
||||
processingList.add(processing.writeToNbt());
|
||||
}
|
||||
|
||||
tag.setTag(NBT_PROCESSING, processingList);
|
||||
tag.put(NBT_PROCESSING, processingList);
|
||||
|
||||
tag.setTag(NBT_MISSING, writeItemStackList(missing));
|
||||
tag.setTag(NBT_MISSING_FLUIDS, writeFluidStackList(missingFluids));
|
||||
tag.put(NBT_MISSING, writeItemStackList(missing));
|
||||
tag.put(NBT_MISSING_FLUIDS, writeFluidStackList(missingFluids));
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
static NBTTagList writeItemStackList(IStackList<ItemStack> stacks) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
static ListNBT writeItemStackList(IStackList<ItemStack> stacks) {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (ItemStack stack : stacks.getStacks()) {
|
||||
list.appendTag(StackUtils.serializeStackToNbt(stack));
|
||||
list.add(StackUtils.serializeStackToNbt(stack));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static IStackList<ItemStack> readItemStackList(NBTTagList list) throws CraftingTaskReadException {
|
||||
static IStackList<ItemStack> readItemStackList(ListNBT list) throws CraftingTaskReadException {
|
||||
IStackList<ItemStack> stacks = API.instance().createItemStackList();
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
ItemStack stack = StackUtils.deserializeStackFromNbt(list.getCompoundTagAt(i));
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
ItemStack stack = StackUtils.deserializeStackFromNbt(list.getCompound(i));
|
||||
|
||||
if (stack.isEmpty()) {
|
||||
throw new CraftingTaskReadException("Empty stack!");
|
||||
@@ -208,21 +210,21 @@ public class CraftingTask implements ICraftingTask {
|
||||
return stacks;
|
||||
}
|
||||
|
||||
static NBTTagList writeFluidStackList(IStackList<FluidStack> stacks) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
static ListNBT writeFluidStackList(IStackList<FluidStack> stacks) {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (FluidStack stack : stacks.getStacks()) {
|
||||
list.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||
list.add(stack.writeToNBT(new CompoundNBT()));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static IStackList<FluidStack> readFluidStackList(NBTTagList list) throws CraftingTaskReadException {
|
||||
static IStackList<FluidStack> readFluidStackList(ListNBT list) throws CraftingTaskReadException {
|
||||
IStackList<FluidStack> stacks = API.instance().createFluidStackList();
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompoundTagAt(i));
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompound(i));
|
||||
|
||||
if (stack == null) {
|
||||
throw new CraftingTaskReadException("Empty stack!");
|
||||
@@ -444,11 +446,11 @@ public class CraftingTask implements ICraftingTask {
|
||||
FluidStack fromSelf = fluidResults.get(input, IComparer.COMPARE_NBT);
|
||||
FluidStack fromNetwork = mutatedFluidStorage.get(input, IComparer.COMPARE_NBT);
|
||||
|
||||
int remaining = input.amount;
|
||||
int remaining = input.getAmount();
|
||||
|
||||
while (remaining > 0) {
|
||||
if (fromSelf != null) {
|
||||
int toTake = Math.min(remaining, fromSelf.amount);
|
||||
int toTake = Math.min(remaining, fromSelf.getAmount());
|
||||
|
||||
fluidsToExtract.add(input, toTake);
|
||||
|
||||
@@ -458,7 +460,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
fromSelf = fluidResults.get(input, IComparer.COMPARE_NBT);
|
||||
} else if (fromNetwork != null) {
|
||||
int toTake = Math.min(remaining, fromNetwork.amount);
|
||||
int toTake = Math.min(remaining, fromNetwork.getAmount());
|
||||
|
||||
this.toTakeFluids.add(input, toTake);
|
||||
|
||||
@@ -477,7 +479,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
if (subPattern != null) {
|
||||
ICraftingPatternChain subPatternChain = patternChainList.getChain(subPattern);
|
||||
|
||||
while ((fromSelf == null ? 0 : fromSelf.amount) < remaining) {
|
||||
while ((fromSelf == null ? 0 : fromSelf.getAmount()) < remaining) {
|
||||
ICraftingTaskError result = calculateInternal(mutatedStorage, mutatedFluidStorage, results, fluidResults, patternChainList, subPatternChain.current(), false);
|
||||
|
||||
if (result != null) {
|
||||
@@ -495,7 +497,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
|
||||
// fromSelf contains the amount crafted after the loop.
|
||||
this.toCraftFluids.add(input, fromSelf.amount);
|
||||
this.toCraftFluids.add(input, fromSelf.getAmount());
|
||||
} else {
|
||||
this.missingFluids.add(input, remaining);
|
||||
|
||||
@@ -570,10 +572,10 @@ public class CraftingTask implements ICraftingTask {
|
||||
List<FluidStack> toRemove = new ArrayList<>();
|
||||
|
||||
for (FluidStack toExtract : toExtractInitialFluids.getStacks()) {
|
||||
FluidStack result = network.extractFluid(toExtract, toExtract.amount, Action.PERFORM);
|
||||
FluidStack result = network.extractFluid(toExtract, toExtract.getAmount(), Action.PERFORM);
|
||||
|
||||
if (result != null) {
|
||||
internalFluidStorage.insert(toExtract, result.amount, Action.PERFORM);
|
||||
internalFluidStorage.insert(toExtract, result.getAmount(), Action.PERFORM);
|
||||
|
||||
toRemove.add(result);
|
||||
}
|
||||
@@ -723,13 +725,13 @@ public class CraftingTask implements ICraftingTask {
|
||||
if (p.getPattern().getContainer().getConnectedFluidInventory() == null) {
|
||||
p.setState(ProcessingState.MACHINE_NONE);
|
||||
} else {
|
||||
FluidStack result = this.internalFluidStorage.extract(need, need.amount, IComparer.COMPARE_NBT, Action.SIMULATE);
|
||||
FluidStack result = this.internalFluidStorage.extract(need, need.getAmount(), IComparer.COMPARE_NBT, Action.SIMULATE);
|
||||
|
||||
if (result == null || result.amount != need.amount) {
|
||||
if (result == null || result.getAmount() != need.getAmount()) {
|
||||
hasAll = false;
|
||||
|
||||
break;
|
||||
} else if (p.getPattern().getContainer().getConnectedFluidInventory().fill(result, false) != result.amount) {
|
||||
} else if (p.getPattern().getContainer().getConnectedFluidInventory().fill(result, IFluidHandler.FluidAction.SIMULATE) != result.getAmount()) {
|
||||
p.setState(ProcessingState.MACHINE_DOES_NOT_ACCEPT);
|
||||
|
||||
break;
|
||||
@@ -756,13 +758,13 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
|
||||
for (FluidStack need : p.getFluidsToPut().getStacks()) {
|
||||
FluidStack result = this.internalFluidStorage.extract(need, need.amount, IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
if (result == null || result.amount != need.amount) {
|
||||
FluidStack result = this.internalFluidStorage.extract(need, need.getAmount(), IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
if (result == null || result.getAmount() != need.getAmount()) {
|
||||
throw new IllegalStateException("The internal crafting inventory reported that " + need + " was available but we got " + result);
|
||||
}
|
||||
|
||||
int filled = p.getPattern().getContainer().getConnectedFluidInventory().fill(result, true);
|
||||
if (filled != result.amount) {
|
||||
int filled = p.getPattern().getContainer().getConnectedFluidInventory().fill(result, IFluidHandler.FluidAction.EXECUTE);
|
||||
if (filled != result.getAmount()) {
|
||||
LOGGER.warn(p.getPattern().getContainer().getConnectedFluidInventory() + " unexpectedly didn't accept fluids, the remainder has been voided!");
|
||||
}
|
||||
}
|
||||
@@ -862,13 +864,13 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
|
||||
for (FluidStack stack : internalFluidStorage.getStacks()) {
|
||||
FluidStack remainder = network.insertFluid(stack, stack.amount, Action.PERFORM);
|
||||
FluidStack remainder = network.insertFluid(stack, stack.getAmount(), Action.PERFORM);
|
||||
|
||||
toPerform.add(() -> {
|
||||
if (remainder == null) {
|
||||
internalFluidStorage.extract(stack, stack.amount, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
internalFluidStorage.extract(stack, stack.getAmount(), IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
} else {
|
||||
internalFluidStorage.extract(stack, stack.amount - remainder.amount, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
internalFluidStorage.extract(stack, stack.getAmount() - remainder.getAmount(), IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -892,7 +894,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
|
||||
for (FluidStack remainder : internalFluidStorage.getStacks()) {
|
||||
network.insertFluid(remainder, remainder.amount, Action.PERFORM);
|
||||
network.insertFluid(remainder, remainder.getAmount(), Action.PERFORM);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -918,7 +920,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
} else {
|
||||
for (FluidStack output : pattern.getFluidOutputs()) {
|
||||
if (API.instance().getComparer().isEqual(output, requested.getFluid(), IComparer.COMPARE_NBT)) {
|
||||
qty += output.amount;
|
||||
qty += output.getAmount();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -984,7 +986,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
FluidStack content = p.getFluidsToReceive().get(stack);
|
||||
|
||||
if (content != null) {
|
||||
int needed = content.amount;
|
||||
int needed = content.getAmount();
|
||||
|
||||
if (needed > size) {
|
||||
needed = size;
|
||||
@@ -1017,22 +1019,22 @@ public class CraftingTask implements ICraftingTask {
|
||||
return size;
|
||||
}
|
||||
|
||||
static NBTTagCompound writePatternToNbt(ICraftingPattern pattern) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
static CompoundNBT writePatternToNbt(ICraftingPattern pattern) {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
tag.setTag(NBT_PATTERN_STACK, pattern.getStack().serializeNBT());
|
||||
tag.setLong(NBT_PATTERN_CONTAINER_POS, pattern.getContainer().getPosition().toLong());
|
||||
tag.put(NBT_PATTERN_STACK, pattern.getStack().serializeNBT());
|
||||
tag.putLong(NBT_PATTERN_CONTAINER_POS, pattern.getContainer().getPosition().toLong());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
static ICraftingPattern readPatternFromNbt(NBTTagCompound tag, World world) throws CraftingTaskReadException {
|
||||
static ICraftingPattern readPatternFromNbt(CompoundNBT tag, World world) throws CraftingTaskReadException {
|
||||
BlockPos containerPos = BlockPos.fromLong(tag.getLong(NBT_PATTERN_CONTAINER_POS));
|
||||
|
||||
INetworkNode node = API.instance().getNetworkNodeManager(world).getNode(containerPos);
|
||||
|
||||
if (node instanceof ICraftingPatternContainer) {
|
||||
ItemStack stack = new ItemStack(tag.getCompoundTag(NBT_PATTERN_STACK));
|
||||
ItemStack stack = ItemStack.read(tag.getCompound(NBT_PATTERN_STACK));
|
||||
|
||||
if (stack.getItem() instanceof ICraftingPatternProvider) {
|
||||
return ((ICraftingPatternProvider) stack.getItem()).create(world, stack, (ICraftingPatternContainer) node);
|
||||
@@ -1091,11 +1093,11 @@ public class CraftingTask implements ICraftingTask {
|
||||
elements.commit();
|
||||
|
||||
for (FluidStack stack : this.internalFluidStorage.getStacks()) {
|
||||
elements.add(new CraftingMonitorElementFluidRender(stack, stack.amount, 0, 0, 0, 0));
|
||||
elements.add(new CraftingMonitorElementFluidRender(stack, stack.getAmount(), 0, 0, 0, 0));
|
||||
}
|
||||
|
||||
for (FluidStack missing : this.missingFluids.getStacks()) {
|
||||
elements.add(new CraftingMonitorElementFluidRender(missing, 0, missing.amount, 0, 0, 0));
|
||||
elements.add(new CraftingMonitorElementFluidRender(missing, 0, missing.getAmount(), 0, 0, 0));
|
||||
}
|
||||
|
||||
for (Processing processing : this.processing) {
|
||||
@@ -1105,11 +1107,11 @@ public class CraftingTask implements ICraftingTask {
|
||||
|
||||
if (processing.getState() == ProcessingState.EXTRACTED_ALL) {
|
||||
for (FluidStack put : processing.getFluidsToPut().getStacks()) {
|
||||
elements.add(new CraftingMonitorElementFluidRender(put, 0, 0, put.amount, 0, 0));
|
||||
elements.add(new CraftingMonitorElementFluidRender(put, 0, 0, put.getAmount(), 0, 0));
|
||||
}
|
||||
} else if (processing.getState() == ProcessingState.READY || processing.getState() == ProcessingState.MACHINE_DOES_NOT_ACCEPT || processing.getState() == ProcessingState.MACHINE_NONE) {
|
||||
for (FluidStack receive : processing.getFluidsToReceive().getStacks()) {
|
||||
ICraftingMonitorElement element = new CraftingMonitorElementFluidRender(receive, 0, 0, 0, receive.amount, 0);
|
||||
ICraftingMonitorElement element = new CraftingMonitorElementFluidRender(receive, 0, 0, 0, receive.getAmount(), 0);
|
||||
|
||||
if (processing.getState() == ProcessingState.MACHINE_DOES_NOT_ACCEPT) {
|
||||
element = new CraftingMonitorElementError(element, "gui.refinedstorage:crafting_monitor.machine_does_not_accept_fluid");
|
||||
@@ -1155,7 +1157,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
previewStack = new CraftingPreviewElementFluidStack(stack);
|
||||
}
|
||||
|
||||
previewStack.addToCraft(stack.amount);
|
||||
previewStack.addToCraft(stack.getAmount());
|
||||
|
||||
mapFluids.put(hash, previewStack);
|
||||
}
|
||||
@@ -1185,7 +1187,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
}
|
||||
|
||||
previewStack.setMissing(true);
|
||||
previewStack.addToCraft(stack.amount);
|
||||
previewStack.addToCraft(stack.getAmount());
|
||||
|
||||
mapFluids.put(hash, previewStack);
|
||||
}
|
||||
@@ -1213,7 +1215,7 @@ public class CraftingTask implements ICraftingTask {
|
||||
previewStack = new CraftingPreviewElementFluidStack(stack);
|
||||
}
|
||||
|
||||
previewStack.addAvailable(stack.amount);
|
||||
previewStack.addAvailable(stack.getAmount());
|
||||
|
||||
mapFluids.put(hash, previewStack);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.task.CraftingTaskReadExc
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
@@ -35,14 +35,14 @@ class Processing {
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
public Processing(INetwork network, NBTTagCompound tag) throws CraftingTaskReadException {
|
||||
this.pattern = CraftingTask.readPatternFromNbt(tag.getCompoundTag(NBT_PATTERN), network.world());
|
||||
this.itemsToReceive = CraftingTask.readItemStackList(tag.getTagList(NBT_ITEMS_TO_RECEIVE, Constants.NBT.TAG_COMPOUND));
|
||||
this.fluidsToReceive = CraftingTask.readFluidStackList(tag.getTagList(NBT_FLUIDS_TO_RECEIVE, Constants.NBT.TAG_COMPOUND));
|
||||
public Processing(INetwork network, CompoundNBT tag) throws CraftingTaskReadException {
|
||||
this.pattern = CraftingTask.readPatternFromNbt(tag.getCompound(NBT_PATTERN), network.world());
|
||||
this.itemsToReceive = CraftingTask.readItemStackList(tag.getList(NBT_ITEMS_TO_RECEIVE, Constants.NBT.TAG_COMPOUND));
|
||||
this.fluidsToReceive = CraftingTask.readFluidStackList(tag.getList(NBT_FLUIDS_TO_RECEIVE, Constants.NBT.TAG_COMPOUND));
|
||||
this.root = tag.getBoolean(NBT_ROOT);
|
||||
this.itemsToPut = CraftingTask.readItemStackList(tag.getTagList(NBT_ITEMS_TO_PUT, Constants.NBT.TAG_COMPOUND));
|
||||
this.fluidsToPut = CraftingTask.readFluidStackList(tag.getTagList(NBT_FLUIDS_TO_PUT, Constants.NBT.TAG_COMPOUND));
|
||||
this.state = ProcessingState.values()[tag.getInteger(NBT_STATE)];
|
||||
this.itemsToPut = CraftingTask.readItemStackList(tag.getList(NBT_ITEMS_TO_PUT, Constants.NBT.TAG_COMPOUND));
|
||||
this.fluidsToPut = CraftingTask.readFluidStackList(tag.getList(NBT_FLUIDS_TO_PUT, Constants.NBT.TAG_COMPOUND));
|
||||
this.state = ProcessingState.values()[tag.getInt(NBT_STATE)];
|
||||
}
|
||||
|
||||
public ICraftingPattern getPattern() {
|
||||
@@ -77,16 +77,16 @@ class Processing {
|
||||
return root;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNbt() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
tag.setTag(NBT_PATTERN, CraftingTask.writePatternToNbt(pattern));
|
||||
tag.setTag(NBT_ITEMS_TO_RECEIVE, CraftingTask.writeItemStackList(itemsToReceive));
|
||||
tag.setTag(NBT_FLUIDS_TO_RECEIVE, CraftingTask.writeFluidStackList(fluidsToReceive));
|
||||
tag.setBoolean(NBT_ROOT, root);
|
||||
tag.setTag(NBT_ITEMS_TO_PUT, CraftingTask.writeItemStackList(itemsToPut));
|
||||
tag.setTag(NBT_FLUIDS_TO_PUT, CraftingTask.writeFluidStackList(fluidsToPut));
|
||||
tag.setInteger(NBT_STATE, state.ordinal());
|
||||
tag.put(NBT_PATTERN, CraftingTask.writePatternToNbt(pattern));
|
||||
tag.put(NBT_ITEMS_TO_RECEIVE, CraftingTask.writeItemStackList(itemsToReceive));
|
||||
tag.put(NBT_FLUIDS_TO_RECEIVE, CraftingTask.writeFluidStackList(fluidsToReceive));
|
||||
tag.putBoolean(NBT_ROOT, root);
|
||||
tag.put(NBT_ITEMS_TO_PUT, CraftingTask.writeItemStackList(itemsToPut));
|
||||
tag.put(NBT_FLUIDS_TO_PUT, CraftingTask.writeFluidStackList(fluidsToPut));
|
||||
tag.putInt(NBT_STATE, state.ordinal());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -6,15 +6,14 @@ import com.raoulvdberge.refinedstorage.api.network.INetworkNodeGraph;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNodeGraphListener;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkNodeVisitor;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.util.OneSixMigrationHelper;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -45,16 +44,14 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
Operator operator = new Operator(action);
|
||||
|
||||
TileEntity tile = world.getTileEntity(origin);
|
||||
if (tile != null && tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null)) {
|
||||
INetworkNodeProxy proxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null);
|
||||
|
||||
if (proxy != null) {
|
||||
if (tile != null) {
|
||||
tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null).ifPresent(proxy -> {
|
||||
INetworkNode node = proxy.getNode();
|
||||
|
||||
if (node instanceof INetworkNodeVisitor) {
|
||||
((INetworkNodeVisitor) node).visit(operator);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Visitor currentVisitor;
|
||||
@@ -125,12 +122,12 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
|
||||
private void dropConflictingBlock(World world, BlockPos pos) {
|
||||
if (!network.getPosition().equals(pos)) {
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
||||
NonNullList<ItemStack> drops = NonNullList.create();
|
||||
state.getBlock().getDrops(drops, world, pos, state, 0);
|
||||
// TODO: state.getBlock().getDrops(drops, world, pos, state, 0);
|
||||
|
||||
world.setBlockToAir(pos);
|
||||
world.removeBlock(pos, false); // TODO: correct?
|
||||
|
||||
for (ItemStack drop : drops) {
|
||||
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), drop);
|
||||
@@ -153,33 +150,34 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(World world, BlockPos pos, @Nullable EnumFacing side) {
|
||||
public void apply(World world, BlockPos pos, @Nullable Direction side) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile != null && tile.hasCapability(NETWORK_NODE_PROXY_CAPABILITY, side)) {
|
||||
INetworkNodeProxy otherNodeProxy = NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, side));
|
||||
INetworkNode otherNode = otherNodeProxy.getNode();
|
||||
if (tile != null) {
|
||||
tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, side).ifPresent(otherNodeProxy -> {
|
||||
INetworkNode otherNode = otherNodeProxy.getNode();
|
||||
|
||||
if (otherNode.getNetwork() != null && !otherNode.getNetwork().equals(network)) {
|
||||
if (action == Action.PERFORM) {
|
||||
dropConflictingBlock(world, tile.getPos());
|
||||
if (otherNode.getNetwork() != null && !otherNode.getNetwork().equals(network)) {
|
||||
if (action == Action.PERFORM) {
|
||||
dropConflictingBlock(world, tile.getPos());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (foundNodes.add(otherNode)) {
|
||||
if (!nodes.contains(otherNode)) {
|
||||
// We can't let the node connect immediately
|
||||
// We can only let the node connect AFTER the nodes list has changed in the graph
|
||||
// This is so that storage nodes can refresh the item/fluid cache, and the item/fluid cache will notice it then (otherwise not)
|
||||
newNodes.add(otherNode);
|
||||
}
|
||||
|
||||
if (foundNodes.add(otherNode)) {
|
||||
if (!nodes.contains(otherNode)) {
|
||||
// We can't let the node connect immediately
|
||||
// We can only let the node connect AFTER the nodes list has changed in the graph
|
||||
// This is so that storage nodes can refresh the item/fluid cache, and the item/fluid cache will notice it then (otherwise not)
|
||||
newNodes.add(otherNode);
|
||||
previousNodes.remove(otherNode);
|
||||
|
||||
toCheck.add(new Visitor(otherNode, world, pos, side, tile));
|
||||
}
|
||||
|
||||
previousNodes.remove(otherNode);
|
||||
|
||||
toCheck.add(new Visitor(otherNode, world, pos, side, tile));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,10 +191,10 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
private final INetworkNode node;
|
||||
private final World world;
|
||||
private final BlockPos pos;
|
||||
private final EnumFacing side;
|
||||
private final Direction side;
|
||||
private final TileEntity tile;
|
||||
|
||||
Visitor(INetworkNode node, World world, BlockPos pos, EnumFacing side, TileEntity tile) {
|
||||
Visitor(INetworkNode node, World world, BlockPos pos, Direction side, TileEntity tile) {
|
||||
this.node = node;
|
||||
this.world = world;
|
||||
this.pos = pos;
|
||||
@@ -209,17 +207,15 @@ public class NetworkNodeGraph implements INetworkNodeGraph {
|
||||
if (node instanceof INetworkNodeVisitor) {
|
||||
((INetworkNodeVisitor) node).visit(operator);
|
||||
} else {
|
||||
for (EnumFacing checkSide : EnumFacing.VALUES) {
|
||||
for (Direction checkSide : Direction.values()) {
|
||||
if (checkSide != side) { // Avoid going backward
|
||||
INetworkNodeProxy nodeOnSideProxy = NETWORK_NODE_PROXY_CAPABILITY.cast(tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, checkSide));
|
||||
|
||||
if (nodeOnSideProxy != null) {
|
||||
tile.getCapability(NETWORK_NODE_PROXY_CAPABILITY, checkSide).ifPresent(nodeOnSideProxy -> {
|
||||
INetworkNode nodeOnSide = nodeOnSideProxy.getNode();
|
||||
|
||||
if (nodeOnSide == node) {
|
||||
operator.apply(world, pos.offset(checkSide), checkSide.getOpposite());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.capability.CapabilityNetworkNodeProxy;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
@@ -31,7 +31,7 @@ public class NetworkNodeListener {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onBlockPlace(BlockEvent.EntityPlaceEvent e) {
|
||||
if (!e.getWorld().isRemote && e.getEntity() instanceof EntityPlayer) {
|
||||
if (!e.getWorld().isRemote && e.getEntity() instanceof PlayerEntity) {
|
||||
TileEntity placed = e.getWorld().getTileEntity(e.getPos());
|
||||
|
||||
if (placed != null && placed.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, null)) {
|
||||
@@ -42,8 +42,8 @@ public class NetworkNodeListener {
|
||||
INetworkNodeProxy nodeProxy = side.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, facing.getOpposite());
|
||||
INetworkNode node = nodeProxy.getNode();
|
||||
|
||||
if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, (EntityPlayer) e.getEntity())) {
|
||||
WorldUtils.sendNoPermissionMessage((EntityPlayer) e.getEntity());
|
||||
if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, (PlayerEntity) e.getEntity())) {
|
||||
WorldUtils.sendNoPermissionMessage((PlayerEntity) e.getEntity());
|
||||
|
||||
e.setCanceled(true);
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ 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.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
@@ -24,7 +24,7 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
private static final String NBT_NODE_POS = "Pos";
|
||||
|
||||
private boolean canReadNodes;
|
||||
private NBTTagList nodesTag;
|
||||
private ListNBT nodesTag;
|
||||
|
||||
private ConcurrentHashMap<BlockPos, INetworkNode> nodes = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -33,9 +33,9 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
public void readFromNBT(CompoundNBT tag) {
|
||||
if (tag.hasKey(NBT_NODES)) {
|
||||
this.nodesTag = tag.getTagList(NBT_NODES, Constants.NBT.TAG_COMPOUND);
|
||||
this.nodesTag = tag.getList(NBT_NODES, Constants.NBT.TAG_COMPOUND);
|
||||
this.canReadNodes = true;
|
||||
}
|
||||
}
|
||||
@@ -46,11 +46,11 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
|
||||
this.nodes.clear();
|
||||
|
||||
for (int i = 0; i < nodesTag.tagCount(); ++i) {
|
||||
NBTTagCompound nodeTag = nodesTag.getCompoundTagAt(i);
|
||||
for (int i = 0; i < nodesTag.size(); ++i) {
|
||||
CompoundNBT nodeTag = nodesTag.getCompound(i);
|
||||
|
||||
String id = nodeTag.getString(NBT_NODE_ID);
|
||||
NBTTagCompound data = nodeTag.getCompoundTag(NBT_NODE_DATA);
|
||||
CompoundNBT data = nodeTag.getCompound(NBT_NODE_DATA);
|
||||
BlockPos pos = BlockPos.fromLong(nodeTag.getLong(NBT_NODE_POS));
|
||||
|
||||
INetworkNodeFactory factory = API.instance().getNetworkNodeRegistry().get(id);
|
||||
@@ -73,24 +73,24 @@ public class NetworkNodeManager extends WorldSavedData implements INetworkNodeMa
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
public CompoundNBT writeToNBT(CompoundNBT tag) {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (INetworkNode node : all()) {
|
||||
try {
|
||||
NBTTagCompound nodeTag = new NBTTagCompound();
|
||||
CompoundNBT nodeTag = new CompoundNBT();
|
||||
|
||||
nodeTag.setString(NBT_NODE_ID, node.getId());
|
||||
nodeTag.setLong(NBT_NODE_POS, node.getPos().toLong());
|
||||
nodeTag.setTag(NBT_NODE_DATA, node.write(new NBTTagCompound()));
|
||||
nodeTag.put(NBT_NODE_DATA, node.write(new CompoundNBT()));
|
||||
|
||||
list.appendTag(nodeTag);
|
||||
list.add(nodeTag);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
tag.setTag(NBT_NODES, list);
|
||||
tag.put(NBT_NODES, list);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridFactory;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -15,14 +15,14 @@ import javax.annotation.Nullable;
|
||||
public class GridFactoryGridBlock implements IGridFactory {
|
||||
@Override
|
||||
@Nullable
|
||||
public IGrid createFromStack(EntityPlayer player, ItemStack stack) {
|
||||
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IGrid createFromBlock(EntityPlayer player, BlockPos pos) {
|
||||
TileEntity tile = getRelevantTile(player.world, pos);
|
||||
public IGrid createFromBlock(PlayerEntity player, BlockPos pos) {
|
||||
TileEntity tile = getRelevantTile(player.getEntityWorld(), pos);
|
||||
|
||||
if (tile instanceof TileGrid) {
|
||||
return ((TileGrid) tile).getNode();
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridFactory;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.PortableGrid;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -15,13 +15,13 @@ import javax.annotation.Nullable;
|
||||
public class GridFactoryPortableGrid implements IGridFactory {
|
||||
@Nullable
|
||||
@Override
|
||||
public IGrid createFromStack(EntityPlayer player, ItemStack stack) {
|
||||
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
||||
return new PortableGrid(player, stack);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IGrid createFromBlock(EntityPlayer player, BlockPos pos) {
|
||||
public IGrid createFromBlock(PlayerEntity player, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridFactory;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.TilePortableGrid;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -15,13 +15,13 @@ import javax.annotation.Nullable;
|
||||
public class GridFactoryPortableGridBlock implements IGridFactory {
|
||||
@Override
|
||||
@Nullable
|
||||
public IGrid createFromStack(EntityPlayer player, ItemStack stack) {
|
||||
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IGrid createFromBlock(EntityPlayer player, BlockPos pos) {
|
||||
public IGrid createFromBlock(PlayerEntity player, BlockPos pos) {
|
||||
TileEntity tile = getRelevantTile(player.world, pos);
|
||||
|
||||
if (tile instanceof TilePortableGrid) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridFactory;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.WirelessFluidGrid;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -15,13 +15,13 @@ import javax.annotation.Nullable;
|
||||
public class GridFactoryWirelessFluidGrid implements IGridFactory {
|
||||
@Nullable
|
||||
@Override
|
||||
public IGrid createFromStack(EntityPlayer player, ItemStack stack) {
|
||||
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
||||
return new WirelessFluidGrid(stack);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IGrid createFromBlock(EntityPlayer player, BlockPos pos) {
|
||||
public IGrid createFromBlock(PlayerEntity player, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.GridFactoryType;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridFactory;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.WirelessGrid;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -15,13 +15,13 @@ import javax.annotation.Nullable;
|
||||
public class GridFactoryWirelessGrid implements IGridFactory {
|
||||
@Nullable
|
||||
@Override
|
||||
public IGrid createFromStack(EntityPlayer player, ItemStack stack) {
|
||||
public IGrid createFromStack(PlayerEntity player, ItemStack stack) {
|
||||
return new WirelessGrid(stack);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IGrid createFromBlock(EntityPlayer player, BlockPos pos) {
|
||||
public IGrid createFromBlock(PlayerEntity player, BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.ResizableDisplayDummy;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridOpen;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -42,16 +42,16 @@ public class GridManager implements IGridManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGrid(int id, EntityPlayerMP player, BlockPos pos) {
|
||||
public void openGrid(int id, ServerPlayerEntity player, BlockPos pos) {
|
||||
openGrid(id, player, null, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openGrid(int id, EntityPlayerMP player, ItemStack stack) {
|
||||
public void openGrid(int id, ServerPlayerEntity player, ItemStack stack) {
|
||||
openGrid(id, player, stack, null);
|
||||
}
|
||||
|
||||
private void openGrid(int id, EntityPlayerMP player, @Nullable ItemStack stack, @Nullable BlockPos pos) {
|
||||
private void openGrid(int id, ServerPlayerEntity player, @Nullable ItemStack stack, @Nullable BlockPos pos) {
|
||||
Pair<IGrid, TileEntity> grid = createGrid(id, player, stack, pos);
|
||||
if (grid == null) {
|
||||
return;
|
||||
@@ -65,7 +65,7 @@ public class GridManager implements IGridManager {
|
||||
|
||||
// We first need to send the grid open packet with the window id.
|
||||
|
||||
// Then we set the openContainer so the slots are getting sent (EntityPlayerMP::update -> Container::detectAndSendChanges).
|
||||
// Then we set the openContainer so the slots are getting sent (ServerPlayerEntity::update -> Container::detectAndSendChanges).
|
||||
|
||||
// If the client window id mismatches with the server window id this causes problems with slots not being set.
|
||||
// If we would set the openContainer first, the slot packets would be sent first but wouldn't be able to be set
|
||||
@@ -73,18 +73,18 @@ public class GridManager implements IGridManager {
|
||||
// So we first send the window id in MessageGridOpen.
|
||||
|
||||
// The order is preserved by TCP.
|
||||
RS.INSTANCE.network.sendTo(new MessageGridOpen(player.currentWindowId, pos, id, stack), player);
|
||||
/* TODO ! RS.INSTANCE.network.sendTo(new MessageGridOpen(player.currentWindowId, pos, id, stack), player);
|
||||
|
||||
player.openContainer = new ContainerGrid(grid.getLeft(), new ResizableDisplayDummy(), grid.getRight() instanceof TileBase ? (TileBase) grid.getRight() : null, player);
|
||||
player.openContainer.windowId = player.currentWindowId;
|
||||
player.openContainer.addListener(player);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerContainerEvent.Open(player, player.openContainer));
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerContainerEvent.Open(player, player.openContainer));*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Pair<IGrid, TileEntity> createGrid(int id, EntityPlayer player, @Nullable ItemStack stack, @Nullable BlockPos pos) {
|
||||
public Pair<IGrid, TileEntity> createGrid(int id, PlayerEntity player, @Nullable ItemStack stack, @Nullable BlockPos pos) {
|
||||
IGridFactory factory = get(id);
|
||||
|
||||
if (factory == null) {
|
||||
|
||||
@@ -2,14 +2,11 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.GuiGrid;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridOpen;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileBase;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class GridOpenHandler implements Runnable {
|
||||
@@ -21,7 +18,7 @@ public class GridOpenHandler implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
PlayerEntity player = Minecraft.getInstance().player;
|
||||
|
||||
Pair<IGrid, TileEntity> grid = API.instance().getGridManager().createGrid(message.getGridId(), player, message.getStack(), message.getPos());
|
||||
|
||||
@@ -32,11 +29,11 @@ public class GridOpenHandler implements Runnable {
|
||||
GuiGrid gui = new GuiGrid(null, grid.getLeft());
|
||||
|
||||
// @Volatile: Just set the windowId: from OpenGuiHandler#process
|
||||
player.openContainer = new ContainerGrid(grid.getLeft(), gui, grid.getRight() instanceof TileBase ? (TileBase) grid.getRight() : null, player);
|
||||
/*TODO player.openContainer = new ContainerGrid(grid.getLeft(), gui, grid.getRight() instanceof TileBase ? (TileBase) grid.getRight() : null, player);
|
||||
player.openContainer.windowId = message.getWindowId();
|
||||
|
||||
gui.inventorySlots = player.openContainer;
|
||||
|
||||
FMLClientHandler.instance().showGuiScreen(gui);
|
||||
FMLClientHandler.instance().showGuiScreen(gui);*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGridTab;
|
||||
import com.raoulvdberge.refinedstorage.api.render.IElementDrawer;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -51,7 +51,7 @@ public class GridTab implements IGridTab {
|
||||
} else {
|
||||
fluidDrawer.draw(x, y, fluidIcon);
|
||||
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableAlphaTest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,16 @@ import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPrev
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingPreviewResponse;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingStartResponse;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -34,10 +38,10 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExtract(EntityPlayerMP player, int hash, boolean shift) {
|
||||
public void onExtract(ServerPlayerEntity player, int hash, boolean shift) {
|
||||
FluidStack stack = network.getFluidStorageCache().getList().get(hash);
|
||||
|
||||
if (stack == null || stack.amount < Fluid.BUCKET_VOLUME || !network.getSecurityManager().hasPermission(Permission.EXTRACT, player)) {
|
||||
if (stack == null || stack.getAmount() < FluidAttributes.BUCKET_VOLUME || !network.getSecurityManager().hasPermission(Permission.EXTRACT, player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,41 +65,41 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
}
|
||||
|
||||
if (bucket != null) {
|
||||
IFluidHandlerItem fluidHandler = bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
|
||||
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||
network.getFluidStorageTracker().changed(player, stack.copy());
|
||||
|
||||
network.getFluidStorageTracker().changed(player, stack.copy());
|
||||
fluidHandler.fill(network.extractFluid(stack, FluidAttributes.BUCKET_VOLUME, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
fluidHandler.fill(network.extractFluid(stack, Fluid.BUCKET_VOLUME, Action.PERFORM), true);
|
||||
|
||||
if (shift) {
|
||||
if (!player.inventory.addItemStackToInventory(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), fluidHandler.getContainer());
|
||||
if (shift) {
|
||||
if (!player.inventory.addItemStackToInventory(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), fluidHandler.getContainer());
|
||||
}
|
||||
} else {
|
||||
player.inventory.setItemStack(fluidHandler.getContainer());
|
||||
player.updateHeldItem();
|
||||
}
|
||||
} else {
|
||||
player.inventory.setItemStack(fluidHandler.getContainer());
|
||||
player.updateHeldItem();
|
||||
}
|
||||
|
||||
network.getNetworkItemHandler().drainEnergy(player, RS.INSTANCE.config.wirelessFluidGridExtractUsage);
|
||||
network.getNetworkItemHandler().drainEnergy(player, RS.INSTANCE.config.wirelessFluidGridExtractUsage);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack onInsert(EntityPlayerMP player, ItemStack container) {
|
||||
public ItemStack onInsert(ServerPlayerEntity player, ItemStack container) {
|
||||
if (!network.getSecurityManager().hasPermission(Permission.INSERT, player)) {
|
||||
return container;
|
||||
}
|
||||
|
||||
Pair<ItemStack, FluidStack> result = StackUtils.getFluid(container, true);
|
||||
|
||||
if (result.getValue() != null && network.insertFluid(result.getValue(), result.getValue().amount, Action.SIMULATE) == null) {
|
||||
if (result.getValue() != null && network.insertFluid(result.getValue(), result.getValue().getAmount(), Action.SIMULATE) == null) {
|
||||
network.getFluidStorageTracker().changed(player, result.getValue().copy());
|
||||
|
||||
result = StackUtils.getFluid(container, false);
|
||||
|
||||
network.insertFluid(result.getValue(), result.getValue().amount, Action.PERFORM);
|
||||
network.insertFluid(result.getValue(), result.getValue().getAmount(), Action.PERFORM);
|
||||
|
||||
network.getNetworkItemHandler().drainEnergy(player, RS.INSTANCE.config.wirelessFluidGridInsertUsage);
|
||||
|
||||
@@ -106,18 +110,18 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInsertHeldContainer(EntityPlayerMP player) {
|
||||
public void onInsertHeldContainer(ServerPlayerEntity player) {
|
||||
player.inventory.setItemStack(StackUtils.nullToEmpty(onInsert(player, player.inventory.getItemStack())));
|
||||
player.updateHeldItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onShiftClick(EntityPlayerMP player, ItemStack container) {
|
||||
public ItemStack onShiftClick(ServerPlayerEntity player, ItemStack container) {
|
||||
return StackUtils.nullToEmpty(onInsert(player, container));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingPreviewRequested(EntityPlayerMP player, int hash, int quantity, boolean noPreview) {
|
||||
public void onCraftingPreviewRequested(ServerPlayerEntity player, int hash, int quantity, boolean noPreview) {
|
||||
if (!network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)) {
|
||||
return;
|
||||
}
|
||||
@@ -142,13 +146,13 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
ICraftingTaskError error = task.calculate();
|
||||
|
||||
if (error != null) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(Collections.singletonList(new CraftingPreviewElementError(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())), hash, quantity, true), player);
|
||||
// TODO: Networking RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(Collections.singletonList(new CraftingPreviewElementError(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())), hash, quantity, true), player);
|
||||
} else if (noPreview && !task.hasMissing()) {
|
||||
network.getCraftingManager().add(task);
|
||||
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingStartResponse(), player);
|
||||
// TODO: Networking RS.INSTANCE.network.sendTo(new MessageGridCraftingStartResponse(), player);
|
||||
} else {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity, true), player);
|
||||
// TODO: Networking RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity, true), player);
|
||||
}
|
||||
}, "RS crafting preview calculation");
|
||||
|
||||
@@ -157,7 +161,7 @@ public class FluidGridHandler implements IFluidGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingRequested(EntityPlayerMP player, int hash, int quantity) {
|
||||
public void onCraftingRequested(ServerPlayerEntity player, int hash, int quantity) {
|
||||
if (quantity <= 0 || !network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,13 +7,13 @@ import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -26,10 +26,10 @@ public class FluidGridHandlerPortable implements IFluidGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExtract(EntityPlayerMP player, int hash, boolean shift) {
|
||||
public void onExtract(ServerPlayerEntity player, int hash, boolean shift) {
|
||||
FluidStack stack = portableGrid.getFluidCache().getList().get(hash);
|
||||
|
||||
if (stack == null || stack.amount < Fluid.BUCKET_VOLUME) {
|
||||
if (stack == null || stack.getAmount() < FluidAttributes.BUCKET_VOLUME) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,37 +49,37 @@ public class FluidGridHandlerPortable implements IFluidGridHandler {
|
||||
}
|
||||
|
||||
if (bucket != null) {
|
||||
IFluidHandlerItem fluidHandler = bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null);
|
||||
bucket.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null).ifPresent(fluidHandler -> {
|
||||
portableGrid.getFluidStorageTracker().changed(player, stack.copy());
|
||||
|
||||
portableGrid.getFluidStorageTracker().changed(player, stack.copy());
|
||||
fluidHandler.fill(portableGrid.getFluidStorage().extract(stack, FluidAttributes.BUCKET_VOLUME, IComparer.COMPARE_NBT, Action.PERFORM), IFluidHandler.FluidAction.EXECUTE);
|
||||
|
||||
fluidHandler.fill(portableGrid.getFluidStorage().extract(stack, Fluid.BUCKET_VOLUME, IComparer.COMPARE_NBT, Action.PERFORM), true);
|
||||
|
||||
if (shift) {
|
||||
if (!player.inventory.addItemStackToInventory(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), fluidHandler.getContainer());
|
||||
if (shift) {
|
||||
if (!player.inventory.addItemStackToInventory(fluidHandler.getContainer().copy())) {
|
||||
InventoryHelper.spawnItemStack(player.getEntityWorld(), player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ(), fluidHandler.getContainer());
|
||||
}
|
||||
} else {
|
||||
player.inventory.setItemStack(fluidHandler.getContainer());
|
||||
player.updateHeldItem();
|
||||
}
|
||||
} else {
|
||||
player.inventory.setItemStack(fluidHandler.getContainer());
|
||||
player.updateHeldItem();
|
||||
}
|
||||
|
||||
portableGrid.drainEnergy(RS.INSTANCE.config.portableGridExtractUsage);
|
||||
portableGrid.drainEnergy(RS.INSTANCE.config.portableGridExtractUsage);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack onInsert(EntityPlayerMP player, ItemStack container) {
|
||||
public ItemStack onInsert(ServerPlayerEntity player, ItemStack container) {
|
||||
Pair<ItemStack, FluidStack> result = StackUtils.getFluid(container, true);
|
||||
|
||||
if (result.getValue() != null && portableGrid.getFluidStorage().insert(result.getValue(), result.getValue().amount, Action.SIMULATE) == null) {
|
||||
if (result.getValue() != null && portableGrid.getFluidStorage().insert(result.getValue(), result.getValue().getAmount(), Action.SIMULATE) == null) {
|
||||
portableGrid.getFluidStorageTracker().changed(player, result.getValue().copy());
|
||||
|
||||
result = StackUtils.getFluid(container, false);
|
||||
|
||||
portableGrid.getFluidStorage().insert(result.getValue(), result.getValue().amount, Action.PERFORM);
|
||||
portableGrid.getFluidStorage().insert(result.getValue(), result.getValue().getAmount(), Action.PERFORM);
|
||||
|
||||
portableGrid.drainEnergy(RS.INSTANCE.config.portableGridInsertUsage);
|
||||
|
||||
@@ -90,23 +90,23 @@ public class FluidGridHandlerPortable implements IFluidGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInsertHeldContainer(EntityPlayerMP player) {
|
||||
public void onInsertHeldContainer(ServerPlayerEntity player) {
|
||||
player.inventory.setItemStack(StackUtils.nullToEmpty(onInsert(player, player.inventory.getItemStack())));
|
||||
player.updateHeldItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onShiftClick(EntityPlayerMP player, ItemStack container) {
|
||||
public ItemStack onShiftClick(ServerPlayerEntity player, ItemStack container) {
|
||||
return StackUtils.nullToEmpty(onInsert(player, container));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingPreviewRequested(EntityPlayerMP player, int hash, int quantity, boolean noPreview) {
|
||||
public void onCraftingPreviewRequested(ServerPlayerEntity player, int hash, int quantity, boolean noPreview) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingRequested(EntityPlayerMP player, int hash, int quantity) {
|
||||
public void onCraftingRequested(ServerPlayerEntity player, int hash, int quantity) {
|
||||
// NO OP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,19 +10,15 @@ import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IStackList;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.autocrafting.preview.CraftingPreviewElementError;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingPreviewResponse;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridCraftingStartResponse;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemGridHandler implements IItemGridHandler {
|
||||
@@ -33,7 +29,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExtract(EntityPlayerMP player, int hash, int flags) {
|
||||
public void onExtract(ServerPlayerEntity player, int hash, int flags) {
|
||||
ItemStack item = network.getItemStorageCache().getList().get(hash);
|
||||
|
||||
if (item == null || !network.getSecurityManager().hasPermission(Permission.EXTRACT, player)) {
|
||||
@@ -83,9 +79,9 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
|
||||
if (took != null) {
|
||||
if ((flags & EXTRACT_SHIFT) == EXTRACT_SHIFT) {
|
||||
IItemHandler playerInventory = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
|
||||
IItemHandler playerInventory = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
|
||||
|
||||
if (ItemHandlerHelper.insertItem(playerInventory, took, true).isEmpty()) {
|
||||
if (playerInventory != null && ItemHandlerHelper.insertItem(playerInventory, took, true).isEmpty()) {
|
||||
took = network.extractItem(item, size, Action.PERFORM);
|
||||
|
||||
if (took != null) {
|
||||
@@ -111,7 +107,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onInsert(EntityPlayerMP player, ItemStack stack) {
|
||||
public ItemStack onInsert(ServerPlayerEntity player, ItemStack stack) {
|
||||
if (!network.getSecurityManager().hasPermission(Permission.INSERT, player)) {
|
||||
return stack;
|
||||
}
|
||||
@@ -126,7 +122,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInsertHeldItem(EntityPlayerMP player, boolean single) {
|
||||
public void onInsertHeldItem(ServerPlayerEntity player, boolean single) {
|
||||
if (player.inventory.getItemStack().isEmpty() || !network.getSecurityManager().hasPermission(Permission.INSERT, player)) {
|
||||
return;
|
||||
}
|
||||
@@ -156,12 +152,12 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onShiftClick(EntityPlayerMP player, ItemStack stack) {
|
||||
public ItemStack onShiftClick(ServerPlayerEntity player, ItemStack stack) {
|
||||
return StackUtils.nullToEmpty(onInsert(player, stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingPreviewRequested(EntityPlayerMP player, int hash, int quantity, boolean noPreview) {
|
||||
public void onCraftingPreviewRequested(ServerPlayerEntity player, int hash, int quantity, boolean noPreview) {
|
||||
if (!network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)) {
|
||||
return;
|
||||
}
|
||||
@@ -186,13 +182,13 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
ICraftingTaskError error = task.calculate();
|
||||
|
||||
if (error != null) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(Collections.singletonList(new CraftingPreviewElementError(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())), hash, quantity, false), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(Collections.singletonList(new CraftingPreviewElementError(error.getType(), error.getRecursedPattern() == null ? ItemStack.EMPTY : error.getRecursedPattern().getStack())), hash, quantity, false), player);
|
||||
} else if (noPreview && !task.hasMissing()) {
|
||||
network.getCraftingManager().add(task);
|
||||
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingStartResponse(), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridCraftingStartResponse(), player);
|
||||
} else {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity, false), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity, false), player);
|
||||
}
|
||||
}, "RS crafting preview calculation");
|
||||
|
||||
@@ -201,7 +197,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingRequested(EntityPlayerMP player, int hash, int quantity) {
|
||||
public void onCraftingRequested(ServerPlayerEntity player, int hash, int quantity) {
|
||||
if (quantity <= 0 || !network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)) {
|
||||
return;
|
||||
}
|
||||
@@ -236,7 +232,7 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingCancelRequested(EntityPlayerMP player, @Nullable UUID id) {
|
||||
public void onCraftingCancelRequested(ServerPlayerEntity player, @Nullable UUID id) {
|
||||
if (!network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
@@ -28,7 +28,7 @@ public class ItemGridHandlerPortable implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExtract(EntityPlayerMP player, int hash, int flags) {
|
||||
public void onExtract(ServerPlayerEntity player, int hash, int flags) {
|
||||
if (portableGrid.getStorage() == null || !grid.isActive()) {
|
||||
return;
|
||||
}
|
||||
@@ -82,9 +82,9 @@ public class ItemGridHandlerPortable implements IItemGridHandler {
|
||||
|
||||
if (took != null) {
|
||||
if ((flags & EXTRACT_SHIFT) == EXTRACT_SHIFT) {
|
||||
IItemHandler playerInventory = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
|
||||
IItemHandler playerInventory = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, Direction.UP).orElse(null);
|
||||
|
||||
if (ItemHandlerHelper.insertItem(playerInventory, took, true).isEmpty()) {
|
||||
if (playerInventory != null && ItemHandlerHelper.insertItem(playerInventory, took, true).isEmpty()) {
|
||||
took = portableGrid.getItemStorage().extract(item, size, IComparer.COMPARE_DAMAGE | IComparer.COMPARE_NBT, Action.PERFORM);
|
||||
|
||||
ItemHandlerHelper.insertItem(playerInventory, took, false);
|
||||
@@ -107,7 +107,7 @@ public class ItemGridHandlerPortable implements IItemGridHandler {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ItemStack onInsert(EntityPlayerMP player, ItemStack stack) {
|
||||
public ItemStack onInsert(ServerPlayerEntity player, ItemStack stack) {
|
||||
if (portableGrid.getStorage() == null || !grid.isActive()) {
|
||||
return stack;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class ItemGridHandlerPortable implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInsertHeldItem(EntityPlayerMP player, boolean single) {
|
||||
public void onInsertHeldItem(ServerPlayerEntity player, boolean single) {
|
||||
if (player.inventory.getItemStack().isEmpty() || portableGrid.getStorage() == null || !grid.isActive()) {
|
||||
return;
|
||||
}
|
||||
@@ -152,22 +152,22 @@ public class ItemGridHandlerPortable implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onShiftClick(EntityPlayerMP player, ItemStack stack) {
|
||||
public ItemStack onShiftClick(ServerPlayerEntity player, ItemStack stack) {
|
||||
return StackUtils.nullToEmpty(onInsert(player, stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingPreviewRequested(EntityPlayerMP player, int hash, int quantity, boolean noPreview) {
|
||||
public void onCraftingPreviewRequested(ServerPlayerEntity player, int hash, int quantity, boolean noPreview) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingRequested(EntityPlayerMP player, int hash, int quantity) {
|
||||
public void onCraftingRequested(ServerPlayerEntity player, int hash, int quantity) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingCancelRequested(EntityPlayerMP player, @Nullable UUID id) {
|
||||
public void onCraftingCancelRequested(ServerPlayerEntity player, @Nullable UUID id) {
|
||||
// NO OP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import com.raoulvdberge.refinedstorage.api.network.item.INetworkItem;
|
||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -16,18 +16,18 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class NetworkItemHandler implements INetworkItemHandler {
|
||||
private INetwork network;
|
||||
|
||||
private Map<EntityPlayer, INetworkItem> items = new ConcurrentHashMap<>();
|
||||
private Map<PlayerEntity, INetworkItem> items = new ConcurrentHashMap<>();
|
||||
|
||||
public NetworkItemHandler(INetwork network) {
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(EntityPlayer player, ItemStack stack) {
|
||||
public void open(PlayerEntity player, ItemStack stack) {
|
||||
boolean inRange = false;
|
||||
|
||||
for (INetworkNode node : network.getNodeGraph().all()) {
|
||||
if (node instanceof IWirelessTransmitter && node.canUpdate() && ((IWirelessTransmitter) node).getDimension() == player.dimension) {
|
||||
if (node instanceof IWirelessTransmitter && node.canUpdate() && ((IWirelessTransmitter) node).getDimension() == player.dimension.getId()) { // TODO does that work?
|
||||
IWirelessTransmitter transmitter = (IWirelessTransmitter) node;
|
||||
|
||||
double distance = Math.sqrt(Math.pow(transmitter.getOrigin().getX() - player.posX, 2) + Math.pow(transmitter.getOrigin().getY() - player.posY, 2) + Math.pow(transmitter.getOrigin().getZ() - player.posZ, 2));
|
||||
@@ -41,7 +41,7 @@ public class NetworkItemHandler implements INetworkItemHandler {
|
||||
}
|
||||
|
||||
if (!inRange) {
|
||||
player.sendMessage(new TextComponentTranslation("misc.refinedstorage:network_item.out_of_range"));
|
||||
player.sendMessage(new TranslationTextComponent("misc.refinedstorage:network_item.out_of_range"));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -54,17 +54,17 @@ public class NetworkItemHandler implements INetworkItemHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(EntityPlayer player) {
|
||||
public void close(PlayerEntity player) {
|
||||
items.remove(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public INetworkItem getItem(EntityPlayer player) {
|
||||
public INetworkItem getItem(PlayerEntity player) {
|
||||
return items.get(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drainEnergy(EntityPlayer player, int energy) {
|
||||
public void drainEnergy(PlayerEntity player, int energy) {
|
||||
INetworkItem item = getItem(player);
|
||||
|
||||
if (item != null) {
|
||||
|
||||
@@ -8,18 +8,18 @@ import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemWirelessCraftingMonitor;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class NetworkItemWirelessCraftingMonitor implements INetworkItem {
|
||||
private INetworkItemHandler handler;
|
||||
private EntityPlayer player;
|
||||
private PlayerEntity player;
|
||||
private ItemStack stack;
|
||||
private int invIndex;
|
||||
|
||||
public NetworkItemWirelessCraftingMonitor(INetworkItemHandler handler, EntityPlayer player, ItemStack stack, int invIndex) {
|
||||
public NetworkItemWirelessCraftingMonitor(INetworkItemHandler handler, PlayerEntity player, ItemStack stack, int invIndex) {
|
||||
this.handler = handler;
|
||||
this.player = player;
|
||||
this.stack = stack;
|
||||
@@ -27,13 +27,15 @@ public class NetworkItemWirelessCraftingMonitor implements INetworkItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
public PlayerEntity getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOpen(INetwork network) {
|
||||
if (RS.INSTANCE.config.wirelessCraftingMonitorUsesEnergy && stack.getItemDamage() != ItemWirelessCraftingMonitor.TYPE_CREATIVE && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() <= RS.INSTANCE.config.wirelessCraftingMonitorOpenUsage) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||
|
||||
if (RS.INSTANCE.config.wirelessCraftingMonitorUsesEnergy /* TODO && stack.getItemDamage() != ItemWirelessCraftingMonitor.TYPE_CREATIVE */ && energy != null && energy.getEnergyStored() <= RS.INSTANCE.config.wirelessCraftingMonitorOpenUsage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,7 +45,7 @@ public class NetworkItemWirelessCraftingMonitor implements INetworkItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
player.openGui(RS.INSTANCE, RSGui.WIRELESS_CRAFTING_MONITOR, player.getEntityWorld(), invIndex, 0, 0);
|
||||
// TODO player.openGui(RS.INSTANCE, RSGui.WIRELESS_CRAFTING_MONITOR, player.getEntityWorld(), invIndex, 0, 0);
|
||||
|
||||
drainEnergy(RS.INSTANCE.config.wirelessCraftingMonitorOpenUsage);
|
||||
|
||||
@@ -52,16 +54,16 @@ public class NetworkItemWirelessCraftingMonitor implements INetworkItem {
|
||||
|
||||
@Override
|
||||
public void drainEnergy(int energy) {
|
||||
if (RS.INSTANCE.config.wirelessCraftingMonitorUsesEnergy && stack.getItemDamage() != ItemWirelessCraftingMonitor.TYPE_CREATIVE) {
|
||||
IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if (RS.INSTANCE.config.wirelessCraftingMonitorUsesEnergy /* TODO && stack.getItemDamage() != ItemWirelessCraftingMonitor.TYPE_CREATIVE*/) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY, null).ifPresent(energyStorage -> {
|
||||
energyStorage.extractEnergy(energy, false);
|
||||
|
||||
energyStorage.extractEnergy(energy, false);
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
handler.close(player);
|
||||
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
handler.close(player);
|
||||
|
||||
player.closeScreen();
|
||||
}
|
||||
player.closeScreen();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,34 +6,35 @@ import com.raoulvdberge.refinedstorage.api.network.item.INetworkItem;
|
||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemWirelessFluidGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.WirelessFluidGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class NetworkItemWirelessFluidGrid implements INetworkItem {
|
||||
private INetworkItemHandler handler;
|
||||
private EntityPlayer player;
|
||||
private PlayerEntity player;
|
||||
private ItemStack stack;
|
||||
|
||||
public NetworkItemWirelessFluidGrid(INetworkItemHandler handler, EntityPlayer player, ItemStack stack) {
|
||||
public NetworkItemWirelessFluidGrid(INetworkItemHandler handler, PlayerEntity player, ItemStack stack) {
|
||||
this.handler = handler;
|
||||
this.player = player;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
public PlayerEntity getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOpen(INetwork network) {
|
||||
if (RS.INSTANCE.config.wirelessFluidGridUsesEnergy && stack.getItemDamage() != ItemWirelessFluidGrid.TYPE_CREATIVE && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() <= RS.INSTANCE.config.wirelessFluidGridOpenUsage) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||
|
||||
if (RS.INSTANCE.config.wirelessFluidGridUsesEnergy /* TODO && stack.getItemDamage() != ItemWirelessFluidGrid.TYPE_CREATIVE*/ && energy != null && energy.getEnergyStored() <= RS.INSTANCE.config.wirelessFluidGridOpenUsage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ public class NetworkItemWirelessFluidGrid implements INetworkItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
API.instance().getGridManager().openGrid(WirelessFluidGrid.ID, (EntityPlayerMP) player, stack);
|
||||
API.instance().getGridManager().openGrid(WirelessFluidGrid.ID, (ServerPlayerEntity) player, stack);
|
||||
|
||||
drainEnergy(RS.INSTANCE.config.wirelessFluidGridOpenUsage);
|
||||
|
||||
@@ -52,16 +53,16 @@ public class NetworkItemWirelessFluidGrid implements INetworkItem {
|
||||
|
||||
@Override
|
||||
public void drainEnergy(int energy) {
|
||||
if (RS.INSTANCE.config.wirelessFluidGridUsesEnergy && stack.getItemDamage() != ItemWirelessFluidGrid.TYPE_CREATIVE) {
|
||||
IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if (RS.INSTANCE.config.wirelessFluidGridUsesEnergy /* TODO && stack.getItemDamage() != ItemWirelessFluidGrid.TYPE_CREATIVE*/) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY, null).ifPresent(energyStorage -> {
|
||||
energyStorage.extractEnergy(energy, false);
|
||||
|
||||
energyStorage.extractEnergy(energy, false);
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
handler.close(player);
|
||||
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
handler.close(player);
|
||||
|
||||
player.closeScreen();
|
||||
}
|
||||
player.closeScreen();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,34 +6,35 @@ import com.raoulvdberge.refinedstorage.api.network.item.INetworkItem;
|
||||
import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemHandler;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemWirelessGrid;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.WirelessGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
public class NetworkItemWirelessGrid implements INetworkItem {
|
||||
private INetworkItemHandler handler;
|
||||
private EntityPlayer player;
|
||||
private PlayerEntity player;
|
||||
private ItemStack stack;
|
||||
|
||||
public NetworkItemWirelessGrid(INetworkItemHandler handler, EntityPlayer player, ItemStack stack) {
|
||||
public NetworkItemWirelessGrid(INetworkItemHandler handler, PlayerEntity player, ItemStack stack) {
|
||||
this.handler = handler;
|
||||
this.player = player;
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer() {
|
||||
public PlayerEntity getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOpen(INetwork network) {
|
||||
if (RS.INSTANCE.config.wirelessGridUsesEnergy && stack.getItemDamage() != ItemWirelessGrid.TYPE_CREATIVE && stack.getCapability(CapabilityEnergy.ENERGY, null).getEnergyStored() <= RS.INSTANCE.config.wirelessGridOpenUsage) {
|
||||
IEnergyStorage energy = stack.getCapability(CapabilityEnergy.ENERGY, null).orElse(null);
|
||||
|
||||
if (RS.INSTANCE.config.wirelessGridUsesEnergy /* TODO && stack.getItemDamage() != ItemWirelessGrid.TYPE_CREATIVE */ && energy != null && energy.getEnergyStored() <= RS.INSTANCE.config.wirelessGridOpenUsage) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,7 +44,7 @@ public class NetworkItemWirelessGrid implements INetworkItem {
|
||||
return false;
|
||||
}
|
||||
|
||||
API.instance().getGridManager().openGrid(WirelessGrid.ID, (EntityPlayerMP) player, stack);
|
||||
API.instance().getGridManager().openGrid(WirelessGrid.ID, (ServerPlayerEntity) player, stack);
|
||||
|
||||
drainEnergy(RS.INSTANCE.config.wirelessGridOpenUsage);
|
||||
|
||||
@@ -52,16 +53,17 @@ public class NetworkItemWirelessGrid implements INetworkItem {
|
||||
|
||||
@Override
|
||||
public void drainEnergy(int energy) {
|
||||
if (RS.INSTANCE.config.wirelessGridUsesEnergy && stack.getItemDamage() != ItemWirelessGrid.TYPE_CREATIVE) {
|
||||
IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if (RS.INSTANCE.config.wirelessGridUsesEnergy /* TODO && stack.getItemDamage() != ItemWirelessGrid.TYPE_CREATIVE*/) {
|
||||
stack.getCapability(CapabilityEnergy.ENERGY, null).ifPresent(energyStorage -> {
|
||||
|
||||
energyStorage.extractEnergy(energy, false);
|
||||
energyStorage.extractEnergy(energy, false);
|
||||
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
handler.close(player);
|
||||
if (energyStorage.getEnergyStored() <= 0) {
|
||||
handler.close(player);
|
||||
|
||||
player.closeScreen();
|
||||
}
|
||||
player.closeScreen();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -160,27 +160,27 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
if (owner != null) {
|
||||
tag.setUniqueId(NBT_OWNER, owner);
|
||||
}
|
||||
|
||||
tag.setString(NBT_VERSION, RS.VERSION);
|
||||
|
||||
tag.setInteger(NBT_DIRECTION, direction.ordinal());
|
||||
tag.putInt(NBT_DIRECTION, direction.ordinal());
|
||||
|
||||
writeConfiguration(tag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
redstoneMode.write(tag);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
if (tag.hasUniqueId(NBT_OWNER)) {
|
||||
owner = tag.getUniqueId(NBT_OWNER);
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public abstract class NetworkNode implements INetworkNode, INetworkNodeVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
redstoneMode = RedstoneMode.read(tag);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.node;
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNodeCable;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -44,20 +44,20 @@ public class NetworkNodeCable extends NetworkNode implements ICoverable, INetwor
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||
tag.put(NBT_COVERS, coverManager.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasKey(NBT_COVERS)) {
|
||||
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTUtil;
|
||||
import net.minecraft.server.management.PlayerProfileCache;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -221,10 +221,10 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
GameProfile playerInfo = null;
|
||||
|
||||
if (item.hasTagCompound()) {
|
||||
NBTTagCompound tag = item.getTagCompound();
|
||||
CompoundNBT tag = item.getTagCompound();
|
||||
|
||||
if (tag.hasKey("SkullOwner", 10)) {
|
||||
playerInfo = NBTUtil.readGameProfileFromNBT(tag.getCompoundTag("SkullOwner"));
|
||||
playerInfo = NBTUtil.readGameProfileFromNBT(tag.getCompound("SkullOwner"));
|
||||
} else if (tag.hasKey("SkullOwner", 8) && !tag.getString("SkullOwner").isEmpty()) {
|
||||
playerInfo = new GameProfile(null, tag.getString("SkullOwner"));
|
||||
}
|
||||
@@ -287,7 +287,7 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(upgrades, 1, tag);
|
||||
@@ -299,33 +299,33 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(upgrades, 1, tag);
|
||||
|
||||
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||
tag.put(NBT_COVERS, coverManager.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.setBoolean(NBT_DROP, drop);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_TYPE, type);
|
||||
tag.putBoolean(NBT_DROP, drop);
|
||||
|
||||
StackUtils.writeItems(itemFilters, 0, tag);
|
||||
|
||||
tag.setTag(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.put(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_COMPARE)) {
|
||||
@@ -341,13 +341,13 @@ public class NetworkNodeConstructor extends NetworkNode implements IComparable,
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_COVERS)) {
|
||||
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
}
|
||||
|
||||
StackUtils.readItems(itemFilters, 0, tag);
|
||||
|
||||
if (tag.hasKey(NBT_FLUID_FILTERS)) {
|
||||
fluidFilters.readFromNbt(tag.getCompoundTag(NBT_FLUID_FILTERS));
|
||||
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorldNameable;
|
||||
@@ -172,7 +172,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
// Fix cascading crafter invalidates while reading patterns
|
||||
@@ -217,7 +217,7 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(patternsInventory, 0, tag);
|
||||
@@ -231,9 +231,9 @@ public class NetworkNodeCrafter extends NetworkNode implements ICraftingPatternC
|
||||
tag.setUniqueId(NBT_UUID, uuid);
|
||||
}
|
||||
|
||||
tag.setInteger(NBT_MODE, mode.ordinal());
|
||||
tag.setBoolean(NBT_LOCKED, locked);
|
||||
tag.setBoolean(NBT_WAS_POWERED, wasPowered);
|
||||
tag.putInt(NBT_MODE, mode.ordinal());
|
||||
tag.putBoolean(NBT_LOCKED, locked);
|
||||
tag.putBoolean(NBT_WAS_POWERED, wasPowered);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageCrafterManagerSlotSizes;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileCrafterManager;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class NetworkNodeCrafterManager extends NetworkNode {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public void sendTo(EntityPlayerMP player) {
|
||||
public void sendTo(ServerPlayerEntity player) {
|
||||
if (network != null) {
|
||||
RS.INSTANCE.network.sendTo(new MessageCrafterManagerSlotSizes(network.getCraftingManager().getNamedContainers()), player);
|
||||
}
|
||||
@@ -47,17 +47,17 @@ public class NetworkNodeCrafterManager extends NetworkNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setInteger(NBT_SIZE, size);
|
||||
tag.setInteger(NBT_SEARCH_BOX_MODE, searchBoxMode);
|
||||
tag.putInt(NBT_SIZE, size);
|
||||
tag.putInt(NBT_SEARCH_BOX_MODE, searchBoxMode);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_SIZE)) {
|
||||
|
||||
@@ -8,9 +8,9 @@ import com.raoulvdberge.refinedstorage.tile.craftingmonitor.ICraftingMonitor;
|
||||
import com.raoulvdberge.refinedstorage.tile.craftingmonitor.TileCraftingMonitor;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
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.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class NetworkNodeCraftingMonitor extends NetworkNode implements ICrafting
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancelled(EntityPlayerMP player, @Nullable UUID id) {
|
||||
public void onCancelled(ServerPlayerEntity player, @Nullable UUID id) {
|
||||
if (network != null) {
|
||||
network.getItemGridHandler().onCraftingCancelRequested(player, id);
|
||||
}
|
||||
@@ -76,10 +76,10 @@ public class NetworkNodeCraftingMonitor extends NetworkNode implements ICrafting
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setInteger(NBT_TAB_PAGE, tabPage);
|
||||
tag.putInt(NBT_TAB_PAGE, tabPage);
|
||||
|
||||
if (tabSelected.isPresent()) {
|
||||
tag.setUniqueId(NBT_TAB_SELECTED, tabSelected.get());
|
||||
@@ -89,7 +89,7 @@ public class NetworkNodeCraftingMonitor extends NetworkNode implements ICrafting
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasKey(NBT_TAB_PAGE)) {
|
||||
@@ -110,7 +110,7 @@ public class NetworkNodeCraftingMonitor extends NetworkNode implements ICrafting
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(EntityPlayer player) {
|
||||
public void onClosed(PlayerEntity player) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.management.PlayerProfileCache;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityShulkerBox;
|
||||
@@ -234,13 +234,13 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(upgrades, 1, tag);
|
||||
|
||||
if (tag.hasKey(NBT_COVERS)) {
|
||||
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,34 +250,34 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(upgrades, 1, tag);
|
||||
|
||||
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||
tag.put(NBT_COVERS, coverManager.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.setBoolean(NBT_PICKUP, pickupItem);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_MODE, mode);
|
||||
tag.putInt(NBT_TYPE, type);
|
||||
tag.putBoolean(NBT_PICKUP, pickupItem);
|
||||
|
||||
StackUtils.writeItems(itemFilters, 0, tag);
|
||||
|
||||
tag.setTag(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.put(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_COMPARE)) {
|
||||
@@ -299,7 +299,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
|
||||
StackUtils.readItems(itemFilters, 0, tag);
|
||||
|
||||
if (tag.hasKey(NBT_FLUID_FILTERS)) {
|
||||
fluidFilters.readFromNbt(tag.getCompoundTag(NBT_FLUID_FILTERS));
|
||||
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
|
||||
}
|
||||
|
||||
OneSixMigrationHelper.migrateEmptyWhitelistToEmptyBlacklist(version, this, itemFilters);
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -167,23 +167,23 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setInteger(NBT_AMOUNT, amount);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_MODE, mode);
|
||||
tag.putInt(NBT_AMOUNT, amount);
|
||||
tag.putInt(NBT_TYPE, type);
|
||||
|
||||
StackUtils.writeItems(itemFilters, 0, tag);
|
||||
|
||||
tag.setTag(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.put(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_COMPARE)) {
|
||||
@@ -205,7 +205,7 @@ public class NetworkNodeDetector extends NetworkNode implements IComparable, ITy
|
||||
StackUtils.readItems(itemFilters, 0, tag);
|
||||
|
||||
if (tag.hasKey(NBT_FLUID_FILTERS)) {
|
||||
fluidFilters.readFromNbt(tag.getCompoundTag(NBT_FLUID_FILTERS));
|
||||
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -171,43 +171,43 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(upgrades, 1, tag);
|
||||
|
||||
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||
tag.put(NBT_COVERS, coverManager.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_TYPE, type);
|
||||
|
||||
StackUtils.writeItems(itemFilters, 0, tag);
|
||||
|
||||
tag.setTag(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.put(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(upgrades, 1, tag);
|
||||
|
||||
if (tag.hasKey(NBT_COVERS)) {
|
||||
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_COMPARE)) {
|
||||
@@ -221,7 +221,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
|
||||
StackUtils.readItems(itemFilters, 0, tag);
|
||||
|
||||
if (tag.hasKey(NBT_FLUID_FILTERS)) {
|
||||
fluidFilters.readFromNbt(tag.getCompoundTag(NBT_FLUID_FILTERS));
|
||||
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -115,35 +115,35 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasKey(NBT_COVERS)) {
|
||||
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||
tag.put(NBT_COVERS, coverManager.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
StackUtils.writeItems(itemFilters, 0, tag);
|
||||
|
||||
tag.setTag(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.put(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
|
||||
tag.setInteger(NBT_PRIORITY, priority);
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.putInt(NBT_PRIORITY, priority);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_MODE, mode);
|
||||
tag.putInt(NBT_TYPE, type);
|
||||
|
||||
AccessTypeUtils.writeAccessType(tag, accessType);
|
||||
|
||||
@@ -151,13 +151,13 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
StackUtils.readItems(itemFilters, 0, tag);
|
||||
|
||||
if (tag.hasKey(NBT_FLUID_FILTERS)) {
|
||||
fluidFilters.readFromNbt(tag.getCompoundTag(NBT_FLUID_FILTERS));
|
||||
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_PRIORITY)) {
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -182,31 +182,31 @@ public class NetworkNodeFluidInterface extends NetworkNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(upgrades, 0, tag);
|
||||
StackUtils.writeItems(in, 1, tag);
|
||||
|
||||
tag.setTag(NBT_TANK_IN, tankIn.writeToNBT(new NBTTagCompound()));
|
||||
tag.setTag(NBT_TANK_OUT, tankOut.writeToNBT(new NBTTagCompound()));
|
||||
tag.put(NBT_TANK_IN, tankIn.writeToNBT(new CompoundNBT()));
|
||||
tag.put(NBT_TANK_OUT, tankOut.writeToNBT(new CompoundNBT()));
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(upgrades, 0, tag);
|
||||
StackUtils.readItems(in, 1, tag);
|
||||
|
||||
if (tag.hasKey(NBT_TANK_IN)) {
|
||||
tankIn.readFromNBT(tag.getCompoundTag(NBT_TANK_IN));
|
||||
tankIn.readFromNBT(tag.getCompound(NBT_TANK_IN));
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_TANK_OUT)) {
|
||||
tankOut.readFromNBT(tag.getCompoundTag(NBT_TANK_OUT));
|
||||
tankOut.readFromNBT(tag.getCompound(NBT_TANK_OUT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,20 +216,20 @@ public class NetworkNodeFluidInterface extends NetworkNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setTag(NBT_OUT, out.writeToNbt());
|
||||
tag.put(NBT_OUT, out.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_OUT)) {
|
||||
out.readFromNbt(tag.getCompoundTag(NBT_OUT));
|
||||
out.readFromNbt(tag.getCompound(NBT_OUT));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -72,7 +72,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
|
||||
private Container craftingContainer = new Container() {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
public boolean canInteractWith(PlayerEntity player) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public IStorageCacheListener createListener(EntityPlayerMP player) {
|
||||
public IStorageCacheListener createListener(ServerPlayerEntity player) {
|
||||
return getGridType() == GridType.FLUID ? new StorageCacheListenerGridFluid(player, network) : new StorageCacheListenerGridItem(player, network);
|
||||
}
|
||||
|
||||
@@ -337,11 +337,11 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipeTransfer(EntityPlayer player, ItemStack[][] recipe) {
|
||||
public void onRecipeTransfer(PlayerEntity player, ItemStack[][] recipe) {
|
||||
onRecipeTransfer(this, player, recipe);
|
||||
}
|
||||
|
||||
public static void onRecipeTransfer(IGridNetworkAware grid, EntityPlayer player, ItemStack[][] recipe) {
|
||||
public static void onRecipeTransfer(IGridNetworkAware grid, PlayerEntity player, ItemStack[][] recipe) {
|
||||
INetwork network = grid.getNetwork();
|
||||
|
||||
if (network != null && grid.getGridType() == GridType.CRAFTING && !network.getSecurityManager().hasPermission(Permission.EXTRACT, player)) {
|
||||
@@ -445,16 +445,16 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(EntityPlayer player) {
|
||||
public void onClosed(PlayerEntity player) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCrafted(EntityPlayer player) {
|
||||
public void onCrafted(PlayerEntity player) {
|
||||
onCrafted(this, world, player);
|
||||
}
|
||||
|
||||
public static void onCrafted(IGridNetworkAware grid, World world, EntityPlayer player) {
|
||||
public static void onCrafted(IGridNetworkAware grid, World world, PlayerEntity player) {
|
||||
NonNullList<ItemStack> remainder = CraftingManager.getRemainingItems(grid.getCraftingMatrix(), world);
|
||||
|
||||
INetwork network = grid.getNetwork();
|
||||
@@ -498,11 +498,11 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftedShift(EntityPlayer player) {
|
||||
public void onCraftedShift(PlayerEntity player) {
|
||||
onCraftedShift(this, player);
|
||||
}
|
||||
|
||||
public static void onCraftedShift(IGridNetworkAware grid, EntityPlayer player) {
|
||||
public static void onCraftedShift(IGridNetworkAware grid, PlayerEntity player) {
|
||||
List<ItemStack> craftedItemsList = new ArrayList<>();
|
||||
int craftedItems = 0;
|
||||
ItemStack crafted = grid.getCraftingResult().getStackInSlot(0);
|
||||
@@ -723,7 +723,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(matrix, 0, tag);
|
||||
@@ -732,7 +732,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
StackUtils.readItems(processingMatrix, 3, tag);
|
||||
|
||||
if (tag.hasKey(NBT_PROCESSING_MATRIX_FLUIDS)) {
|
||||
processingMatrixFluids.readFromNbt(tag.getCompoundTag(NBT_PROCESSING_MATRIX_FLUIDS));
|
||||
processingMatrixFluids.readFromNbt(tag.getCompound(NBT_PROCESSING_MATRIX_FLUIDS));
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_TAB_SELECTED)) {
|
||||
@@ -750,7 +750,7 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(matrix, 0, tag);
|
||||
@@ -758,32 +758,32 @@ public class NetworkNodeGrid extends NetworkNode implements IGridNetworkAware, I
|
||||
StackUtils.writeItems(filter, 2, tag);
|
||||
StackUtils.writeItems(processingMatrix, 3, tag);
|
||||
|
||||
tag.setTag(NBT_PROCESSING_MATRIX_FLUIDS, processingMatrixFluids.writeToNbt());
|
||||
tag.setInteger(NBT_TAB_SELECTED, tabSelected);
|
||||
tag.setInteger(NBT_TAB_PAGE, tabPage);
|
||||
tag.put(NBT_PROCESSING_MATRIX_FLUIDS, processingMatrixFluids.writeToNbt());
|
||||
tag.putInt(NBT_TAB_SELECTED, tabSelected);
|
||||
tag.putInt(NBT_TAB_PAGE, tabPage);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setInteger(NBT_VIEW_TYPE, viewType);
|
||||
tag.setInteger(NBT_SORTING_DIRECTION, sortingDirection);
|
||||
tag.setInteger(NBT_SORTING_TYPE, sortingType);
|
||||
tag.setInteger(NBT_SEARCH_BOX_MODE, searchBoxMode);
|
||||
tag.setInteger(NBT_SIZE, size);
|
||||
tag.putInt(NBT_VIEW_TYPE, viewType);
|
||||
tag.putInt(NBT_SORTING_DIRECTION, sortingDirection);
|
||||
tag.putInt(NBT_SORTING_TYPE, sortingType);
|
||||
tag.putInt(NBT_SEARCH_BOX_MODE, searchBoxMode);
|
||||
tag.putInt(NBT_SIZE, size);
|
||||
|
||||
tag.setBoolean(NBT_OREDICT_PATTERN, oredictPattern);
|
||||
tag.setBoolean(NBT_PROCESSING_PATTERN, processingPattern);
|
||||
tag.setInteger(NBT_PROCESSING_TYPE, processingType);
|
||||
tag.putBoolean(NBT_OREDICT_PATTERN, oredictPattern);
|
||||
tag.putBoolean(NBT_PROCESSING_PATTERN, processingPattern);
|
||||
tag.putInt(NBT_PROCESSING_TYPE, processingType);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_VIEW_TYPE)) {
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -154,13 +154,13 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(upgrades, 1, tag);
|
||||
|
||||
if (tag.hasKey(NBT_COVERS)) {
|
||||
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,33 +170,33 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(upgrades, 1, tag);
|
||||
|
||||
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||
tag.put(NBT_COVERS, coverManager.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_MODE, mode);
|
||||
tag.putInt(NBT_TYPE, type);
|
||||
|
||||
StackUtils.writeItems(itemFilters, 0, tag);
|
||||
|
||||
tag.setTag(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.put(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_COMPARE)) {
|
||||
@@ -214,7 +214,7 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
|
||||
StackUtils.readItems(itemFilters, 0, tag);
|
||||
|
||||
if (tag.hasKey(NBT_FLUID_FILTERS)) {
|
||||
fluidFilters.readFromNbt(tag.getCompoundTag(NBT_FLUID_FILTERS));
|
||||
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
|
||||
}
|
||||
|
||||
OneSixMigrationHelper.migrateEmptyWhitelistToEmptyBlacklist(version, this, itemFilters);
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -162,7 +162,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(importItems, 0, tag);
|
||||
@@ -176,7 +176,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(importItems, 0, tag);
|
||||
@@ -187,18 +187,18 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
StackUtils.writeItems(exportFilterItems, 1, tag);
|
||||
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
StackUtils.readItems(exportFilterItems, 1, tag);
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemNetworkCard;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
@@ -48,7 +48,7 @@ public class NetworkNodeNetworkTransmitter extends NetworkNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(networkCard, 0, tag);
|
||||
@@ -57,7 +57,7 @@ public class NetworkNodeNetworkTransmitter extends NetworkNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(networkCard, 0, tag);
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReader;
|
||||
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.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -68,7 +68,7 @@ public class NetworkNodeReader extends NetworkNode implements IReader, IGuiReade
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasKey(NBT_CHANNEL)) {
|
||||
@@ -76,7 +76,7 @@ public class NetworkNodeReader extends NetworkNode implements IReader, IGuiReade
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_COVERS)) {
|
||||
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ public class NetworkNodeReader extends NetworkNode implements IReader, IGuiReade
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setString(NBT_CHANNEL, channel);
|
||||
|
||||
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||
tag.put(NBT_COVERS, coverManager.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemSecurityCard;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
@@ -104,7 +104,7 @@ public class NetworkNodeSecurityManager extends NetworkNode implements ISecurity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(cardsInv, 0, tag);
|
||||
@@ -117,7 +117,7 @@ public class NetworkNodeSecurityManager extends NetworkNode implements ISecurity
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(cardsInv, 0, tag);
|
||||
|
||||
@@ -10,10 +10,10 @@ import com.raoulvdberge.refinedstorage.tile.config.IComparable;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.RedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -64,7 +64,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
|
||||
}
|
||||
}
|
||||
|
||||
public boolean depositAll(EntityPlayer player) {
|
||||
public boolean depositAll(PlayerEntity player) {
|
||||
if (network == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean deposit(EntityPlayer player, ItemStack toInsert) {
|
||||
public boolean deposit(PlayerEntity player, ItemStack toInsert) {
|
||||
if (network == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
|
||||
return true;
|
||||
}
|
||||
|
||||
public void extract(EntityPlayer player, EnumFacing side) {
|
||||
public void extract(PlayerEntity player, EnumFacing side) {
|
||||
if (network == null || getDirection() != side) {
|
||||
return;
|
||||
}
|
||||
@@ -164,10 +164,10 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
|
||||
StackUtils.writeItems(itemFilter, 0, tag);
|
||||
|
||||
@@ -175,7 +175,7 @@ public class NetworkNodeStorageMonitor extends NetworkNode implements IComparabl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_COMPARE)) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.inventory.listener.ListenerNetworkNode;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemUpgrade;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -30,7 +30,7 @@ public class NetworkNodeWirelessTransmitter extends NetworkNode implements IWire
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(upgrades, 0, tag);
|
||||
@@ -42,7 +42,7 @@ public class NetworkNodeWirelessTransmitter extends NetworkNode implements IWire
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(upgrades, 0, tag);
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.raoulvdberge.refinedstorage.api.network.readerwriter.IWriter;
|
||||
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.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -100,7 +100,7 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasKey(NBT_CHANNEL)) {
|
||||
@@ -108,7 +108,7 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_COVERS)) {
|
||||
coverManager.readFromNbt(tag.getTagList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
coverManager.readFromNbt(tag.getList(NBT_COVERS, Constants.NBT.TAG_COMPOUND));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,12 +118,12 @@ public class NetworkNodeWriter extends NetworkNode implements IWriter, IGuiReade
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setString(NBT_CHANNEL, channel);
|
||||
|
||||
tag.setTag(NBT_COVERS, coverManager.writeToNbt());
|
||||
tag.put(NBT_COVERS, coverManager.writeToNbt());
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import net.minecraft.block.BlockStainedGlass;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
@@ -90,15 +90,15 @@ public class CoverManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void readFromNbt(NBTTagList list) {
|
||||
public void readFromNbt(ListNBT list) {
|
||||
covers.clear();
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
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.getCompoundTag(NBT_ITEM));
|
||||
ItemStack item = new ItemStack(tag.getCompound(NBT_ITEM));
|
||||
int type = tag.hasKey(NBT_TYPE) ? tag.getInteger(NBT_TYPE) : 0;
|
||||
|
||||
if (type >= CoverType.values().length) {
|
||||
@@ -112,17 +112,17 @@ public class CoverManager {
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagList writeToNbt() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
public ListNBT writeToNbt() {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (Map.Entry<EnumFacing, Cover> entry : covers.entrySet()) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
tag.setInteger(NBT_DIRECTION, entry.getKey().ordinal());
|
||||
tag.setTag(NBT_ITEM, entry.getValue().getStack().serializeNBT());
|
||||
tag.setInteger(NBT_TYPE, entry.getValue().getType().ordinal());
|
||||
tag.putInt(NBT_DIRECTION, entry.getKey().ordinal());
|
||||
tag.put(NBT_ITEM, entry.getValue().getStack().serializeNBT());
|
||||
tag.putInt(NBT_TYPE, entry.getValue().getType().ordinal());
|
||||
|
||||
list.appendTag(tag);
|
||||
list.add(tag);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -172,7 +172,7 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(disks, 0, tag);
|
||||
@@ -188,7 +188,7 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(disks, 0, tag);
|
||||
@@ -197,16 +197,16 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
StackUtils.writeItems(itemFilters, 1, tag);
|
||||
|
||||
tag.setTag(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.setInteger(NBT_PRIORITY, priority);
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.put(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.putInt(NBT_PRIORITY, priority);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_MODE, mode);
|
||||
tag.putInt(NBT_TYPE, type);
|
||||
|
||||
AccessTypeUtils.writeAccessType(tag, accessType);
|
||||
|
||||
@@ -214,13 +214,13 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
StackUtils.readItems(itemFilters, 1, tag);
|
||||
|
||||
if (tag.hasKey(NBT_FLUID_FILTERS)) {
|
||||
fluidFilters.readFromNbt(tag.getCompoundTag(NBT_FLUID_FILTERS));
|
||||
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_PRIORITY)) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.render.constants.ConstantsDisk;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -90,7 +90,7 @@ public class StorageDiskFluidDriveWrapper implements IStorageDisk<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
public CompoundNBT writeToNbt() {
|
||||
return parent.writeToNbt();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.render.constants.ConstantsDisk;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -90,7 +90,7 @@ public class StorageDiskItemDriveWrapper implements IStorageDisk<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
public CompoundNBT writeToNbt() {
|
||||
return parent.writeToNbt();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IType;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
@@ -460,7 +460,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
StackUtils.readItems(upgrades, 3, tag);
|
||||
@@ -482,7 +482,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
StackUtils.writeItems(upgrades, 3, tag);
|
||||
@@ -493,28 +493,28 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
StackUtils.writeItems(itemFilters, 1, tag);
|
||||
|
||||
tag.setTag(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.setInteger(NBT_TYPE, type);
|
||||
tag.setInteger(NBT_IO_MODE, ioMode);
|
||||
tag.put(NBT_FLUID_FILTERS, fluidFilters.writeToNbt());
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_MODE, mode);
|
||||
tag.putInt(NBT_TYPE, type);
|
||||
tag.putInt(NBT_IO_MODE, ioMode);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
StackUtils.readItems(itemFilters, 1, tag);
|
||||
|
||||
if (tag.hasKey(NBT_FLUID_FILTERS)) {
|
||||
fluidFilters.readFromNbt(tag.getCompoundTag(NBT_FLUID_FILTERS));
|
||||
fluidFilters.readFromNbt(tag.getCompound(NBT_FLUID_FILTERS));
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_COMPARE)) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.raoulvdberge.refinedstorage.render.constants.ConstantsDisk;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -50,7 +50,7 @@ public class StorageDiskFluidManipulatorWrapper implements IStorageDisk<FluidSta
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
public CompoundNBT writeToNbt() {
|
||||
return parent.writeToNbt();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.raoulvdberge.refinedstorage.render.constants.ConstantsDisk;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -50,7 +50,7 @@ public class StorageDiskItemManipulatorWrapper implements IStorageDisk<ItemStack
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
public CompoundNBT writeToNbt() {
|
||||
return parent.writeToNbt();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import com.raoulvdberge.refinedstorage.tile.data.TileDataParameter;
|
||||
import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -92,7 +92,7 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setUniqueId(NBT_ID, storageId);
|
||||
@@ -101,7 +101,7 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasUniqueId(NBT_ID)) {
|
||||
@@ -139,13 +139,13 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setTag(NBT_FILTERS, filters.writeToNbt());
|
||||
tag.setInteger(NBT_PRIORITY, priority);
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.put(NBT_FILTERS, filters.writeToNbt());
|
||||
tag.putInt(NBT_PRIORITY, priority);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_MODE, mode);
|
||||
|
||||
AccessTypeUtils.writeAccessType(tag, accessType);
|
||||
|
||||
@@ -153,11 +153,11 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
if (tag.hasKey(NBT_FILTERS)) {
|
||||
filters.readFromNbt(tag.getCompoundTag(NBT_FILTERS));
|
||||
filters.readFromNbt(tag.getCompound(NBT_FILTERS));
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_PRIORITY)) {
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.raoulvdberge.refinedstorage.util.AccessTypeUtils;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
@@ -92,7 +92,7 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound write(NBTTagCompound tag) {
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
super.write(tag);
|
||||
|
||||
tag.setUniqueId(NBT_ID, storageId);
|
||||
@@ -101,7 +101,7 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound tag) {
|
||||
public void read(CompoundNBT tag) {
|
||||
super.read(tag);
|
||||
|
||||
if (tag.hasUniqueId(NBT_ID)) {
|
||||
@@ -139,14 +139,14 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeConfiguration(NBTTagCompound tag) {
|
||||
public CompoundNBT writeConfiguration(CompoundNBT tag) {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
StackUtils.writeItems(filters, 0, tag);
|
||||
|
||||
tag.setInteger(NBT_PRIORITY, priority);
|
||||
tag.setInteger(NBT_COMPARE, compare);
|
||||
tag.setInteger(NBT_MODE, mode);
|
||||
tag.putInt(NBT_PRIORITY, priority);
|
||||
tag.putInt(NBT_COMPARE, compare);
|
||||
tag.putInt(NBT_MODE, mode);
|
||||
|
||||
AccessTypeUtils.writeAccessType(tag, accessType);
|
||||
|
||||
@@ -154,7 +154,7 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readConfiguration(NBTTagCompound tag) {
|
||||
public void readConfiguration(CompoundNBT tag) {
|
||||
super.readConfiguration(tag);
|
||||
|
||||
StackUtils.readItems(filters, 0, tag);
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskListener;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -76,7 +76,7 @@ public class StorageDiskFluidStorageWrapper implements IStorageDisk<FluidStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
public CompoundNBT writeToNbt() {
|
||||
return parent.writeToNbt();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskListener;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -76,7 +76,7 @@ public class StorageDiskItemStorageWrapper implements IStorageDisk<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
public CompoundNBT writeToNbt() {
|
||||
return parent.writeToNbt();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetwork;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.*;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -45,24 +45,24 @@ public class ReaderWriterChannel implements IReaderWriterChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt(NBTTagCompound tag) {
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
for (IReaderWriterHandler handler : handlers) {
|
||||
tag.setTag(String.format(NBT_HANDLER, handler.getId()), handler.writeToNbt(new NBTTagCompound()));
|
||||
tag.put(String.format(NBT_HANDLER, handler.getId()), handler.writeToNbt(new CompoundNBT()));
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNbt(NBTTagCompound tag) {
|
||||
public void readFromNbt(CompoundNBT tag) {
|
||||
for (IReaderWriterHandler handler : handlers) {
|
||||
String id = String.format(NBT_HANDLER, handler.getId());
|
||||
|
||||
if (tag.hasKey(id)) {
|
||||
if (tag.contains(id)) {
|
||||
IReaderWriterHandlerFactory factory = API.instance().getReaderWriterHandlerRegistry().get(id);
|
||||
|
||||
if (factory != null) {
|
||||
handlers.add(factory.create(tag.getCompoundTag(id)));
|
||||
handlers.add(factory.create(tag.getCompound(id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter;
|
||||
|
||||
/* TODO
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReader;
|
||||
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.apiimpl.API;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
@@ -49,7 +49,7 @@ public class ReaderWriterHandlerFluids implements IReaderWriterHandler {
|
||||
private FluidTank tank;
|
||||
private FluidTankReaderWriter tankReader, tankWriter;
|
||||
|
||||
public ReaderWriterHandlerFluids(@Nullable NBTTagCompound tag) {
|
||||
public ReaderWriterHandlerFluids(@Nullable CompoundNBT tag) {
|
||||
this.tank = new FluidTank(16 * Fluid.BUCKET_VOLUME);
|
||||
this.tankReader = new FluidTankReaderWriter(tank, true, false);
|
||||
this.tankWriter = new FluidTankReaderWriter(tank, false, true);
|
||||
@@ -103,7 +103,7 @@ public class ReaderWriterHandlerFluids implements IReaderWriterHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt(NBTTagCompound tag) {
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
tank.writeToNBT(tag);
|
||||
|
||||
return tag;
|
||||
@@ -224,4 +224,4 @@ public class ReaderWriterHandlerFluids implements IReaderWriterHandler {
|
||||
return canDrain ? parent.drain(maxDrain, doDrain) : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.readerwriter;
|
||||
|
||||
/* TODO
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReader;
|
||||
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.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
@@ -51,12 +51,17 @@ public class ReaderWriterHandlerItems implements IReaderWriterHandler {
|
||||
public int getSlotLimit(int slot) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private ItemStackHandler items;
|
||||
private ItemHandlerReaderWriter itemsReader, itemsWriter;
|
||||
|
||||
public ReaderWriterHandlerItems(@Nullable NBTTagCompound tag) {
|
||||
public ReaderWriterHandlerItems(@Nullable CompoundNBT tag) {
|
||||
this.items = new ItemStackHandler(16);
|
||||
this.itemsWriter = new ItemHandlerReaderWriter(items, false, true);
|
||||
this.itemsReader = new ItemHandlerReaderWriter(items, true, false);
|
||||
@@ -98,7 +103,7 @@ public class ReaderWriterHandlerItems implements IReaderWriterHandler {
|
||||
@Override
|
||||
public <T> T getCapabilityWriter(IWriter writer, Capability<T> capability) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(itemsWriter);
|
||||
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.(itemsWriter);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -110,7 +115,7 @@ public class ReaderWriterHandlerItems implements IReaderWriterHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt(NBTTagCompound tag) {
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
StackUtils.writeItems(items, 0, tag);
|
||||
|
||||
return tag;
|
||||
@@ -184,3 +189,4 @@ public class ReaderWriterHandlerItems implements IReaderWriterHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -4,9 +4,9 @@ import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReader;
|
||||
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 net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -65,7 +65,7 @@ public class ReaderWriterHandlerRedstone implements IReaderWriterHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt(NBTTagCompound tag) {
|
||||
public CompoundNBT writeToNbt(CompoundNBT tag) {
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,6 @@ public class ReaderWriterHandlerRedstone implements IReaderWriterHandler {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
return Collections.singletonList(new TextComponentTranslation("misc.refinedstorage:reader_writer.redstone", strength));
|
||||
return Collections.singletonList(new TranslationTextComponent("misc.refinedstorage:reader_writer.redstone", strength));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterHan
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterListener;
|
||||
import com.raoulvdberge.refinedstorage.api.network.readerwriter.IReaderWriterManager;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -79,27 +79,27 @@ public class ReaderWriterManager implements IReaderWriterManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNbt(NBTTagCompound tag) {
|
||||
NBTTagList readerWriterChannelsList = new NBTTagList();
|
||||
public void writeToNbt(CompoundNBT tag) {
|
||||
ListNBT readerWriterChannelsList = new ListNBT();
|
||||
|
||||
for (Map.Entry<String, IReaderWriterChannel> entry : channels.entrySet()) {
|
||||
NBTTagCompound channelTag = entry.getValue().writeToNbt(new NBTTagCompound());
|
||||
CompoundNBT channelTag = entry.getValue().writeToNbt(new CompoundNBT());
|
||||
|
||||
channelTag.setString(NBT_NAME, entry.getKey());
|
||||
channelTag.putString(NBT_NAME, entry.getKey());
|
||||
|
||||
readerWriterChannelsList.appendTag(channelTag);
|
||||
readerWriterChannelsList.add(channelTag);
|
||||
}
|
||||
|
||||
tag.setTag(NBT_CHANNELS, readerWriterChannelsList);
|
||||
tag.put(NBT_CHANNELS, readerWriterChannelsList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNbt(NBTTagCompound tag) {
|
||||
if (tag.hasKey(NBT_CHANNELS)) {
|
||||
NBTTagList readerWriterChannelsList = tag.getTagList(NBT_CHANNELS, Constants.NBT.TAG_COMPOUND);
|
||||
public void readFromNbt(CompoundNBT tag) {
|
||||
if (tag.contains(NBT_CHANNELS)) {
|
||||
ListNBT readerWriterChannelsList = tag.getList(NBT_CHANNELS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < readerWriterChannelsList.tagCount(); ++i) {
|
||||
NBTTagCompound channelTag = readerWriterChannelsList.getCompoundTagAt(i);
|
||||
for (int i = 0; i < readerWriterChannelsList.size(); ++i) {
|
||||
CompoundNBT channelTag = readerWriterChannelsList.getCompound(i);
|
||||
|
||||
String name = channelTag.getString(NBT_NAME);
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@ import com.raoulvdberge.refinedstorage.api.network.security.ISecurityCard;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.ISecurityCardContainer;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.ISecurityManager;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.management.UserListOps;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.management.OpList;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -24,8 +23,8 @@ public class SecurityManager implements ISecurityManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission permission, EntityPlayer player) {
|
||||
UserListOps ops = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getOppedPlayers();
|
||||
public boolean hasPermission(Permission permission, PlayerEntity player) {
|
||||
OpList ops = player.getServer().getPlayerList().getOppedPlayers(); // TODO does that work?
|
||||
|
||||
if (ops.getEntry(player.getGameProfile()) != null) {
|
||||
return true;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class StorageCacheFluid implements IStorageCache<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void invalidate() {
|
||||
public void invalidate() {
|
||||
storages.clear();
|
||||
|
||||
network.getNodeGraph().all().stream()
|
||||
@@ -45,7 +45,7 @@ public class StorageCacheFluid implements IStorageCache<FluidStack> {
|
||||
}
|
||||
|
||||
for (FluidStack stack : storage.getStacks()) {
|
||||
add(stack, stack.amount, true, false);
|
||||
add(stack, stack.getAmount(), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class StorageCacheFluid implements IStorageCache<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void add(@Nonnull FluidStack stack, int size, boolean rebuilding, boolean batched) {
|
||||
public void add(@Nonnull FluidStack stack, int size, boolean rebuilding, boolean batched) {
|
||||
list.add(stack, size);
|
||||
|
||||
if (!rebuilding) {
|
||||
@@ -66,7 +66,7 @@ public class StorageCacheFluid implements IStorageCache<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void remove(@Nonnull FluidStack stack, int size, boolean batched) {
|
||||
public void remove(@Nonnull FluidStack stack, int size, boolean batched) {
|
||||
if (list.remove(stack, size)) {
|
||||
if (!batched) {
|
||||
listeners.forEach(l -> l.onChanged(stack, -size));
|
||||
@@ -77,7 +77,7 @@ public class StorageCacheFluid implements IStorageCache<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void flush() {
|
||||
public void flush() {
|
||||
if (!batchedChanges.isEmpty()) {
|
||||
batchedChanges.forEach(c -> listeners.forEach(l -> l.onChanged(c.getKey(), c.getValue())));
|
||||
batchedChanges.clear();
|
||||
|
||||
@@ -28,7 +28,7 @@ public class StorageCacheItem implements IStorageCache<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void invalidate() {
|
||||
public void invalidate() {
|
||||
storages.clear();
|
||||
|
||||
network.getNodeGraph().all().stream()
|
||||
@@ -55,7 +55,7 @@ public class StorageCacheItem implements IStorageCache<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void add(@Nonnull ItemStack stack, int size, boolean rebuilding, boolean batched) {
|
||||
public void add(@Nonnull ItemStack stack, int size, boolean rebuilding, boolean batched) {
|
||||
list.add(stack, size);
|
||||
|
||||
if (!rebuilding) {
|
||||
@@ -68,7 +68,7 @@ public class StorageCacheItem implements IStorageCache<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void remove(@Nonnull ItemStack stack, int size, boolean batched) {
|
||||
public void remove(@Nonnull ItemStack stack, int size, boolean batched) {
|
||||
if (list.remove(stack, size)) {
|
||||
if (!batched) {
|
||||
listeners.forEach(l -> l.onChanged(stack, -size));
|
||||
@@ -79,7 +79,7 @@ public class StorageCacheItem implements IStorageCache<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void flush() {
|
||||
public void flush() {
|
||||
if (!batchedChanges.isEmpty()) {
|
||||
if (batchedChanges.size() > 1) {
|
||||
listeners.forEach(l -> l.onChangedBulk(batchedChanges));
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridFluidDelta;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridFluidUpdate;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -14,17 +14,17 @@ import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class StorageCacheListenerGridFluid implements IStorageCacheListener<FluidStack> {
|
||||
private EntityPlayerMP player;
|
||||
private ServerPlayerEntity player;
|
||||
private INetwork network;
|
||||
|
||||
public StorageCacheListenerGridFluid(EntityPlayerMP player, INetwork network) {
|
||||
public StorageCacheListenerGridFluid(ServerPlayerEntity player, INetwork network) {
|
||||
this.player = player;
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached() {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridFluidUpdate(network, network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)), player);
|
||||
// TODO: RS.INSTANCE.network.sendTo(new MessageGridFluidUpdate(network, network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,7 +34,7 @@ public class StorageCacheListenerGridFluid implements IStorageCacheListener<Flui
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nonnull FluidStack stack, int size) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridFluidDelta(network, network.getFluidStorageTracker(), stack, size), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridFluidDelta(network, network.getFluidStorageTracker(), stack, size), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCacheListener;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridItemDelta;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridItemUpdate;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -14,17 +14,17 @@ import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class StorageCacheListenerGridItem implements IStorageCacheListener<ItemStack> {
|
||||
private EntityPlayerMP player;
|
||||
private ServerPlayerEntity player;
|
||||
private INetwork network;
|
||||
|
||||
public StorageCacheListenerGridItem(EntityPlayerMP player, INetwork network) {
|
||||
public StorageCacheListenerGridItem(ServerPlayerEntity player, INetwork network) {
|
||||
this.player = player;
|
||||
this.network = network;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached() {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridItemUpdate(network, network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridItemUpdate(network, network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,11 +34,11 @@ public class StorageCacheListenerGridItem implements IStorageCacheListener<ItemS
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nonnull ItemStack stack, int size) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridItemDelta(network, network.getItemStorageTracker(), stack, size), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridItemDelta(network, network.getItemStorageTracker(), stack, size), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangedBulk(@Nonnull List<Pair<ItemStack, Integer>> stacks) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridItemDelta(network, network.getItemStorageTracker(), stacks), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridItemDelta(network, network.getItemStorageTracker(), stacks), player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.raoulvdberge.refinedstorage.network.MessageGridItemDelta;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridItemUpdate;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -17,16 +17,16 @@ import java.util.List;
|
||||
|
||||
public class StorageCacheListenerGridPortable implements IStorageCacheListener<ItemStack> {
|
||||
private IPortableGrid portableGrid;
|
||||
private EntityPlayerMP player;
|
||||
private ServerPlayerEntity player;
|
||||
|
||||
public StorageCacheListenerGridPortable(IPortableGrid portableGrid, EntityPlayerMP player) {
|
||||
public StorageCacheListenerGridPortable(IPortableGrid portableGrid, ServerPlayerEntity player) {
|
||||
this.portableGrid = portableGrid;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached() {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridItemUpdate(buf -> {
|
||||
/*RS.INSTANCE.network.sendTo(new MessageGridItemUpdate(buf -> {
|
||||
buf.writeInt(portableGrid.getItemCache().getList().getStacks().size());
|
||||
|
||||
for (ItemStack stack : portableGrid.getItemCache().getList().getStacks()) {
|
||||
@@ -39,7 +39,7 @@ public class StorageCacheListenerGridPortable implements IStorageCacheListener<I
|
||||
ByteBufUtils.writeUTF8String(buf, entry.getName());
|
||||
}
|
||||
}
|
||||
}, false), player);
|
||||
}, false), player); TODO */
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,11 +49,11 @@ public class StorageCacheListenerGridPortable implements IStorageCacheListener<I
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nonnull ItemStack stack, int size) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridItemDelta(null, portableGrid.getItemStorageTracker(), stack, size), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridItemDelta(null, portableGrid.getItemStorageTracker(), stack, size), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangedBulk(@Nonnull List<Pair<ItemStack, Integer>> stacks) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridItemDelta(null, portableGrid.getItemStorageTracker(), stacks), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridItemDelta(null, portableGrid.getItemStorageTracker(), stacks), player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.raoulvdberge.refinedstorage.network.MessageGridFluidDelta;
|
||||
import com.raoulvdberge.refinedstorage.network.MessageGridFluidUpdate;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -17,16 +17,16 @@ import java.util.List;
|
||||
|
||||
public class StorageCacheListenerGridPortableFluid implements IStorageCacheListener<FluidStack> {
|
||||
private IPortableGrid portableGrid;
|
||||
private EntityPlayerMP player;
|
||||
private ServerPlayerEntity player;
|
||||
|
||||
public StorageCacheListenerGridPortableFluid(IPortableGrid portableGrid, EntityPlayerMP player) {
|
||||
public StorageCacheListenerGridPortableFluid(IPortableGrid portableGrid, ServerPlayerEntity player) {
|
||||
this.portableGrid = portableGrid;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttached() {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridFluidUpdate(buf -> {
|
||||
/*RS.INSTANCE.network.sendTo(new MessageGridFluidUpdate(buf -> {
|
||||
int size = portableGrid.getFluidCache().getList().getStacks().size();
|
||||
|
||||
buf.writeInt(size);
|
||||
@@ -44,7 +44,7 @@ public class StorageCacheListenerGridPortableFluid implements IStorageCacheListe
|
||||
buf.writeBoolean(false);
|
||||
buf.writeBoolean(false);
|
||||
}
|
||||
}, false), player);
|
||||
}, false), player); TODO */
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +54,7 @@ public class StorageCacheListenerGridPortableFluid implements IStorageCacheListe
|
||||
|
||||
@Override
|
||||
public void onChanged(@Nonnull FluidStack stack, int size) {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridFluidDelta(null, portableGrid.getFluidStorageTracker(), stack, size), player);
|
||||
// TODO RS.INSTANCE.network.sendTo(new MessageGridFluidDelta(null, portableGrid.getFluidStorageTracker(), stack, size), player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
|
||||
public class StorageTrackerEntry implements IStorageTracker.IStorageTrackerEntry {
|
||||
@@ -13,9 +14,9 @@ public class StorageTrackerEntry implements IStorageTracker.IStorageTrackerEntry
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public StorageTrackerEntry(ByteBuf buf) {
|
||||
public StorageTrackerEntry(PacketBuffer buf) {
|
||||
this.time = buf.readLong();
|
||||
this.name = ByteBufUtils.readUTF8String(buf);
|
||||
this.name = buf.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import gnu.trove.map.hash.TCustomHashMap;
|
||||
import gnu.trove.strategy.HashingStrategy;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class StorageTrackerFluid implements IStorageTracker<FluidStack> {
|
||||
@@ -18,6 +14,8 @@ public class StorageTrackerFluid implements IStorageTracker<FluidStack> {
|
||||
private static final String NBT_NAME = "Name";
|
||||
private static final String NBT_TIME = "Time";
|
||||
|
||||
private Map<FluidStack, IStorageTrackerEntry> changes = new HashMap<>(); // TODO broken
|
||||
/*
|
||||
private Map<FluidStack, IStorageTrackerEntry> changes = new TCustomHashMap<>(new HashingStrategy<FluidStack>() {
|
||||
@Override
|
||||
public int computeHashCode(FluidStack stack) {
|
||||
@@ -28,7 +26,7 @@ public class StorageTrackerFluid implements IStorageTracker<FluidStack> {
|
||||
public boolean equals(FluidStack left, FluidStack right) {
|
||||
return API.instance().getComparer().isEqual(left, right, IComparer.COMPARE_NBT);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
private Runnable listener;
|
||||
|
||||
@@ -37,8 +35,8 @@ public class StorageTrackerFluid implements IStorageTracker<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(EntityPlayer player, FluidStack stack) {
|
||||
changes.put(stack, new StorageTrackerEntry(MinecraftServer.getCurrentTimeMillis(), player.getName()));
|
||||
public void changed(PlayerEntity player, FluidStack stack) {
|
||||
changes.put(stack, new StorageTrackerEntry(System.currentTimeMillis(), player.getName().getString())); // TODO: correct?
|
||||
|
||||
listener.run();
|
||||
}
|
||||
@@ -48,11 +46,11 @@ public class StorageTrackerFluid implements IStorageTracker<FluidStack> {
|
||||
return changes.get(stack);
|
||||
}
|
||||
|
||||
public void readFromNbt(NBTTagList list) {
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
public void readFromNbt(ListNBT list) {
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
CompoundNBT tag = list.getCompound(i);
|
||||
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag(NBT_STACK));
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(tag.getCompound(NBT_STACK));
|
||||
|
||||
if (stack != null) {
|
||||
changes.put(
|
||||
@@ -63,17 +61,17 @@ public class StorageTrackerFluid implements IStorageTracker<FluidStack> {
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagList serializeNbt() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
public ListNBT serializeNbt() {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (Map.Entry<FluidStack, IStorageTrackerEntry> entry : changes.entrySet()) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
tag.setLong(NBT_TIME, entry.getValue().getTime());
|
||||
tag.setString(NBT_NAME, entry.getValue().getName());
|
||||
tag.setTag(NBT_STACK, entry.getKey().writeToNBT(new NBTTagCompound()));
|
||||
tag.putLong(NBT_TIME, entry.getValue().getTime());
|
||||
tag.putString(NBT_NAME, entry.getValue().getName());
|
||||
tag.put(NBT_STACK, entry.getKey().writeToNBT(new CompoundNBT()));
|
||||
|
||||
list.appendTag(tag);
|
||||
list.add(tag);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.storage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageTracker;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import gnu.trove.map.hash.TCustomHashMap;
|
||||
import gnu.trove.strategy.HashingStrategy;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class StorageTrackerItem implements IStorageTracker<ItemStack> {
|
||||
@@ -18,7 +15,8 @@ public class StorageTrackerItem implements IStorageTracker<ItemStack> {
|
||||
private static final String NBT_NAME = "Name";
|
||||
private static final String NBT_TIME = "Time";
|
||||
|
||||
private Map<ItemStack, IStorageTrackerEntry> changes = new TCustomHashMap<>(new HashingStrategy<ItemStack>() {
|
||||
|
||||
private Map<ItemStack, IStorageTrackerEntry> changes = new HashMap<>(); /* TODO BROKEN new TCustomHashMap<>(new HashingStrategy<ItemStack>() {
|
||||
@Override
|
||||
public int computeHashCode(ItemStack stack) {
|
||||
return API.instance().getItemStackHashCode(stack);
|
||||
@@ -28,7 +26,7 @@ public class StorageTrackerItem implements IStorageTracker<ItemStack> {
|
||||
public boolean equals(ItemStack left, ItemStack right) {
|
||||
return API.instance().getComparer().isEqualNoQuantity(left, right);
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
private Runnable listener;
|
||||
|
||||
@@ -37,8 +35,8 @@ public class StorageTrackerItem implements IStorageTracker<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(EntityPlayer player, ItemStack stack) {
|
||||
changes.put(stack, new StorageTrackerEntry(MinecraftServer.getCurrentTimeMillis(), player.getName()));
|
||||
public void changed(PlayerEntity player, ItemStack stack) {
|
||||
changes.put(stack, new StorageTrackerEntry(System.currentTimeMillis(), player.getName().getString())); // TODO correct?
|
||||
|
||||
listener.run();
|
||||
}
|
||||
@@ -48,11 +46,11 @@ public class StorageTrackerItem implements IStorageTracker<ItemStack> {
|
||||
return changes.get(stack);
|
||||
}
|
||||
|
||||
public void readFromNbt(NBTTagList list) {
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
public void readFromNbt(ListNBT list) {
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
CompoundNBT tag = list.getCompound(i);
|
||||
|
||||
ItemStack stack = StackUtils.deserializeStackFromNbt(tag.getCompoundTag(NBT_STACK));
|
||||
ItemStack stack = StackUtils.deserializeStackFromNbt(tag.getCompound(NBT_STACK));
|
||||
|
||||
if (!stack.isEmpty()) {
|
||||
changes.put(
|
||||
@@ -63,17 +61,17 @@ public class StorageTrackerItem implements IStorageTracker<ItemStack> {
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagList serializeNbt() {
|
||||
NBTTagList list = new NBTTagList();
|
||||
public ListNBT serializeNbt() {
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (Map.Entry<ItemStack, IStorageTrackerEntry> entry : changes.entrySet()) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
tag.setLong(NBT_TIME, entry.getValue().getTime());
|
||||
tag.setString(NBT_NAME, entry.getValue().getName());
|
||||
tag.setTag(NBT_STACK, StackUtils.serializeStackToNbt(entry.getKey()));
|
||||
tag.putLong(NBT_TIME, entry.getValue().getTime());
|
||||
tag.putString(NBT_NAME, entry.getValue().getName());
|
||||
tag.put(NBT_STACK, StackUtils.serializeStackToNbt(entry.getKey()));
|
||||
|
||||
list.appendTag(tag);
|
||||
list.add(tag);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
@@ -2,25 +2,26 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage.disk;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskFactory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class StorageDiskFactoryFluid implements IStorageDiskFactory<FluidStack> {
|
||||
public static final String ID = "normal_fluid";
|
||||
|
||||
@Override
|
||||
public IStorageDisk<FluidStack> createFromNbt(World world, NBTTagCompound tag) {
|
||||
StorageDiskFluid disk = new StorageDiskFluid(world, tag.getInteger(StorageDiskFluid.NBT_CAPACITY));
|
||||
public IStorageDisk<FluidStack> createFromNbt(World world, CompoundNBT tag) {
|
||||
StorageDiskFluid disk = new StorageDiskFluid(world, tag.getInt(StorageDiskFluid.NBT_CAPACITY));
|
||||
|
||||
NBTTagList list = (NBTTagList) tag.getTag(StorageDiskFluid.NBT_FLUIDS);
|
||||
ListNBT list = tag.getList(StorageDiskFluid.NBT_FLUIDS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompoundTagAt(i));
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompound(i));
|
||||
|
||||
if (stack != null) {
|
||||
disk.getRawStacks().put(stack.getFluid(), stack);
|
||||
disk.getRawStacks().put(stack.getRawFluid(), stack);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,21 +4,22 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskFactory;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
public class StorageDiskFactoryItem implements IStorageDiskFactory<ItemStack> {
|
||||
public static final String ID = "normal_item";
|
||||
|
||||
@Override
|
||||
public IStorageDisk<ItemStack> createFromNbt(World world, NBTTagCompound tag) {
|
||||
StorageDiskItem disk = new StorageDiskItem(world, tag.getInteger(StorageDiskItem.NBT_CAPACITY));
|
||||
public IStorageDisk<ItemStack> createFromNbt(World world, CompoundNBT tag) {
|
||||
StorageDiskItem disk = new StorageDiskItem(world, tag.getInt(StorageDiskItem.NBT_CAPACITY));
|
||||
|
||||
NBTTagList list = (NBTTagList) tag.getTag(StorageDiskItem.NBT_ITEMS);
|
||||
ListNBT list = tag.getList(StorageDiskItem.NBT_ITEMS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
ItemStack stack = StackUtils.deserializeStackFromNbt(list.getCompoundTagAt(i));
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
ItemStack stack = StackUtils.deserializeStackFromNbt(list.getCompound(i));
|
||||
|
||||
if (!stack.isEmpty()) {
|
||||
disk.getRawStacks().put(stack.getItem(), stack);
|
||||
|
||||
@@ -10,10 +10,10 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskListener;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -43,18 +43,18 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (FluidStack stack : stacks.values()) {
|
||||
list.appendTag(stack.writeToNBT(new NBTTagCompound()));
|
||||
list.add(stack.writeToNBT(new CompoundNBT()));
|
||||
}
|
||||
|
||||
tag.setString(NBT_VERSION, RS.VERSION);
|
||||
tag.setTag(NBT_FLUIDS, list);
|
||||
tag.setInteger(NBT_CAPACITY, capacity);
|
||||
tag.putString(NBT_VERSION, RS.VERSION);
|
||||
tag.put(NBT_FLUIDS, list);
|
||||
tag.putInt(NBT_CAPACITY, capacity);
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
}
|
||||
|
||||
if (action == Action.PERFORM) {
|
||||
otherStack.amount += remainingSpace;
|
||||
otherStack.grow(remainingSpace);
|
||||
|
||||
onChanged();
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
return StackUtils.copy(otherStack, size - remainingSpace);
|
||||
} else {
|
||||
if (action == Action.PERFORM) {
|
||||
otherStack.amount += size;
|
||||
otherStack.grow(size);
|
||||
|
||||
onChanged();
|
||||
}
|
||||
@@ -125,15 +125,15 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
public FluidStack extract(@Nonnull FluidStack stack, int size, int flags, Action action) {
|
||||
for (FluidStack otherStack : stacks.get(stack.getFluid())) {
|
||||
if (API.instance().getComparer().isEqual(otherStack, stack, flags)) {
|
||||
if (size > otherStack.amount) {
|
||||
size = otherStack.amount;
|
||||
if (size > otherStack.getAmount()) {
|
||||
size = otherStack.getAmount();
|
||||
}
|
||||
|
||||
if (action == Action.PERFORM) {
|
||||
if (otherStack.amount - size == 0) {
|
||||
if (otherStack.getAmount() - size == 0) {
|
||||
stacks.remove(otherStack.getFluid(), otherStack);
|
||||
} else {
|
||||
otherStack.amount -= size;
|
||||
otherStack.shrink(size);
|
||||
}
|
||||
|
||||
onChanged();
|
||||
@@ -148,7 +148,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
|
||||
@Override
|
||||
public int getStored() {
|
||||
return stacks.values().stream().mapToInt(s -> s.amount).sum();
|
||||
return stacks.values().stream().mapToInt(s -> s.getAmount()).sum();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -172,7 +172,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return remainder == null ? size : (size - remainder.amount);
|
||||
return remainder == null ? size : (size - remainder.getAmount());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskContainerCon
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskListener;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -33,7 +33,7 @@ public class StorageDiskFluidPortable implements IStorageDisk<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
public CompoundNBT writeToNbt() {
|
||||
return parent.writeToNbt();
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class StorageDiskFluidPortable implements IStorageDisk<FluidStack> {
|
||||
FluidStack extracted = parent.extract(stack, size, flags, action);
|
||||
|
||||
if (action == Action.PERFORM && extracted != null) {
|
||||
portableGrid.getFluidCache().remove(extracted, extracted.amount, false);
|
||||
portableGrid.getFluidCache().remove(extracted, extracted.getAmount(), false);
|
||||
}
|
||||
|
||||
return extracted;
|
||||
|
||||
@@ -12,8 +12,8 @@ import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
@@ -44,18 +44,18 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
public CompoundNBT writeToNbt() {
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
ListNBT list = new ListNBT();
|
||||
|
||||
for (ItemStack stack : stacks.values()) {
|
||||
list.appendTag(StackUtils.serializeStackToNbt(stack));
|
||||
list.add(StackUtils.serializeStackToNbt(stack));
|
||||
}
|
||||
|
||||
tag.setString(NBT_VERSION, RS.VERSION);
|
||||
tag.setTag(NBT_ITEMS, list);
|
||||
tag.setInteger(NBT_CAPACITY, capacity);
|
||||
tag.putString(NBT_VERSION, RS.VERSION);
|
||||
tag.put(NBT_ITEMS, list);
|
||||
tag.putInt(NBT_CAPACITY, capacity);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskListener;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.portable.IPortableGrid;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -33,7 +33,7 @@ public class StorageDiskItemPortable implements IStorageDisk<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNbt() {
|
||||
public CompoundNBT writeToNbt() {
|
||||
return parent.writeToNbt();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskManager;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.storage.WorldSavedData;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
@@ -26,7 +26,7 @@ public class StorageDiskManager extends WorldSavedData implements IStorageDiskMa
|
||||
private static final String NBT_DISK_DATA = "Data";
|
||||
|
||||
private boolean canReadDisks;
|
||||
private NBTTagList disksTag;
|
||||
private ListNBT disksTag;
|
||||
|
||||
private ConcurrentHashMap<UUID, IStorageDisk> disks = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -93,9 +93,9 @@ public class StorageDiskManager extends WorldSavedData implements IStorageDiskMa
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
if (tag.hasKey(NBT_DISKS)) {
|
||||
this.disksTag = tag.getTagList(NBT_DISKS, Constants.NBT.TAG_COMPOUND);
|
||||
public void read(CompoundNBT tag) {
|
||||
if (tag.contains(NBT_DISKS)) {
|
||||
this.disksTag = tag.getList(NBT_DISKS, Constants.NBT.TAG_COMPOUND);
|
||||
this.canReadDisks = true;
|
||||
}
|
||||
}
|
||||
@@ -104,11 +104,11 @@ public class StorageDiskManager extends WorldSavedData implements IStorageDiskMa
|
||||
if (this.canReadDisks) {
|
||||
this.canReadDisks = false;
|
||||
|
||||
for (int i = 0; i < disksTag.tagCount(); ++i) {
|
||||
NBTTagCompound diskTag = disksTag.getCompoundTagAt(i);
|
||||
for (int i = 0; i < disksTag.size(); ++i) {
|
||||
CompoundNBT diskTag = disksTag.getCompound(i);
|
||||
|
||||
UUID id = diskTag.getUniqueId(NBT_DISK_ID);
|
||||
NBTTagCompound data = diskTag.getCompoundTag(NBT_DISK_DATA);
|
||||
CompoundNBT data = diskTag.getCompound(NBT_DISK_DATA);
|
||||
String type = diskTag.getString(NBT_DISK_TYPE);
|
||||
|
||||
IStorageDiskFactory factory = API.instance().getStorageDiskRegistry().get(type);
|
||||
@@ -120,20 +120,20 @@ public class StorageDiskManager extends WorldSavedData implements IStorageDiskMa
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tag) {
|
||||
NBTTagList disks = new NBTTagList();
|
||||
public CompoundNBT write(CompoundNBT tag) {
|
||||
ListNBT disks = new ListNBT();
|
||||
|
||||
for (Map.Entry<UUID, IStorageDisk> entry : this.disks.entrySet()) {
|
||||
NBTTagCompound diskTag = new NBTTagCompound();
|
||||
CompoundNBT diskTag = new CompoundNBT();
|
||||
|
||||
diskTag.setUniqueId(NBT_DISK_ID, entry.getKey());
|
||||
diskTag.setTag(NBT_DISK_DATA, entry.getValue().writeToNbt());
|
||||
diskTag.setString(NBT_DISK_TYPE, entry.getValue().getId());
|
||||
diskTag.putUniqueId(NBT_DISK_ID, entry.getKey());
|
||||
diskTag.put(NBT_DISK_DATA, entry.getValue().writeToNbt());
|
||||
diskTag.putString(NBT_DISK_TYPE, entry.getValue().getId());
|
||||
|
||||
disks.appendTag(diskTag);
|
||||
disks.add(diskTag);
|
||||
}
|
||||
|
||||
tag.setTag(NBT_DISKS, disks);
|
||||
tag.put(NBT_DISKS, disks);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class StorageDiskSync implements IStorageDiskSync {
|
||||
long lastSync = syncTime.getOrDefault(id, 0L);
|
||||
|
||||
if (System.currentTimeMillis() - lastSync > THROTTLE_MS) {
|
||||
RS.INSTANCE.network.sendToServer(new MessageStorageDiskSizeRequest(id));
|
||||
// TODO: Networking: RS.INSTANCE.network.sendToServer(new MessageStorageDiskSizeRequest(id));
|
||||
|
||||
syncTime.put(id, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
@@ -22,19 +21,19 @@ public class ExternalStorageCacheFluid {
|
||||
if (cache == null) {
|
||||
cache = new ArrayList<>();
|
||||
|
||||
for (IFluidTankProperties properties : handler.getTankProperties()) {
|
||||
cache.add(properties.getContents() == null ? null : properties.getContents().copy());
|
||||
for (int i = 0; i < handler.getTanks(); ++i) {
|
||||
cache.add(handler.getFluidInTank(i));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < handler.getTankProperties().length; ++i) {
|
||||
FluidStack actual = handler.getTankProperties()[i].getContents();
|
||||
for (int i = 0; i < handler.getTanks(); ++i) {
|
||||
FluidStack actual = handler.getFluidInTank(i);
|
||||
|
||||
if (i >= cache.size()) { // ENLARGED
|
||||
if (actual != null) {
|
||||
network.getFluidStorageCache().add(actual, actual.amount, false, true);
|
||||
network.getFluidStorageCache().add(actual, actual.getAmount(), false, true);
|
||||
|
||||
cache.add(actual.copy());
|
||||
}
|
||||
@@ -49,35 +48,35 @@ public class ExternalStorageCacheFluid {
|
||||
}
|
||||
|
||||
if (actual == null && cached != null) { // REMOVED
|
||||
network.getFluidStorageCache().remove(cached, cached.amount, true);
|
||||
network.getFluidStorageCache().remove(cached, cached.getAmount(), true);
|
||||
|
||||
cache.set(i, null);
|
||||
} else if (actual != null && cached == null) { // ADDED
|
||||
network.getFluidStorageCache().add(actual, actual.amount, false, true);
|
||||
network.getFluidStorageCache().add(actual, actual.getAmount(), false, true);
|
||||
|
||||
cache.set(i, actual.copy());
|
||||
} else if (!API.instance().getComparer().isEqual(actual, cached, IComparer.COMPARE_NBT)) { // CHANGED
|
||||
network.getFluidStorageCache().remove(cached, cached.amount, true);
|
||||
network.getFluidStorageCache().add(actual, actual.amount, false, true);
|
||||
network.getFluidStorageCache().remove(cached, cached.getAmount(), true);
|
||||
network.getFluidStorageCache().add(actual, actual.getAmount(), false, true);
|
||||
|
||||
cache.set(i, actual.copy());
|
||||
} else if (actual.amount > cached.amount) { // COUNT_CHANGED
|
||||
network.getFluidStorageCache().add(actual, actual.amount - cached.amount, false, true);
|
||||
} else if (actual.getAmount() > cached.getAmount()) { // COUNT_CHANGED
|
||||
network.getFluidStorageCache().add(actual, actual.getAmount() - cached.getAmount(), false, true);
|
||||
|
||||
cached.amount = actual.amount;
|
||||
} else if (actual.amount < cached.amount) { // COUNT_CHANGED
|
||||
network.getFluidStorageCache().remove(actual, cached.amount - actual.amount, true);
|
||||
cached.setAmount(actual.getAmount());
|
||||
} else if (actual.getAmount() < cached.getAmount()) { // COUNT_CHANGED
|
||||
network.getFluidStorageCache().remove(actual, cached.getAmount() - actual.getAmount(), true);
|
||||
|
||||
cached.amount = actual.amount;
|
||||
cached.setAmount(actual.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
if (cache.size() > handler.getTankProperties().length) { // SHRUNK
|
||||
for (int i = cache.size() - 1; i >= handler.getTankProperties().length; --i) { // Reverse order for the remove call.
|
||||
if (cache.size() > handler.getTanks()) { // SHRUNK
|
||||
for (int i = cache.size() - 1; i >= handler.getTanks(); --i) { // Reverse order for the remove call.
|
||||
FluidStack cached = cache.get(i);
|
||||
|
||||
if (cached != null) {
|
||||
network.getFluidStorageCache().remove(cached, cached.amount, true);
|
||||
network.getFluidStorageCache().remove(cached, cached.getAmount(), true);
|
||||
}
|
||||
|
||||
cache.remove(i);
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.api.storage.externalstorage.IStorageExter
|
||||
import com.raoulvdberge.refinedstorage.tile.TileFluidInterface;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -14,13 +14,13 @@ import java.util.function.Supplier;
|
||||
|
||||
public class ExternalStorageProviderFluid implements IExternalStorageProvider<FluidStack> {
|
||||
@Override
|
||||
public boolean canProvide(TileEntity tile, EnumFacing direction) {
|
||||
public boolean canProvide(TileEntity tile, Direction direction) {
|
||||
return WorldUtils.getFluidHandler(tile, direction.getOpposite()) != null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IStorageExternal<FluidStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, EnumFacing direction) {
|
||||
public IStorageExternal<FluidStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, Direction direction) {
|
||||
return new StorageExternalFluid(context, () -> WorldUtils.getFluidHandler(tile.get(), direction.getOpposite()), tile.get() instanceof TileFluidInterface);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,18 +10,17 @@ import com.raoulvdberge.refinedstorage.tile.TileInterface;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ExternalStorageProviderItem implements IExternalStorageProvider<ItemStack> {
|
||||
@Override
|
||||
public boolean canProvide(TileEntity tile, EnumFacing direction) {
|
||||
boolean isNode = tile.hasCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, direction.getOpposite());
|
||||
INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, direction.getOpposite());
|
||||
public boolean canProvide(TileEntity tile, Direction direction) {
|
||||
INetworkNodeProxy nodeProxy = tile.getCapability(CapabilityNetworkNodeProxy.NETWORK_NODE_PROXY_CAPABILITY, direction.getOpposite()).orElse(null);
|
||||
|
||||
if (!(isNode && nodeProxy.getNode() instanceof IStorageProvider)) {
|
||||
if (!(nodeProxy != null && nodeProxy.getNode() instanceof IStorageProvider)) { // TODO: Correct if still?
|
||||
return WorldUtils.getItemHandler(tile, direction.getOpposite()) != null;
|
||||
}
|
||||
|
||||
@@ -30,7 +29,7 @@ public class ExternalStorageProviderItem implements IExternalStorageProvider<Ite
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IStorageExternal<ItemStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, EnumFacing direction) {
|
||||
public IStorageExternal<ItemStack> provide(IExternalStorageContext context, Supplier<TileEntity> tile, Direction direction) {
|
||||
return new StorageExternalItem(context, () -> WorldUtils.getItemHandler(tile.get(), direction.getOpposite()), tile.get() instanceof TileInterface);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.util.StackUtils;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -34,13 +33,6 @@ public class StorageExternalFluid implements IStorageExternal<FluidStack> {
|
||||
return connectedToInterface;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IFluidTankProperties[] getProperties() {
|
||||
IFluidHandler handler = handlerSupplier.get();
|
||||
|
||||
return (handler != null && handler.getTankProperties() != null && handler.getTankProperties().length != 0) ? handler.getTankProperties() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(INetwork network) {
|
||||
if (getAccessType() == AccessType.INSERT) {
|
||||
@@ -52,13 +44,13 @@ public class StorageExternalFluid implements IStorageExternal<FluidStack> {
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
IFluidTankProperties[] props = getProperties();
|
||||
IFluidHandler fluidHandler = handlerSupplier.get();
|
||||
|
||||
if (props != null) {
|
||||
if (fluidHandler != null) {
|
||||
int cap = 0;
|
||||
|
||||
for (IFluidTankProperties properties : props) {
|
||||
cap += properties.getCapacity();
|
||||
for (int i = 0; i < fluidHandler.getTanks(); ++i) {
|
||||
cap += fluidHandler.getTankCapacity(i);
|
||||
}
|
||||
|
||||
return cap;
|
||||
@@ -69,17 +61,13 @@ public class StorageExternalFluid implements IStorageExternal<FluidStack> {
|
||||
|
||||
@Override
|
||||
public Collection<FluidStack> getStacks() {
|
||||
IFluidTankProperties[] props = getProperties();
|
||||
IFluidHandler fluidHandler = handlerSupplier.get();
|
||||
|
||||
if (props != null) {
|
||||
if (fluidHandler != null) {
|
||||
List<FluidStack> fluids = new ArrayList<>();
|
||||
|
||||
for (IFluidTankProperties properties : props) {
|
||||
FluidStack stack = properties.getContents();
|
||||
|
||||
if (stack != null) {
|
||||
fluids.add(stack);
|
||||
}
|
||||
for (int i = 0; i < fluidHandler.getTanks(); ++i) {
|
||||
fluids.add(fluidHandler.getFluidInTank(i));
|
||||
}
|
||||
|
||||
return fluids;
|
||||
@@ -92,7 +80,7 @@ public class StorageExternalFluid implements IStorageExternal<FluidStack> {
|
||||
@Override
|
||||
public FluidStack insert(@Nonnull FluidStack stack, int size, Action action) {
|
||||
if (context.acceptsFluid(stack)) {
|
||||
int filled = handlerSupplier.get().fill(StackUtils.copy(stack, size), action == Action.PERFORM);
|
||||
int filled = handlerSupplier.get().fill(StackUtils.copy(stack, size), action == Action.PERFORM ? IFluidHandler.FluidAction.EXECUTE : IFluidHandler.FluidAction.SIMULATE);
|
||||
|
||||
if (filled == size) {
|
||||
return null;
|
||||
@@ -113,22 +101,18 @@ public class StorageExternalFluid implements IStorageExternal<FluidStack> {
|
||||
return null;
|
||||
}
|
||||
|
||||
return handler.drain(StackUtils.copy(stack, size), action == Action.PERFORM);
|
||||
return handler.drain(StackUtils.copy(stack, size), action == Action.PERFORM ? IFluidHandler.FluidAction.EXECUTE : IFluidHandler.FluidAction.SIMULATE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored() {
|
||||
IFluidTankProperties[] props = getProperties();
|
||||
IFluidHandler fluidHandler = handlerSupplier.get();
|
||||
|
||||
if (props != null) {
|
||||
if (fluidHandler != null) {
|
||||
int stored = 0;
|
||||
|
||||
for (IFluidTankProperties properties : props) {
|
||||
FluidStack contents = properties.getContents();
|
||||
|
||||
if (contents != null) {
|
||||
stored += contents.amount;
|
||||
}
|
||||
for (int i = 0; i < fluidHandler.getTanks(); ++i) {
|
||||
stored += fluidHandler.getFluidInTank(i).getAmount();
|
||||
}
|
||||
|
||||
return stored;
|
||||
@@ -153,6 +137,6 @@ public class StorageExternalFluid implements IStorageExternal<FluidStack> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return remainder == null ? size : (size - remainder.amount);
|
||||
return remainder == null ? size : (size - remainder.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,31 +2,24 @@ package com.raoulvdberge.refinedstorage.apiimpl.util;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class Comparer implements IComparer {
|
||||
@Override
|
||||
public boolean isEqual(@Nullable ItemStack left, @Nullable ItemStack right, int flags) {
|
||||
EnumActionResult validity = getResult(left, right);
|
||||
ActionResultType validity = getResult(left, right);
|
||||
|
||||
if (validity == EnumActionResult.FAIL || validity == EnumActionResult.SUCCESS) {
|
||||
return validity == EnumActionResult.SUCCESS;
|
||||
if (validity == ActionResultType.FAIL || validity == ActionResultType.SUCCESS) {
|
||||
return validity == ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if (left.getItem() != right.getItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((flags & COMPARE_DAMAGE) == COMPARE_DAMAGE && left.getItemDamage() != OreDictionary.WILDCARD_VALUE && right.getItemDamage() != OreDictionary.WILDCARD_VALUE) {
|
||||
if (left.getItemDamage() != right.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & COMPARE_NBT) == COMPARE_NBT) {
|
||||
if (!isEqualNbt(left, right)) {
|
||||
return false;
|
||||
@@ -57,13 +50,13 @@ public class Comparer implements IComparer {
|
||||
}
|
||||
|
||||
if ((flags & COMPARE_QUANTITY) == COMPARE_QUANTITY) {
|
||||
if (left.amount != right.amount) {
|
||||
if (left.getAmount() != right.getAmount()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((flags & COMPARE_NBT) == COMPARE_NBT) {
|
||||
if (left.tag != null && !left.tag.equals(right.tag)) {
|
||||
if (left.getTag() != null && !left.getTag().equals(right.getTag())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -73,18 +66,18 @@ public class Comparer implements IComparer {
|
||||
|
||||
@Override
|
||||
public boolean isEqualNbt(@Nullable ItemStack left, @Nullable ItemStack right) {
|
||||
EnumActionResult validity = getResult(left, right);
|
||||
ActionResultType validity = getResult(left, right);
|
||||
|
||||
if (validity == EnumActionResult.FAIL || validity == EnumActionResult.SUCCESS) {
|
||||
return validity == EnumActionResult.SUCCESS;
|
||||
if (validity == ActionResultType.FAIL || validity == ActionResultType.SUCCESS) {
|
||||
return validity == ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if (!ItemStack.areItemStackTagsEqual(left, right)) {
|
||||
if (left.hasTagCompound() && !right.hasTagCompound() && left.getTagCompound().isEmpty()) {
|
||||
if (left.hasTag() && !right.hasTag() && left.getTag().isEmpty()) {
|
||||
return true;
|
||||
} else if (!left.hasTagCompound() && right.hasTagCompound() && right.getTagCompound().isEmpty()) {
|
||||
} else if (!left.hasTag() && right.hasTag() && right.getTag().isEmpty()) {
|
||||
return true;
|
||||
} else if (!left.hasTagCompound() && !right.hasTagCompound()) {
|
||||
} else if (!left.hasTag() && !right.hasTag()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -94,26 +87,26 @@ public class Comparer implements IComparer {
|
||||
return true;
|
||||
}
|
||||
|
||||
private EnumActionResult getResult(@Nullable ItemStack left, @Nullable ItemStack right) {
|
||||
private ActionResultType getResult(@Nullable ItemStack left, @Nullable ItemStack right) {
|
||||
if (left == null && right == null) {
|
||||
return EnumActionResult.SUCCESS;
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if ((left == null && right != null) || (left != null && right == null)) {
|
||||
return EnumActionResult.FAIL;
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
boolean leftEmpty = left.isEmpty();
|
||||
boolean rightEmpty = right.isEmpty();
|
||||
|
||||
if (leftEmpty && rightEmpty) {
|
||||
return EnumActionResult.SUCCESS;
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
if ((leftEmpty && !rightEmpty) || (!leftEmpty && rightEmpty)) {
|
||||
return EnumActionResult.FAIL;
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
return EnumActionResult.PASS;
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,254 +0,0 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.util;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDisk;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.disk.IStorageDiskProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.Action;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IFilter;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IOneSixMigrationHelper;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeFluidStorage;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.storage.NetworkNodeStorage;
|
||||
import com.raoulvdberge.refinedstorage.block.enums.FluidStorageType;
|
||||
import com.raoulvdberge.refinedstorage.block.enums.ItemStorageType;
|
||||
import com.raoulvdberge.refinedstorage.inventory.item.ItemHandlerBase;
|
||||
import com.raoulvdberge.refinedstorage.item.ItemPattern;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public class OneSixMigrationHelper implements IOneSixMigrationHelper {
|
||||
// 1.5.x NBT keys
|
||||
private static final String NBT_ITEMS = "Items";
|
||||
private static final String NBT_ITEM_TYPE = "Type";
|
||||
private static final String NBT_ITEM_QUANTITY = "Quantity";
|
||||
private static final String NBT_ITEM_DAMAGE = "Damage";
|
||||
private static final String NBT_ITEM_NBT = "NBT";
|
||||
private static final String NBT_ITEM_CAPS = "Caps";
|
||||
|
||||
private static final String NBT_FLUIDS = "Fluids";
|
||||
|
||||
private static UUID createItemDisk(World world, int capacity, NBTTagCompound legacyTag) {
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
IStorageDisk<ItemStack> newDisk = API.instance().createDefaultItemDisk(world, capacity);
|
||||
|
||||
NBTTagList list = (NBTTagList) legacyTag.getTag(NBT_ITEMS);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
|
||||
ItemStack stack = new ItemStack(
|
||||
Item.getItemById(tag.getInteger(NBT_ITEM_TYPE)),
|
||||
tag.getInteger(NBT_ITEM_QUANTITY),
|
||||
tag.getInteger(NBT_ITEM_DAMAGE),
|
||||
tag.hasKey(NBT_ITEM_CAPS) ? tag.getCompoundTag(NBT_ITEM_CAPS) : null
|
||||
);
|
||||
|
||||
stack.setTagCompound(tag.hasKey(NBT_ITEM_NBT) ? tag.getCompoundTag(NBT_ITEM_NBT) : null);
|
||||
|
||||
if (!stack.isEmpty()) {
|
||||
newDisk.insert(stack, stack.getCount(), Action.PERFORM);
|
||||
}
|
||||
}
|
||||
|
||||
API.instance().getStorageDiskManager(world).set(id, newDisk);
|
||||
API.instance().getStorageDiskManager(world).markForSaving();
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
private static UUID createFluidDisk(World world, int capacity, NBTTagCompound legacyTag) {
|
||||
UUID id = UUID.randomUUID();
|
||||
|
||||
IStorageDisk<FluidStack> newDisk = API.instance().createDefaultFluidDisk(world, capacity);
|
||||
|
||||
NBTTagList list = (NBTTagList) legacyTag.getTag(NBT_FLUIDS);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
FluidStack stack = FluidStack.loadFluidStackFromNBT(list.getCompoundTagAt(i));
|
||||
|
||||
if (stack != null) {
|
||||
newDisk.insert(stack, stack.amount, Action.PERFORM);
|
||||
}
|
||||
}
|
||||
|
||||
API.instance().getStorageDiskManager(world).set(id, newDisk);
|
||||
API.instance().getStorageDiskManager(world).markForSaving();
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean migrateDisk(World world, ItemStack disk) {
|
||||
IStorageDiskProvider provider = (IStorageDiskProvider) disk.getItem();
|
||||
|
||||
switch (provider.getType()) {
|
||||
case ITEM:
|
||||
if (disk.hasTagCompound() && disk.getTagCompound().hasKey(NBT_ITEMS)) {
|
||||
provider.setId(disk, createItemDisk(world, provider.getCapacity(disk), disk.getTagCompound()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
case FLUID:
|
||||
if (disk.hasTagCompound() && disk.getTagCompound().hasKey(NBT_FLUIDS)) {
|
||||
provider.setId(disk, createFluidDisk(world, provider.getCapacity(disk), disk.getTagCompound()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean migrateDiskInventory(World world, IItemHandlerModifiable handler) {
|
||||
boolean migrated = false;
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||
ItemStack disk = handler.getStackInSlot(i);
|
||||
|
||||
if (!disk.isEmpty() && disk.getItem() instanceof IStorageDiskProvider) {
|
||||
if (migrateDisk(world, disk)) {
|
||||
handler.setStackInSlot(i, disk); // Trigger a onContentsChanged
|
||||
|
||||
migrated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return migrated;
|
||||
}
|
||||
|
||||
private static final String NBT_OUTPUTS = "Outputs";
|
||||
private static final String NBT_SLOT = "Slot_%d";
|
||||
|
||||
@Override
|
||||
public boolean migratePattern(ItemStack pattern) {
|
||||
NBTTagCompound tag = pattern.getTagCompound();
|
||||
|
||||
if (pattern.hasTagCompound() && !tag.hasKey(ItemPattern.NBT_PROCESSING)) {
|
||||
boolean isProcessing = tag.hasKey(NBT_OUTPUTS);
|
||||
|
||||
// Add "processing" tag
|
||||
tag.setBoolean(ItemPattern.NBT_PROCESSING, isProcessing);
|
||||
|
||||
// Convert "slot_%d" to "input_%d"
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
String id = String.format(NBT_SLOT, i);
|
||||
|
||||
if (tag.hasKey(id)) {
|
||||
ItemStack slot = new ItemStack(pattern.getTagCompound().getCompoundTag(id));
|
||||
|
||||
if (!slot.isEmpty()) {
|
||||
tag.setTag(String.format(ItemPattern.NBT_INPUT_SLOT, i), slot.serializeNBT());
|
||||
}
|
||||
|
||||
tag.removeTag(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert "outputs" to "output_%d"
|
||||
if (isProcessing) {
|
||||
NBTTagList list = tag.getTagList(NBT_OUTPUTS, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
ItemStack output = new ItemStack(list.getCompoundTagAt(i));
|
||||
|
||||
if (!output.isEmpty()) {
|
||||
tag.setTag(String.format(ItemPattern.NBT_OUTPUT_SLOT, i), output.serializeNBT());
|
||||
}
|
||||
}
|
||||
|
||||
tag.removeTag(NBT_OUTPUTS);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean migratePatternInventory(IItemHandler handler) {
|
||||
boolean migrated = false;
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||
ItemStack pattern = handler.getStackInSlot(i);
|
||||
|
||||
if (!pattern.isEmpty() && migratePattern(pattern)) {
|
||||
migrated = true;
|
||||
}
|
||||
}
|
||||
|
||||
return migrated;
|
||||
}
|
||||
|
||||
// We check on NBT_PROCESSING, so it needs to be there for sure to be a valid pattern.
|
||||
public static boolean isValidOneSixPattern(ItemStack stack) {
|
||||
return stack.hasTagCompound() && stack.getTagCompound().hasKey(ItemPattern.NBT_PROCESSING);
|
||||
}
|
||||
|
||||
// If we remove the OneSixMigrationHelper we know where to remove other migration hooks by removing this method.
|
||||
public static void removalHook() {
|
||||
}
|
||||
|
||||
public static void migrateEmptyWhitelistToEmptyBlacklist(String version, IFilterable filterable, @Nullable ItemHandlerBase itemFilterInv) {
|
||||
// Only migrate if we come from a version where the RS version tag stuff in NetworkNode wasn't added yet.
|
||||
// Otherwise, we would constantly migrate empty whitelists to empty blacklists...
|
||||
if (version == null && filterable.getMode() == IFilterable.WHITELIST && (itemFilterInv == null || itemFilterInv.isEmpty())) {
|
||||
filterable.setMode(IFilter.MODE_BLACKLIST);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String NBT_STORAGE = "Storage";
|
||||
|
||||
public static void migrateItemStorageBlock(NetworkNodeStorage storage, NBTTagCompound tag) {
|
||||
if (tag.hasKey(NBT_STORAGE)) {
|
||||
NBTTagCompound storageTag = tag.getCompoundTag(NBT_STORAGE);
|
||||
|
||||
storage.setStorageId(createItemDisk(storage.getWorld(), storage.getType().getCapacity(), storageTag));
|
||||
storage.loadStorage();
|
||||
}
|
||||
}
|
||||
|
||||
public static void migrateItemStorageBlockItem(World world, ItemStack stack) {
|
||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_STORAGE)) {
|
||||
NBTTagCompound storageTag = stack.getTagCompound().getCompoundTag(NBT_STORAGE);
|
||||
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
stack.getTagCompound().setUniqueId(NetworkNodeStorage.NBT_ID, createItemDisk(world, ItemStorageType.getById(stack.getItemDamage()).getCapacity(), storageTag));
|
||||
}
|
||||
}
|
||||
|
||||
public static void migrateFluidStorageBlock(NetworkNodeFluidStorage storage, NBTTagCompound tag) {
|
||||
if (tag.hasKey(NBT_STORAGE)) {
|
||||
NBTTagCompound storageTag = tag.getCompoundTag(NBT_STORAGE);
|
||||
|
||||
storage.setStorageId(createFluidDisk(storage.getWorld(), storage.getType().getCapacity(), storageTag));
|
||||
storage.loadStorage();
|
||||
}
|
||||
}
|
||||
|
||||
public static void migrateFluidStorageBlockItem(World world, ItemStack stack) {
|
||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey(NBT_STORAGE)) {
|
||||
NBTTagCompound storageTag = stack.getTagCompound().getCompoundTag(NBT_STORAGE);
|
||||
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
stack.getTagCompound().setUniqueId(NetworkNodeStorage.NBT_ID, createFluidDisk(world, FluidStorageType.getById(stack.getItemDamage()).getCapacity(), storageTag));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.util;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.util.IQuantityFormatter;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -60,12 +60,12 @@ public class QuantityFormatter implements IQuantityFormatter {
|
||||
|
||||
@Override
|
||||
public String formatInBucketForm(int qty) {
|
||||
return bucketFormatter.format((float) qty / (float) Fluid.BUCKET_VOLUME) + " B";
|
||||
return bucketFormatter.format((float) qty / (float) FluidAttributes.BUCKET_VOLUME) + " B";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatInBucketFormWithOnlyTrailingDigitsIfZero(int qty) {
|
||||
float amountRaw = ((float) qty / (float) Fluid.BUCKET_VOLUME);
|
||||
float amountRaw = ((float) qty / (float) FluidAttributes.BUCKET_VOLUME);
|
||||
int amount = (int) amountRaw;
|
||||
|
||||
if (amount >= 1) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user