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 0000000..ce5d66e Binary files /dev/null and b/src/resources/assets/mmm/textures/blocks/materials/trap/mud.png differ