use of mcjty.rftools.blocks.storage.ModularAmountOverlay in project RFTools by McJty.
the class ModularStorageBlock method getActualState.
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntity tileEntity = world instanceof ChunkCache ? ((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos);
if (tileEntity instanceof ModularStorageTileEntity) {
ModularStorageTileEntity te = (ModularStorageTileEntity) tileEntity;
ItemStack stack = te.getInventoryHelper().getStackInSlot(ModularStorageContainer.SLOT_TYPE_MODULE);
int level = te.getRenderLevel();
int remoteId = te.getRemoteId();
ModularAmountOverlay p = AMOUNT_NONE;
if (remoteId > 0) {
switch(level) {
case -1:
p = AMOUNT_NONE;
break;
case 0:
p = AMOUNT_R0;
break;
case 1:
p = AMOUNT_R1;
break;
case 2:
p = AMOUNT_R2;
break;
case 3:
p = AMOUNT_R3;
break;
case 4:
p = AMOUNT_R4;
break;
case 5:
p = AMOUNT_R5;
break;
case 6:
p = AMOUNT_R6;
break;
case 7:
p = AMOUNT_R7;
break;
}
} else {
switch(level) {
case -1:
p = AMOUNT_NONE;
break;
case 0:
p = AMOUNT_G0;
break;
case 1:
p = AMOUNT_G1;
break;
case 2:
p = AMOUNT_G2;
break;
case 3:
p = AMOUNT_G3;
break;
case 4:
p = AMOUNT_G4;
break;
case 5:
p = AMOUNT_G5;
break;
case 6:
p = AMOUNT_G6;
break;
case 7:
p = AMOUNT_G7;
break;
}
}
IBlockState newstate = state.withProperty(AMOUNT, p);
if (stack.isEmpty()) {
return newstate.withProperty(TYPEMODULE, TYPE_NONE);
} else if (stack.getItem() == ModularStorageSetup.genericTypeItem) {
return newstate.withProperty(TYPEMODULE, TYPE_GENERIC);
} else if (stack.getItem() == ModularStorageSetup.oreDictTypeItem) {
return newstate.withProperty(TYPEMODULE, TYPE_ORE);
}
return newstate.withProperty(TYPEMODULE, TYPE_NONE);
} else {
return super.getActualState(state, world, pos);
}
}
Aggregations