Blockstates for disk drive slots
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package refinedstorage.block;
|
package refinedstorage.block;
|
||||||
|
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
import net.minecraft.block.properties.PropertyInteger;
|
import net.minecraft.block.properties.PropertyInteger;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
@@ -18,6 +19,15 @@ import refinedstorage.tile.TileDiskDrive;
|
|||||||
public class BlockDiskDrive extends BlockNode {
|
public class BlockDiskDrive extends BlockNode {
|
||||||
private static final PropertyInteger STORED = PropertyInteger.create("stored", 0, 7);
|
private static final PropertyInteger STORED = PropertyInteger.create("stored", 0, 7);
|
||||||
|
|
||||||
|
private static final PropertyBool FILLED_0 = PropertyBool.create("filled_0");
|
||||||
|
private static final PropertyBool FILLED_1 = PropertyBool.create("filled_1");
|
||||||
|
private static final PropertyBool FILLED_2 = PropertyBool.create("filled_2");
|
||||||
|
private static final PropertyBool FILLED_3 = PropertyBool.create("filled_3");
|
||||||
|
private static final PropertyBool FILLED_4 = PropertyBool.create("filled_4");
|
||||||
|
private static final PropertyBool FILLED_5 = PropertyBool.create("filled_5");
|
||||||
|
private static final PropertyBool FILLED_6 = PropertyBool.create("filled_6");
|
||||||
|
private static final PropertyBool FILLED_7 = PropertyBool.create("filled_7");
|
||||||
|
|
||||||
public BlockDiskDrive() {
|
public BlockDiskDrive() {
|
||||||
super("disk_drive");
|
super("disk_drive");
|
||||||
}
|
}
|
||||||
@@ -31,13 +41,33 @@ public class BlockDiskDrive extends BlockNode {
|
|||||||
public BlockStateContainer createBlockState() {
|
public BlockStateContainer createBlockState() {
|
||||||
return createBlockStateBuilder()
|
return createBlockStateBuilder()
|
||||||
.add(STORED)
|
.add(STORED)
|
||||||
|
.add(FILLED_0)
|
||||||
|
.add(FILLED_1)
|
||||||
|
.add(FILLED_2)
|
||||||
|
.add(FILLED_3)
|
||||||
|
.add(FILLED_4)
|
||||||
|
.add(FILLED_5)
|
||||||
|
.add(FILLED_6)
|
||||||
|
.add(FILLED_7)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||||
return super.getActualState(state, world, pos)
|
TileDiskDrive diskDrive = (TileDiskDrive) world.getTileEntity(pos);
|
||||||
.withProperty(STORED, Math.max(0, ((TileDiskDrive) world.getTileEntity(pos)).getStoredForDisplay()));
|
|
||||||
|
state = super.getActualState(state, world, pos);
|
||||||
|
state = state.withProperty(STORED, Math.max(0, diskDrive.getStoredForDisplay()));
|
||||||
|
state = state.withProperty(FILLED_0, diskDrive.getFilled()[0]);
|
||||||
|
state = state.withProperty(FILLED_1, diskDrive.getFilled()[1]);
|
||||||
|
state = state.withProperty(FILLED_2, diskDrive.getFilled()[2]);
|
||||||
|
state = state.withProperty(FILLED_3, diskDrive.getFilled()[3]);
|
||||||
|
state = state.withProperty(FILLED_4, diskDrive.getFilled()[4]);
|
||||||
|
state = state.withProperty(FILLED_5, diskDrive.getFilled()[5]);
|
||||||
|
state = state.withProperty(FILLED_6, diskDrive.getFilled()[6]);
|
||||||
|
state = state.withProperty(FILLED_7, diskDrive.getFilled()[7]);
|
||||||
|
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
private static final String NBT_MODE = "Mode";
|
private static final String NBT_MODE = "Mode";
|
||||||
private static final String NBT_STORED = "Stored";
|
private static final String NBT_STORED = "Stored";
|
||||||
private static final String NBT_TYPE = "Type";
|
private static final String NBT_TYPE = "Type";
|
||||||
|
private static final String NBT_FILLED = "Filled_%d";
|
||||||
|
|
||||||
private ItemHandlerBasic disks = new ItemHandlerBasic(8, this, IItemValidator.STORAGE_DISK) {
|
private ItemHandlerBasic disks = new ItemHandlerBasic(8, this, IItemValidator.STORAGE_DISK) {
|
||||||
@Override
|
@Override
|
||||||
@@ -99,6 +100,10 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
network.getItemStorage().rebuild();
|
network.getItemStorage().rebuild();
|
||||||
network.getFluidStorage().rebuild();
|
network.getFluidStorage().rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (worldObj != null) {
|
||||||
|
updateBlock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +133,7 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
private int type = IType.ITEMS;
|
private int type = IType.ITEMS;
|
||||||
|
|
||||||
private int stored = 0;
|
private int stored = 0;
|
||||||
|
private boolean[] filled = new boolean[8];
|
||||||
|
|
||||||
public TileDiskDrive() {
|
public TileDiskDrive() {
|
||||||
dataManager.addWatchedParameter(PRIORITY);
|
dataManager.addWatchedParameter(PRIORITY);
|
||||||
@@ -263,6 +269,10 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
|
|
||||||
tag.setInteger(NBT_STORED, stored);
|
tag.setInteger(NBT_STORED, stored);
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
tag.setBoolean(String.format(NBT_FILLED, i), disks.getStackInSlot(i) != null);
|
||||||
|
}
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,9 +280,17 @@ public class TileDiskDrive extends TileNode implements IItemStorageProvider, IFl
|
|||||||
public void readUpdate(NBTTagCompound tag) {
|
public void readUpdate(NBTTagCompound tag) {
|
||||||
stored = tag.getInteger(NBT_STORED);
|
stored = tag.getInteger(NBT_STORED);
|
||||||
|
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
filled[i] = tag.getBoolean(String.format(NBT_FILLED, i));
|
||||||
|
}
|
||||||
|
|
||||||
super.readUpdate(tag);
|
super.readUpdate(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean[] getFilled() {
|
||||||
|
return filled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCompare() {
|
public int getCompare() {
|
||||||
return compare;
|
return compare;
|
||||||
|
|||||||
@@ -14,6 +14,54 @@
|
|||||||
"y": 0
|
"y": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"filled_0": {
|
||||||
|
"true": {
|
||||||
|
},
|
||||||
|
"false": {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"filled_1": {
|
||||||
|
"true": {
|
||||||
|
},
|
||||||
|
"false": {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"filled_2": {
|
||||||
|
"true": {
|
||||||
|
},
|
||||||
|
"false": {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"filled_3": {
|
||||||
|
"true": {
|
||||||
|
},
|
||||||
|
"false": {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"filled_4": {
|
||||||
|
"true": {
|
||||||
|
},
|
||||||
|
"false": {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"filled_5": {
|
||||||
|
"true": {
|
||||||
|
},
|
||||||
|
"false": {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"filled_6": {
|
||||||
|
"true": {
|
||||||
|
},
|
||||||
|
"false": {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"filled_7": {
|
||||||
|
"true": {
|
||||||
|
},
|
||||||
|
"false": {
|
||||||
|
}
|
||||||
|
},
|
||||||
"stored": {
|
"stored": {
|
||||||
"0": {
|
"0": {
|
||||||
"textures": {
|
"textures": {
|
||||||
|
|||||||
Reference in New Issue
Block a user