From b28d4689359f3b63a71ac4981188a30f1a5c8c53 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Fri, 26 Aug 2016 13:59:59 +0200 Subject: [PATCH] Implemented security station rendering. --- .../block/misc/BlockSecurityStation.java | 27 ++++++++++ .../block/misc/SecurityStationRendering.java | 25 +++++++++ .../core/api/definitions/ApiBlocks.java | 6 ++- .../blockstates/security_station.json | 11 ++-- .../models/block/security_station.json | 8 --- .../models/block/security_station_off.json | 47 +++++++++++++++++ .../models/block/security_station_on.json | 48 ++++++++++++++++++ .../blocks/security_station_light_bright.png | Bin 0 -> 223 bytes .../blocks/security_station_light_dark.png | Bin 0 -> 208 bytes .../blocks/security_station_light_medium.png | Bin 0 -> 216 bytes ...y_station.png => security_station_top.png} | Bin 11 files changed, 157 insertions(+), 15 deletions(-) create mode 100644 src/main/java/appeng/block/misc/SecurityStationRendering.java delete mode 100644 src/main/resources/assets/appliedenergistics2/models/block/security_station.json create mode 100644 src/main/resources/assets/appliedenergistics2/models/block/security_station_off.json create mode 100644 src/main/resources/assets/appliedenergistics2/models/block/security_station_on.json create mode 100644 src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_light_bright.png create mode 100644 src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_light_dark.png create mode 100644 src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_light_medium.png rename src/main/resources/assets/appliedenergistics2/textures/blocks/{security_station.png => security_station_top.png} (100%) diff --git a/src/main/java/appeng/block/misc/BlockSecurityStation.java b/src/main/java/appeng/block/misc/BlockSecurityStation.java index cdf2f8ac..00d7624c 100644 --- a/src/main/java/appeng/block/misc/BlockSecurityStation.java +++ b/src/main/java/appeng/block/misc/BlockSecurityStation.java @@ -22,12 +22,16 @@ package appeng.block.misc; import javax.annotation.Nullable; import net.minecraft.block.material.Material; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyBool; +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.util.AEPartLocation; @@ -39,11 +43,20 @@ import appeng.util.Platform; public class BlockSecurityStation extends AEBaseTileBlock { + private static final PropertyBool POWERED = PropertyBool.create( "powered" ); + public BlockSecurityStation() { super( Material.IRON ); this.setTileEntity( TileSecurityStation.class ); + this.setDefaultState( getDefaultState().withProperty( POWERED, false ) ); + } + + @Override + protected IProperty[] getAEStates() + { + return new IProperty[] { POWERED }; } @Override @@ -52,6 +65,20 @@ public class BlockSecurityStation extends AEBaseTileBlock return BlockRenderLayer.CUTOUT; } + @Override + public IBlockState getActualState( IBlockState state, IBlockAccess world, BlockPos pos ) + { + boolean powered = false; + TileSecurityStation te = getTileEntity( world, pos ); + if( te != null ) + { + powered = te.isActive(); + } + + return super.getActualState( state, world, pos ) + .withProperty( POWERED, powered ); + } + @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/misc/SecurityStationRendering.java b/src/main/java/appeng/block/misc/SecurityStationRendering.java new file mode 100644 index 00000000..e54b07aa --- /dev/null +++ b/src/main/java/appeng/block/misc/SecurityStationRendering.java @@ -0,0 +1,25 @@ +package appeng.block.misc; + + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +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 SecurityStationRendering extends BlockRenderingCustomizer +{ + + @Override + @SideOnly( Side.CLIENT ) + public void customize( IBlockRendering rendering, IItemRendering itemRendering ) + { + rendering.blockColor( ColorableTileBlockColor.INSTANCE ); + itemRendering.color( new StaticItemColor( AEColor.Transparent ) ); + } +} diff --git a/src/main/java/appeng/core/api/definitions/ApiBlocks.java b/src/main/java/appeng/core/api/definitions/ApiBlocks.java index d5d49800..c3df218c 100644 --- a/src/main/java/appeng/core/api/definitions/ApiBlocks.java +++ b/src/main/java/appeng/core/api/definitions/ApiBlocks.java @@ -52,6 +52,7 @@ import appeng.block.misc.BlockSecurityStation; import appeng.block.misc.BlockSkyCompass; import appeng.block.misc.BlockTinyTNT; import appeng.block.misc.BlockVibrationChamber; +import appeng.block.misc.SecurityStationRendering; import appeng.block.misc.SkyCompassRendering; import appeng.block.networking.BlockCableBus; import appeng.block.networking.BlockController; @@ -265,7 +266,10 @@ public final class ApiBlocks implements IBlocks BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject( item, new DispenserBehaviorTinyTNT() ); } ) .build(); - this.securityStation = registry.block( "security_station", BlockSecurityStation::new ).features( AEFeature.Security ).build(); + this.securityStation = registry.block( "security_station", BlockSecurityStation::new ) + .features( AEFeature.Security ) + .rendering( new SecurityStationRendering() ) + .build(); this.quantumRing = registry.block( "quantum_ring", BlockQuantumRing::new ).features( AEFeature.QuantumNetworkBridge ).build(); this.quantumLink = registry.block( "quantum_link", BlockQuantumLinkChamber::new ).features( AEFeature.QuantumNetworkBridge ).build(); this.spatialPylon = registry.block( "spatial_pylon", BlockSpatialPylon::new ).features( AEFeature.SpatialIO ).build(); diff --git a/src/main/resources/assets/appliedenergistics2/blockstates/security_station.json b/src/main/resources/assets/appliedenergistics2/blockstates/security_station.json index 93633894..cfebf8c3 100644 --- a/src/main/resources/assets/appliedenergistics2/blockstates/security_station.json +++ b/src/main/resources/assets/appliedenergistics2/blockstates/security_station.json @@ -1,7 +1,6 @@ { - "variants": { - "normal": { - "model": "appliedenergistics2:security_station" - } - } -} \ No newline at end of file + "variants": { + "powered=false": { "model": "appliedenergistics2:security_station_off" }, + "powered=true": { "model": "appliedenergistics2:security_station_on" } + } +} diff --git a/src/main/resources/assets/appliedenergistics2/models/block/security_station.json b/src/main/resources/assets/appliedenergistics2/models/block/security_station.json deleted file mode 100644 index c375fa85..00000000 --- a/src/main/resources/assets/appliedenergistics2/models/block/security_station.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "parent": "block/cube_bottom_top", - "textures": { - "bottom": "appliedenergistics2:blocks/security_station_bottom", - "side": "appliedenergistics2:blocks/security_station_side", - "top": "appliedenergistics2:blocks/security_station" - } -} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/security_station_off.json b/src/main/resources/assets/appliedenergistics2/models/block/security_station_off.json new file mode 100644 index 00000000..19c02a10 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/security_station_off.json @@ -0,0 +1,47 @@ +{ + "parent": "block/block", + "textures": { + "particle": "appliedenergistics2:blocks/security_station_side", + "side": "appliedenergistics2:blocks/security_station_side", + "bottom": "appliedenergistics2:blocks/security_station_bottom", + "top": "appliedenergistics2:blocks/security_station_top", + "lightsBright": "appliedenergistics2:blocks/security_station_light_bright", + "lightsMedium": "appliedenergistics2:blocks/security_station_light_medium", + "lightsDark": "appliedenergistics2:blocks/security_station_light_dark" + }, + "elements": [ + { + "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "texture": "#bottom" }, + "up": { "texture": "#top"}, + "north": { "texture": "#side"}, + "south": { "texture": "#side"}, + "west": { "texture": "#side"}, + "east": { "texture": "#side"} + } + }, + { + "from": [ 0, 15, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "up": { "texture": "#lightsBright", "tintindex": 0 } + } + }, + { + "from": [ 0, 15, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "up": { "texture": "#lightsMedium", "tintindex": 1 } + } + }, + { + "from": [ 0, 15, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "up": { "texture": "#lightsDark", "tintindex": 2 } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/models/block/security_station_on.json b/src/main/resources/assets/appliedenergistics2/models/block/security_station_on.json new file mode 100644 index 00000000..0a3c1406 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/block/security_station_on.json @@ -0,0 +1,48 @@ +{ + "uvlMarker": true, + "parent": "block/block", + "textures": { + "particle": "appliedenergistics2:blocks/security_station_side", + "side": "appliedenergistics2:blocks/security_station_side", + "bottom": "appliedenergistics2:blocks/security_station_bottom", + "top": "appliedenergistics2:blocks/security_station_top", + "lightsBright": "appliedenergistics2:blocks/security_station_light_bright", + "lightsMedium": "appliedenergistics2:blocks/security_station_light_medium", + "lightsDark": "appliedenergistics2:blocks/security_station_light_dark" + }, + "elements": [ + { + "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "texture": "#bottom" }, + "up": { "texture": "#top"}, + "north": { "texture": "#side"}, + "south": { "texture": "#side"}, + "west": { "texture": "#side"}, + "east": { "texture": "#side"} + } + }, + { + "from": [ 0, 15, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "up": { "texture": "#lightsBright", "tintindex": 0, "uvlightmap": { "sky": 0.007, "block": 0.007 } } + } + }, + { + "from": [ 0, 15, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "up": { "texture": "#lightsMedium", "tintindex": 1, "uvlightmap": { "sky": 0.007, "block": 0.007 } } + } + }, + { + "from": [ 0, 15, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "up": { "texture": "#lightsDark", "tintindex": 2, "uvlightmap": { "sky": 0.007, "block": 0.007 } } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_light_bright.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_light_bright.png new file mode 100644 index 0000000000000000000000000000000000000000..bd7939eadd9c998812d4b93cb59f625fc1a9abe2 GIT binary patch literal 223 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+K$tP>S|=w^P^`o?q9iy!t)x7$D3zfgF*C13FE6!3!9>r%`o-5wpo(};7sn6_ z|E1lITnvspho1eP|L)b=iE>t(8x^?bt@`!U;+{pH`Lhj-@*Bsfo${@^%qS$fung?oUy`X1l2l6R4^`1D|Zn+4D+ N22WQ%mvv4FO#l#LOf&!h literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_light_dark.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_light_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..418494a2e5df3a907891af1308168b6ddf1fd228 GIT binary patch literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DkxL735kHCP2GC|2ScQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`PW{o-pTP(^^Ji(`m| z|I(9=Tn7wzm=FH@e_78;<%z+C4z6bpz8V|vH!zcs?vdYAJHKBwI37er-`scp_@tG> v$c`rWmihJY9`%_ERKgTe~DWM4f8)8I1 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_light_medium.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_light_medium.png new file mode 100644 index 0000000000000000000000000000000000000000..9f45ae06008b3d42afae13566a97d88e3e0e0ee2 GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DkxL735kHCP2GC|2ScQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`PW{o-pTP(_5Ni(`m| z|I#i;E(Svm=HLJQqg$kooJ-uy%X7p~TWOxd%Z5vgOPNnGKfM)ui1le>P@J`BbI-ef zGXhR!FHf3q@vgkESLNFf9;02qlbtlz&pj0%V71_n-x}WQr)2rMJ&%?H?O^b9^>bP0 Hl+XkK__;@e literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/appliedenergistics2/textures/blocks/security_station.png b/src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_top.png similarity index 100% rename from src/main/resources/assets/appliedenergistics2/textures/blocks/security_station.png rename to src/main/resources/assets/appliedenergistics2/textures/blocks/security_station_top.png