From ae03058d20165f57d1faa2ee8178b0e6629fd712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 10 Jul 2016 14:43:58 +0200 Subject: [PATCH] Mud trap for swamps and tropical swamps --- src/java/mmm/materials/MMud.java | 63 ++++++++++++++++++ src/java/mmm/materials/MQuicksand.java | 7 +- src/java/mmm/materials/MTraps.java | 7 +- src/java/mmm/utils/I_UTrapBlock.java | 2 +- src/java/mmm/utils/UTrapBlocks.java | 4 +- src/java/mmm/world/biome/WBTropicalSwamp.java | 9 ++- src/java/mmm/world/gen/WGTrapBlocks.java | 5 +- .../mmm/blockstates/materials/trap/mud.json | 5 ++ src/resources/assets/mmm/lang/en_US.lang | 1 + .../mmm/models/block/materials/trap/mud.json | 6 ++ .../mmm/models/item/materials/trap/mud.json | 3 + .../textures/blocks/materials/trap/mud.png | Bin 0 -> 422 bytes 12 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 src/java/mmm/materials/MMud.java create mode 100644 src/resources/assets/mmm/blockstates/materials/trap/mud.json create mode 100644 src/resources/assets/mmm/models/block/materials/trap/mud.json create mode 100644 src/resources/assets/mmm/models/item/materials/trap/mud.json create mode 100644 src/resources/assets/mmm/textures/blocks/materials/trap/mud.png diff --git a/src/java/mmm/materials/MMud.java b/src/java/mmm/materials/MMud.java new file mode 100644 index 0000000..48cb77f --- /dev/null +++ b/src/java/mmm/materials/MMud.java @@ -0,0 +1,63 @@ +package mmm.materials; + + +import mmm.utils.I_UTrapBlock; +import mmm.utils.UMaths; +import mmm.utils.URegistry; +import net.minecraft.block.Block; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + + + +public class MMud + extends Block + implements I_UTrapBlock +{ + private static final AxisAlignedBB MUD_AABB = UMaths.makeBlockAABB( 0 , 0 , 0 , 16 , 15 , 16 ); + + + public MMud( ) + { + super( Material.GROUND ); + this.setHardness( 0.6f ); + this.setHarvestLevel( "shovel" , 0 ); + this.setSoundType( SoundType.GROUND ); + this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); + URegistry.setIdentifiers( this , "materials" , "trap" , "mud" ); + } + + + @Override + public IBlockState[] getReplacedBlocks( ) + { + return new IBlockState[] { + Blocks.DIRT.getDefaultState( ) , Blocks.GRASS.getDefaultState( ) + }; + } + + + @Override + public AxisAlignedBB getCollisionBoundingBox( final IBlockState blockState , final World worldIn , + final BlockPos pos ) + { + return MMud.MUD_AABB; + } + + + @Override + public void onEntityCollidedWithBlock( final World worldIn , final BlockPos pos , final IBlockState state , + final Entity entityIn ) + { + entityIn.motionX *= .1; + entityIn.motionZ *= .1; + } + +} diff --git a/src/java/mmm/materials/MQuicksand.java b/src/java/mmm/materials/MQuicksand.java index 5ade103..b565ecc 100644 --- a/src/java/mmm/materials/MQuicksand.java +++ b/src/java/mmm/materials/MQuicksand.java @@ -34,14 +34,17 @@ public class MQuicksand this.setHardness( .6f ); this.setSoundType( SoundType.SAND ); this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); + this.setHarvestLevel( "shovel" , 0 ); URegistry.setIdentifiers( this , "materials" , "trap" , name ); } @Override - public IBlockState getReplacedBlock( ) + public IBlockState[] getReplacedBlocks( ) { - return this.forType; + return new IBlockState[] { + this.forType + }; } diff --git a/src/java/mmm/materials/MTraps.java b/src/java/mmm/materials/MTraps.java index 4ac2568..6f1b2df 100644 --- a/src/java/mmm/materials/MTraps.java +++ b/src/java/mmm/materials/MTraps.java @@ -11,15 +11,18 @@ public class MTraps { public final MQuicksand QUICKSAND; public final MQuicksand RED_QUICKSAND; + public final MMud MUD; MTraps( ) { - URegistry.addBlock( QUICKSAND = new MQuicksand( "sand" , // + // FIXME recipes to convert quicksand into sand or mud into dirt + URegistry.addBlock( this.QUICKSAND = new MQuicksand( "sand" , // Blocks.SAND.getDefaultState( ) // .withProperty( BlockSand.VARIANT , BlockSand.EnumType.SAND ) ) ); - URegistry.addBlock( RED_QUICKSAND = new MQuicksand( "red_sand" , // + URegistry.addBlock( this.RED_QUICKSAND = new MQuicksand( "red_sand" , // Blocks.SAND.getDefaultState( ) // .withProperty( BlockSand.VARIANT , BlockSand.EnumType.RED_SAND ) ) ); + URegistry.addBlock( this.MUD = new MMud( ) ); } } diff --git a/src/java/mmm/utils/I_UTrapBlock.java b/src/java/mmm/utils/I_UTrapBlock.java index a7c2d4b..a1481c5 100644 --- a/src/java/mmm/utils/I_UTrapBlock.java +++ b/src/java/mmm/utils/I_UTrapBlock.java @@ -8,6 +8,6 @@ import net.minecraft.block.state.IBlockState; public interface I_UTrapBlock { - public IBlockState getReplacedBlock( ); + public IBlockState[] getReplacedBlocks( ); } diff --git a/src/java/mmm/utils/UTrapBlocks.java b/src/java/mmm/utils/UTrapBlocks.java index bbb71cd..1344d3d 100644 --- a/src/java/mmm/utils/UTrapBlocks.java +++ b/src/java/mmm/utils/UTrapBlocks.java @@ -18,7 +18,9 @@ public enum UTrapBlocks { public void register( final I_UTrapBlock block ) { - this.replacements.put( block.getReplacedBlock( ) , ( (Block) block ).getDefaultState( ) ); + for ( IBlockState state : block.getReplacedBlocks( ) ) { + this.replacements.put( state , ( (Block) block ).getDefaultState( ) ); + } } diff --git a/src/java/mmm/world/biome/WBTropicalSwamp.java b/src/java/mmm/world/biome/WBTropicalSwamp.java index aefb30f..7b05ae0 100644 --- a/src/java/mmm/world/biome/WBTropicalSwamp.java +++ b/src/java/mmm/world/biome/WBTropicalSwamp.java @@ -37,7 +37,7 @@ import net.minecraft.world.gen.feature.WorldGenerator; public class WBTropicalSwamp extends Biome - implements I_WBiomeWithOres + implements I_WBiomeWithOres , I_WBTrappedBiome { private static final IBlockState OAK_LOG = Blocks.LOG.getDefaultState( ) // .withProperty( BlockOldLog.VARIANT , BlockPlanks.EnumType.OAK ); @@ -173,4 +173,11 @@ public class WBTropicalSwamp return BlockFlower.EnumFlowerType.BLUE_ORCHID; } + + @Override + public float getTrapBlockChance( ) + { + return .05f; + } + } diff --git a/src/java/mmm/world/gen/WGTrapBlocks.java b/src/java/mmm/world/gen/WGTrapBlocks.java index 805d1c1..67d05b4 100644 --- a/src/java/mmm/world/gen/WGTrapBlocks.java +++ b/src/java/mmm/world/gen/WGTrapBlocks.java @@ -46,11 +46,12 @@ public class WGTrapBlocks final int minDepth = Math.max( 0 , worldIn.getSeaLevel( ) - 20 ); boolean found = false; while ( check.getY( ) > minDepth ) { - final Material material = worldIn.getBlockState( check ).getMaterial( ); + IBlockState bs = worldIn.getBlockState( check ); + final Material material = bs.getMaterial( ); if ( material.isLiquid( ) ) { return false; } - if ( material != Material.AIR ) { + if ( material != Material.AIR && material != Material.WOOD && material != Material.PLANTS ) { found = true; break; } diff --git a/src/resources/assets/mmm/blockstates/materials/trap/mud.json b/src/resources/assets/mmm/blockstates/materials/trap/mud.json new file mode 100644 index 0000000..037cb16 --- /dev/null +++ b/src/resources/assets/mmm/blockstates/materials/trap/mud.json @@ -0,0 +1,5 @@ +{ + "variants": { + "normal": { "model": "mmm:materials/trap/mud" } + } +} diff --git a/src/resources/assets/mmm/lang/en_US.lang b/src/resources/assets/mmm/lang/en_US.lang index d40620e..cfc6043 100644 --- a/src/resources/assets/mmm/lang/en_US.lang +++ b/src/resources/assets/mmm/lang/en_US.lang @@ -76,6 +76,7 @@ tile.mmm.materials.planks.bamboo.name=Bamboo Wood Planks tile.mmm.materials.trap.sand.name=Quicksand tile.mmm.materials.trap.red_sand.name=Red Quicksand +tile.mmm.materials.trap.mud.name=Mud tile.mmm.tech.base.alloy_furnace.inactive.name=Alloy Furnace diff --git a/src/resources/assets/mmm/models/block/materials/trap/mud.json b/src/resources/assets/mmm/models/block/materials/trap/mud.json new file mode 100644 index 0000000..17c390f --- /dev/null +++ b/src/resources/assets/mmm/models/block/materials/trap/mud.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/cube_all", + "textures": { + "all": "mmm:blocks/materials/trap/mud" + } +} \ No newline at end of file diff --git a/src/resources/assets/mmm/models/item/materials/trap/mud.json b/src/resources/assets/mmm/models/item/materials/trap/mud.json new file mode 100644 index 0000000..247e449 --- /dev/null +++ b/src/resources/assets/mmm/models/item/materials/trap/mud.json @@ -0,0 +1,3 @@ +{ + "parent": "mmm:block/materials/trap/mud" +} \ No newline at end of file diff --git a/src/resources/assets/mmm/textures/blocks/materials/trap/mud.png b/src/resources/assets/mmm/textures/blocks/materials/trap/mud.png new file mode 100644 index 0000000000000000000000000000000000000000..ce5d66e4c6027bf5b84e7ba70aff95916f98c114 GIT binary patch literal 422 zcmV;X0a^ZuP)fuRH(%0W(QN zK~y-)by7`B!$1(7KT*-6Hl}DwD^x3?ZL}a*Dx`u?M5wju!GjmSKpMUDANY%(nWYmZ zlkH*H-M7R0m|c20*~ZUx+tn=IbLGPZL9KKzEAfUKbpxN1{aS$uq2BWy7cnsJhgkFi zoP}EjyH(RpxCE!=q~+B9W-*?V5X-bxQ5JRU!VzSXcJ3g+?@b4*X&0A=JEiP89t&B_ z&0v^Y|4xtamL6j<2=Os);ylO1u5XaV5GBh)ua3v0;Z$CR4SbFx*PtgZdmV{18`sxW z6R#HsxR2|OG+W!X&njoqV3rS**Y{C`yVKoLX5FXbc>jUTZgcA>WS>W87GlA56mdts zTv~w}bp#=iJz3C_Y$|b8iokW-k1B(c7``7$wn54b?SOF(wO Q*8l(j07*qoM6N<$g8!nfng9R* literal 0 HcmV?d00001