Add constructor destructor model, fix issue with setting storage on client

This commit is contained in:
Raoul Van den Berge
2016-07-10 21:48:32 +02:00
parent a57e9e8e9b
commit f9c4eb4def
14 changed files with 1352 additions and 36 deletions

View File

@@ -43,7 +43,7 @@ public abstract class NBTStorage implements IStorage {
/**
* @param tag The NBT tag we are reading from and writing the amount stored to, has to be initialized with {@link NBTStorage#createNBT()} if it doesn't exist yet
* @param capacity The capacity of this storage, -1 for infinite capacity
* @param tile A {@link TileEntity} that the NBT storage is in, will be marked dirty when storage changes
* @param tile A {@link TileEntity} that the NBT storage is in, will be marked dirty when the storage changes
*/
public NBTStorage(NBTTagCompound tag, int capacity, @Nullable TileEntity tile) {
this.tag = tag;

View File

@@ -12,7 +12,7 @@ import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileConstructor;
public class BlockConstructor extends BlockNode {
public class BlockConstructor extends BlockCable {
public BlockConstructor() {
super("constructor");
}

View File

@@ -12,7 +12,7 @@ import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageGui;
import refinedstorage.tile.TileDestructor;
public class BlockDestructor extends BlockNode {
public class BlockDestructor extends BlockCable {
public BlockDestructor() {
super("destructor");
}

View File

@@ -6,6 +6,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;
@@ -56,16 +58,21 @@ public class TileDiskDrive extends TileNode implements IStorageProvider, IStorag
protected void onContentsChanged(int slot) {
super.onContentsChanged(slot);
ItemStack disk = getStackInSlot(slot);
/**
* Can't use {@link net.minecraft.world.World#isRemote} here because when {@link TileDiskDrive#readFromNBT(NBTTagCompound)} is called there is no world set yet.
*/
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
ItemStack disk = getStackInSlot(slot);
if (disk == null) {
storages[slot] = null;
} else {
storages[slot] = new Storage(disk);
}
if (disk == null) {
storages[slot] = null;
} else {
storages[slot] = new Storage(disk);
}
if (network != null) {
network.getStorage().rebuild();
if (network != null) {
network.getStorage().rebuild();
}
}
}