From 7ba899b576e5176d93a06b98019a2272fc1ab714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 10 Jul 2016 15:28:59 +0200 Subject: [PATCH] Quicksand that can replace dirt or grass --- src/java/mmm/materials/MSwampPit.java | 88 ++++++++++++++++++ src/java/mmm/materials/MTraps.java | 2 + .../blockstates/materials/trap/swamp_pit.json | 5 + .../block/materials/trap/swamp_pit.json | 21 +++++ .../models/item/materials/trap/swamp_pit.json | 3 + .../blocks/materials/trap/swamp_pit.png | Bin 0 -> 661 bytes 6 files changed, 119 insertions(+) create mode 100644 src/java/mmm/materials/MSwampPit.java create mode 100644 src/resources/assets/mmm/blockstates/materials/trap/swamp_pit.json create mode 100644 src/resources/assets/mmm/models/block/materials/trap/swamp_pit.json create mode 100644 src/resources/assets/mmm/models/item/materials/trap/swamp_pit.json create mode 100644 src/resources/assets/mmm/textures/blocks/materials/trap/swamp_pit.png diff --git a/src/java/mmm/materials/MSwampPit.java b/src/java/mmm/materials/MSwampPit.java new file mode 100644 index 0000000..7531bad --- /dev/null +++ b/src/java/mmm/materials/MSwampPit.java @@ -0,0 +1,88 @@ +package mmm.materials; + + +import mmm.utils.I_UTintedBlock; +import mmm.utils.I_UTintedItem; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.color.IBlockColor; +import net.minecraft.client.renderer.color.IItemColor; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.ColorizerGrass; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.biome.BiomeColorHelper; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + + + +public class MSwampPit + extends MQuicksand + implements I_UTintedBlock , I_UTintedItem +{ + + public MSwampPit( ) + { + super( "swamp_pit" , Blocks.GRASS.getDefaultState( ) ); + } + + + @Override + public IBlockState[] getReplacedBlocks( ) + { + return new IBlockState[] { + this.forType , Blocks.DIRT.getDefaultState( ) + }; + } + + + @Override + public boolean canSustainPlant( IBlockState state , IBlockAccess world , BlockPos pos , EnumFacing direction , + IPlantable plantable ) + { + return false; + } + + + @Override + @SideOnly( Side.CLIENT ) + public IBlockColor getBlockTint( ) + { + return new IBlockColor( ) { + + @Override + public int colorMultiplier( final IBlockState state , final IBlockAccess worldIn , final BlockPos pos , + final int tintIndex ) + { + final boolean inWorld = worldIn != null && pos != null; + final int baseTint = inWorld + ? BiomeColorHelper.getGrassColorAtPos( worldIn , pos ) + : ColorizerGrass.getGrassColor( .5f , .5f ); + return baseTint; + } + + }; + } + + + @Override + @SideOnly( Side.CLIENT ) + public IItemColor getItemTint( ) + { + final IBlockColor bTint = this.getBlockTint( ); + final IBlockState ds = this.getDefaultState( ); + return new IItemColor( ) { + + @Override + public int getColorFromItemstack( final ItemStack stack , final int tintIndex ) + { + return bTint.colorMultiplier( ds , null , null , tintIndex ); + } + + }; + } + +} diff --git a/src/java/mmm/materials/MTraps.java b/src/java/mmm/materials/MTraps.java index 6f1b2df..7ddd265 100644 --- a/src/java/mmm/materials/MTraps.java +++ b/src/java/mmm/materials/MTraps.java @@ -11,6 +11,7 @@ public class MTraps { public final MQuicksand QUICKSAND; public final MQuicksand RED_QUICKSAND; + public final MSwampPit SWAMP_PIT; public final MMud MUD; @@ -23,6 +24,7 @@ public class MTraps URegistry.addBlock( this.RED_QUICKSAND = new MQuicksand( "red_sand" , // Blocks.SAND.getDefaultState( ) // .withProperty( BlockSand.VARIANT , BlockSand.EnumType.RED_SAND ) ) ); + URegistry.addBlock( this.SWAMP_PIT = new MSwampPit( ) ); URegistry.addBlock( this.MUD = new MMud( ) ); } } diff --git a/src/resources/assets/mmm/blockstates/materials/trap/swamp_pit.json b/src/resources/assets/mmm/blockstates/materials/trap/swamp_pit.json new file mode 100644 index 0000000..57c5d4d --- /dev/null +++ b/src/resources/assets/mmm/blockstates/materials/trap/swamp_pit.json @@ -0,0 +1,5 @@ +{ + "variants": { + "normal": { "model": "mmm:materials/trap/swamp_pit" } + } +} diff --git a/src/resources/assets/mmm/models/block/materials/trap/swamp_pit.json b/src/resources/assets/mmm/models/block/materials/trap/swamp_pit.json new file mode 100644 index 0000000..0632966 --- /dev/null +++ b/src/resources/assets/mmm/models/block/materials/trap/swamp_pit.json @@ -0,0 +1,21 @@ +{ + "parent": "minecraft:block/grass", + "textures": { + "particle": "minecraft:blocks/dirt", + "all": "mmm:blocks/materials/trap/swamp_pit" + } , + "elements": [ + { + "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "down", "tintindex": 0 }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "up", "tintindex": 0 }, + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "north", "tintindex": 0 }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "south", "tintindex": 0 }, + "west": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "west", "tintindex": 0 }, + "east": { "uv": [ 0, 0, 16, 16 ], "texture": "#all", "cullface": "east", "tintindex": 0 } + } + } + ] +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/trap/swamp_pit.json b/src/resources/assets/mmm/models/item/materials/trap/swamp_pit.json new file mode 100644 index 0000000..96df940 --- /dev/null +++ b/src/resources/assets/mmm/models/item/materials/trap/swamp_pit.json @@ -0,0 +1,3 @@ +{ + "parent": "mmm:block/materials/trap/swamp_pit" +} \ No newline at end of file diff --git a/src/resources/assets/mmm/textures/blocks/materials/trap/swamp_pit.png b/src/resources/assets/mmm/textures/blocks/materials/trap/swamp_pit.png new file mode 100644 index 0000000000000000000000000000000000000000..049004d8ffdf7465de88aee67264a5d55734a702 GIT binary patch literal 661 zcmV;G0&4w+QN#r_MQ5 zZHz`EdB5K>7!0IbF6-0jbR?h8ORZLua5yXgOy`J>@eQnliwWMCJYn`#%?eq``1myGc zQydP5#9}c;ryGDUSuU5_xl*Y}JRaBh^Z68m7iiNRT3)YLet&-@olYxoBofgA*uV@) z#bQwohl6CZSuwWTt!m@n?RHBv8Wnu0R;!wHy2xX^ifLqUu~;l*yH&rO z{a#J)cDrKmgQJ*)b{s}4XG{eMc^HXt#D~M7dUQUY#Q+rskH;RMj!DS|Kxm+|EPmpC!0#9JVy?zT^zFsdaX5LJKB0e5-kvOx$EFC)lEBsIi v1fWKck?|$6WhMZ!kONcXu{-3iRx9}jp%r&>1SuGp00000NkvXXu0mjfUH%%K literal 0 HcmV?d00001