This makes more sense
This commit is contained in:
@@ -76,10 +76,12 @@ public class BlockStorage extends BlockMachine {
|
|||||||
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
|
||||||
super.onBlockPlacedBy(world, pos, state, player, stack);
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
|
|
||||||
|
if (!world.isRemote) {
|
||||||
NBTTagCompound tag = stack.getTagCompound();
|
NBTTagCompound tag = stack.getTagCompound();
|
||||||
|
|
||||||
((TileStorage) world.getTileEntity(pos)).onPlaced((tag != null && tag.hasKey(TileStorage.NBT_STORAGE)) ? tag.getCompoundTag(TileStorage.NBT_STORAGE) : null);
|
((TileStorage) world.getTileEntity(pos)).onPlaced((tag != null && tag.hasKey(TileStorage.NBT_STORAGE)) ? tag.getCompoundTag(TileStorage.NBT_STORAGE) : null);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
|||||||
|
|
||||||
private InventorySimple inventory = new InventorySimple("storage", 9, this);
|
private InventorySimple inventory = new InventorySimple("storage", 9, this);
|
||||||
|
|
||||||
private NBTTagCompound storageTag;
|
private NBTTagCompound storageTag = NBTStorage.createNBT();
|
||||||
|
|
||||||
private StorageBlockStorage storage;
|
private StorageBlockStorage storage;
|
||||||
|
|
||||||
@@ -43,31 +43,26 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMachine() {
|
public void updateMachine() {
|
||||||
if (getStorage().isDirty()) {
|
if (storage != null && storage.isDirty()) {
|
||||||
markDirty();
|
markDirty();
|
||||||
|
|
||||||
getStorage().markClean();
|
storage.markClean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlaced(NBTTagCompound tag) {
|
public void onPlaced(NBTTagCompound tag) {
|
||||||
if (tag == null) {
|
if (tag != null) {
|
||||||
storageTag = NBTStorage.createNBT();
|
this.storageTag = tag;
|
||||||
} else {
|
|
||||||
storageTag = tag;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NBTStorage getStorage() {
|
this.storage = new StorageBlockStorage(this);
|
||||||
if (storage == null) {
|
|
||||||
storage = new StorageBlockStorage(this);
|
|
||||||
}
|
|
||||||
return storage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void provide(List<IStorage> storages) {
|
public void provide(List<IStorage> storages) {
|
||||||
storages.add(getStorage());
|
if (storage != null) {
|
||||||
|
storages.add(storage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,10 +77,10 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
|||||||
|
|
||||||
if (nbt.hasKey(NBT_STORAGE)) {
|
if (nbt.hasKey(NBT_STORAGE)) {
|
||||||
storageTag = nbt.getCompoundTag(NBT_STORAGE);
|
storageTag = nbt.getCompoundTag(NBT_STORAGE);
|
||||||
} else {
|
|
||||||
storageTag = NBTStorage.createNBT();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storage = new StorageBlockStorage(this);
|
||||||
|
|
||||||
if (nbt.hasKey(NBT_COMPARE)) {
|
if (nbt.hasKey(NBT_COMPARE)) {
|
||||||
compare = nbt.getInteger(NBT_COMPARE);
|
compare = nbt.getInteger(NBT_COMPARE);
|
||||||
}
|
}
|
||||||
@@ -102,7 +97,10 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
|||||||
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
RefinedStorageUtils.saveInventory(inventory, 0, nbt);
|
||||||
|
|
||||||
nbt.setInteger(NBT_PRIORITY, priority);
|
nbt.setInteger(NBT_PRIORITY, priority);
|
||||||
|
|
||||||
|
storage.writeToNBT(storageTag);
|
||||||
nbt.setTag(NBT_STORAGE, storageTag);
|
nbt.setTag(NBT_STORAGE, storageTag);
|
||||||
|
|
||||||
nbt.setInteger(NBT_COMPARE, compare);
|
nbt.setInteger(NBT_COMPARE, compare);
|
||||||
nbt.setInteger(NBT_MODE, mode);
|
nbt.setInteger(NBT_MODE, mode);
|
||||||
}
|
}
|
||||||
@@ -210,12 +208,6 @@ public class TileStorage extends TileMachine implements IStorageProvider, IStora
|
|||||||
return storageTag;
|
return storageTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStorageTag(NBTTagCompound tag) {
|
|
||||||
markDirty();
|
|
||||||
|
|
||||||
this.storageTag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPriority() {
|
public int getPriority() {
|
||||||
return priority;
|
return priority;
|
||||||
|
|||||||
Reference in New Issue
Block a user