diff --git a/src/main/java/appeng/block/storage/BlockChest.java b/src/main/java/appeng/block/storage/BlockChest.java index 62e1bd805..dac20eaf4 100644 --- a/src/main/java/appeng/block/storage/BlockChest.java +++ b/src/main/java/appeng/block/storage/BlockChest.java @@ -22,12 +22,16 @@ package appeng.block.storage; import javax.annotation.Nullable; import net.minecraft.block.material.Material; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import appeng.api.AEApi; @@ -43,10 +47,19 @@ import appeng.util.Platform; public class BlockChest extends AEBaseTileBlock { + private final static PropertyEnum SLOT_STATE = PropertyEnum.create( "slot_state", DriveSlotState.class ); + public BlockChest() { super( Material.IRON ); this.setTileEntity( TileChest.class ); + this.setDefaultState( getDefaultState().withProperty( SLOT_STATE, DriveSlotState.EMPTY ) ); + } + + @Override + protected IProperty[] getAEStates() + { + return new IProperty[] { SLOT_STATE }; } @Override @@ -55,6 +68,30 @@ public class BlockChest extends AEBaseTileBlock return BlockRenderLayer.CUTOUT; } + @Override + public IBlockState getActualState( IBlockState state, IBlockAccess worldIn, BlockPos pos ) + { + DriveSlotState slotState = DriveSlotState.EMPTY; + + TileChest te = getTileEntity( worldIn, pos ); + + if( te != null ) + { + if( te.getCellCount() >= 1 ) + { + slotState = DriveSlotState.fromCellStatus( te.getCellStatus( 0 ) ); + } + // Power-state has to be checked separately + if( !te.isPowered() && slotState != DriveSlotState.EMPTY ) + { + slotState = DriveSlotState.OFFLINE; + } + } + + return super.getActualState( state, worldIn, pos ) + .withProperty( SLOT_STATE, slotState ); + } + @Override public boolean onActivated( final World w, final BlockPos pos, final EntityPlayer p, final EnumHand hand, final @Nullable ItemStack heldItem, final EnumFacing side, final float hitX, final float hitY, final float hitZ ) { diff --git a/src/main/java/appeng/block/storage/ChestRendering.java b/src/main/java/appeng/block/storage/ChestRendering.java new file mode 100644 index 000000000..255847224 --- /dev/null +++ b/src/main/java/appeng/block/storage/ChestRendering.java @@ -0,0 +1,23 @@ +package appeng.block.storage; + + +import appeng.api.util.AEColor; +import appeng.bootstrap.BlockRenderingCustomizer; +import appeng.bootstrap.IBlockRendering; +import appeng.bootstrap.IItemRendering; +import appeng.client.render.ColorableTileBlockColor; +import appeng.client.render.StaticItemColor; + + +public class ChestRendering extends BlockRenderingCustomizer +{ + + @Override + public void customize( IBlockRendering rendering, IItemRendering itemRendering ) + { + // I checked, the ME chest doesn't keep its color in item form + itemRendering.color( new StaticItemColor( AEColor.Transparent ) ); + rendering.blockColor( new ColorableTileBlockColor() ); + } + +} diff --git a/src/main/java/appeng/block/storage/DriveSlotState.java b/src/main/java/appeng/block/storage/DriveSlotState.java index 9c01f92fd..3b8d2521e 100644 --- a/src/main/java/appeng/block/storage/DriveSlotState.java +++ b/src/main/java/appeng/block/storage/DriveSlotState.java @@ -19,25 +19,57 @@ package appeng.block.storage; +import net.minecraft.util.IStringSerializable; + + /** * Describes the different states a single slot of a BlockDrive can be in in terms of rendering. */ -public enum DriveSlotState +public enum DriveSlotState implements IStringSerializable { // No cell in slot - EMPTY, + EMPTY( "empty" ), // Cell in slot, but unpowered - OFFLINE, + OFFLINE( "offline" ), // Online and free space - ONLINE, + ONLINE( "online" ), // Types full, space left - TYPES_FULL, + TYPES_FULL( "types_full" ), // Completely full - FULL + FULL( "full" ); + + private final String name; + + DriveSlotState( String name ) + { + this.name = name; + } + + @Override + public String getName() + { + return name; + } + + public static DriveSlotState fromCellStatus( int cellStatus ) + { + switch( cellStatus ) + { + default: + case 0: + return DriveSlotState.EMPTY; + case 1: + return DriveSlotState.ONLINE; + case 2: + return DriveSlotState.TYPES_FULL; + case 3: + return DriveSlotState.FULL; + } + } } diff --git a/src/main/java/appeng/block/storage/DriveSlotsState.java b/src/main/java/appeng/block/storage/DriveSlotsState.java index d97305b66..0919d1289 100644 --- a/src/main/java/appeng/block/storage/DriveSlotsState.java +++ b/src/main/java/appeng/block/storage/DriveSlotsState.java @@ -70,22 +70,7 @@ public class DriveSlotsState } else { - switch( chestOrDrive.getCellStatus( i ) ) - { - default: - case 0: - slots[i] = DriveSlotState.EMPTY; - break; - case 1: - slots[i] = DriveSlotState.ONLINE; - break; - case 2: - slots[i] = DriveSlotState.TYPES_FULL; - break; - case 3: - slots[i] = DriveSlotState.FULL; - break; - } + slots[i] = DriveSlotState.fromCellStatus( chestOrDrive.getCellStatus( i ) ); } } return new DriveSlotsState( slots ); diff --git a/src/main/java/appeng/core/api/definitions/ApiBlocks.java b/src/main/java/appeng/core/api/definitions/ApiBlocks.java index de6699eca..be86cf654 100644 --- a/src/main/java/appeng/core/api/definitions/ApiBlocks.java +++ b/src/main/java/appeng/core/api/definitions/ApiBlocks.java @@ -75,6 +75,7 @@ import appeng.block.storage.BlockDrive; import appeng.block.storage.BlockIOPort; import appeng.block.storage.BlockSkyChest; import appeng.block.storage.BlockSkyChest.SkyChestType; +import appeng.block.storage.ChestRendering; import appeng.block.storage.DriveRendering; import appeng.block.storage.SkyChestRenderingCustomizer; import appeng.bootstrap.BlockRenderingCustomizer; @@ -288,7 +289,11 @@ public final class ApiBlocks implements IBlocks .useCustomItemModel() .rendering( new DriveRendering() ) .build(); - this.chest = registry.block( "chest", BlockChest::new ).features( AEFeature.StorageCells, AEFeature.MEChest ).build(); + this.chest = registry.block( "chest", BlockChest::new ) + .features( AEFeature.StorageCells, AEFeature.MEChest ) + .useCustomItemModel() + .rendering( new ChestRendering() ) + .build(); this.iface = registry.block( "interface", BlockInterface::new ).build(); this.cellWorkbench = registry.block( "cell_workbench", BlockCellWorkbench::new ).features( AEFeature.StorageCells ).build(); this.iOPort = registry.block( "ioport", BlockIOPort::new ).features( AEFeature.StorageCells, AEFeature.IOPort ).build(); diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/chest.json b/src/main/resources/assets/appliedenergistics2/blockstates/chest.json new file mode 100644 index 000000000..aaf60d704 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/blockstates/chest.json @@ -0,0 +1,60 @@ +{ + "forge_marker": 1, + "defaults": { + "model": "appliedenergistics2:chest/base" + }, + "variants": { + "slot_state": { + "empty": { + "submodel": { + "lights": { + "model": "appliedenergistics2:chest/lights_off" + }, + "state": { + "model": "appliedenergistics2:chest/cell_state_empty" + } + } + }, + "offline": { + "submodel": { + "lights": { + "model": "appliedenergistics2:chest/lights_off" + }, + "state": { + "model": "appliedenergistics2:chest/cell_state_offline" + } + } + }, + "online": { + "submodel": { + "lights": { + "model": "appliedenergistics2:chest/lights_on" + }, + "state": { + "model": "appliedenergistics2:chest/cell_state_online" + } + } + }, + "types_full": { + "submodel": { + "lights": { + "model": "appliedenergistics2:chest/lights_on" + }, + "state": { + "model": "appliedenergistics2:chest/cell_state_types_full" + } + } + }, + "full": { + "submodel": { + "lights": { + "model": "appliedenergistics2:chest/lights_on" + }, + "state": { + "model": "appliedenergistics2:chest/cell_state_full" + } + } + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/base.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/base.json new file mode 100644 index 000000000..2caad1c2f --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/base.json @@ -0,0 +1,12 @@ +{ + "parent": "block/cube", + "textures": { + "particle": "appliedenergistics2:blocks/chest/side", + "up": "appliedenergistics2:blocks/chest/top", + "down": "appliedenergistics2:blocks/chest/bottom", + "north": "appliedenergistics2:blocks/chest/front", + "east": "appliedenergistics2:blocks/chest/side", + "south": "appliedenergistics2:blocks/chest/side", + "west": "appliedenergistics2:blocks/chest/side" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_empty.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_empty.json new file mode 100644 index 000000000..8e44b7dc6 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_empty.json @@ -0,0 +1,14 @@ +{ + "textures": { + "state": "appliedenergistics2:blocks/chest/cell_state_empty" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"texture": "#state"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_full.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_full.json new file mode 100644 index 000000000..5f2d8a05e --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_full.json @@ -0,0 +1,23 @@ +{ + "uvlMarker": true, + "textures": { + "backdrop": "appliedenergistics2:blocks/chest/cell_state_backdrop", + "state": "appliedenergistics2:blocks/chest/cell_state_full" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"texture": "#backdrop" } + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"texture": "#state", "uvlightmap": { "block": 0.007, "sky": 0.007 }} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_offline.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_offline.json new file mode 100644 index 000000000..7a697043e --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_offline.json @@ -0,0 +1,14 @@ +{ + "textures": { + "state": "appliedenergistics2:blocks/chest/cell_state_offline" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"texture": "#state"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_online.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_online.json new file mode 100644 index 000000000..23f57823b --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_online.json @@ -0,0 +1,23 @@ +{ + "uvlMarker": true, + "textures": { + "backdrop": "appliedenergistics2:blocks/chest/cell_state_backdrop", + "state": "appliedenergistics2:blocks/chest/cell_state_online" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"texture": "#backdrop" } + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"texture": "#state", "uvlightmap": { "block": 0.007, "sky": 0.007 }} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_types_full.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_types_full.json new file mode 100644 index 000000000..f438c274c --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/cell_state_types_full.json @@ -0,0 +1,23 @@ +{ + "uvlMarker": true, + "textures": { + "backdrop": "appliedenergistics2:blocks/chest/cell_state_backdrop", + "state": "appliedenergistics2:blocks/chest/cell_state_types_full" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"texture": "#backdrop" } + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "north": {"texture": "#state", "uvlightmap": { "block": 0.007, "sky": 0.007 }} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_off.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_off.json new file mode 100644 index 000000000..ed2c7dd52 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_off.json @@ -0,0 +1,14 @@ +{ + "textures": { + "lights": "appliedenergistics2:blocks/chest/lights_off" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": { "texture": "#lights", "tintindex": 0 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_on.json b/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_on.json new file mode 100644 index 000000000..8f88855a3 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/chest/lights_on.json @@ -0,0 +1,31 @@ +{ + "uvlMarker": true, + "textures": { + "lights_bright": "appliedenergistics2:blocks/chest/lights_on_bright", + "lights_medium": "appliedenergistics2:blocks/chest/lights_on_medium", + "lights_dark": "appliedenergistics2:blocks/chest/lights_on_dark" + }, + "elements": [ + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": {"texture": "#lights_bright", "tintindex": 0, "uvlightmap": { "block": 0.007, "sky": 0.007 }} + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": {"texture": "#lights_medium", "tintindex": 1, "uvlightmap": { "block": 0.007, "sky": 0.007 }} + } + }, + { + "from": [0, 0, 0], + "to": [16, 16, 16], + "faces": { + "up": {"texture": "#lights_dark", "tintindex": 2, "uvlightmap": { "block": 0.007, "sky": 0.007 }} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/item/chest.json b/src/main/resources/assets/appliedenergistics2/models/item/chest.json new file mode 100644 index 000000000..f7828b1e0 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/item/chest.json @@ -0,0 +1,11 @@ +{ + "parent": "block/cube", + "textures": { + "up": "appliedenergistics2:blocks/chest/top_item", + "down": "appliedenergistics2:blocks/chest/bottom", + "north": "appliedenergistics2:blocks/chest/front_item", + "east": "appliedenergistics2:blocks/chest/side", + "south": "appliedenergistics2:blocks/chest/side", + "west": "appliedenergistics2:blocks/chest/side" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/bottom.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/bottom.png new file mode 100644 index 000000000..6a87e174a Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/bottom.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_backdrop.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_backdrop.png new file mode 100644 index 000000000..e4f5021bb Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_backdrop.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_empty.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_empty.png new file mode 100644 index 000000000..cd3a27a73 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_empty.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_full.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_full.png new file mode 100644 index 000000000..cf4564d9e Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_full.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_offline.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_offline.png new file mode 100644 index 000000000..49a22b659 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_offline.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_online.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_online.png new file mode 100644 index 000000000..f57be58e1 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_online.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_types_full.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_types_full.png new file mode 100644 index 000000000..4c9492315 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/cell_state_types_full.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/front.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/front.png new file mode 100644 index 000000000..4e4e034e9 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/front.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/front_item.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/front_item.png new file mode 100644 index 000000000..5545360ad Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/front_item.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_off.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_off.png new file mode 100644 index 000000000..9a6c4e8c5 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_off.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_on_bright.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_on_bright.png new file mode 100644 index 000000000..7bc5a1597 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_on_bright.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_on_dark.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_on_dark.png new file mode 100644 index 000000000..2ab98bae0 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_on_dark.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_on_medium.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_on_medium.png new file mode 100644 index 000000000..d8789f24b Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/lights_on_medium.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/side.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/side.png new file mode 100644 index 000000000..d95e8e8a5 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/side.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/top.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/top.png new file mode 100644 index 000000000..a05c40626 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/top.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/top_item.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/top_item.png new file mode 100644 index 000000000..b7c66998f Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/blocks/chest/top_item.png differ