Split mud and quicksand into separate classes (they really have little in common

This commit is contained in:
Cheeserolls 2015-06-11 11:27:44 +01:00
parent 4cdbc7c294
commit 63fe140915
12 changed files with 181 additions and 53 deletions

View file

@ -106,6 +106,7 @@ public class BOPBlocks
public static Block mud;
public static Block sand;
public static Block turnip_block;
public static Block flesh;
public static Block grass;

View file

@ -10,7 +10,6 @@ package biomesoplenty.common.biome.overworld;
import net.minecraft.block.BlockDoublePlant;
import net.minecraft.block.BlockTallGrass;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.monster.EntitySlime;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.BiomeManager.BiomeType;
@ -22,7 +21,6 @@ import biomesoplenty.common.block.BlockBOPDirt;
import biomesoplenty.common.block.BlockBOPGrass;
import biomesoplenty.common.block.BlockBOPLilypad;
import biomesoplenty.common.block.BlockBOPCoral;
import biomesoplenty.common.block.BlockBOPMud;
import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.util.biome.GeneratorUtils.ScatterYMethod;
@ -48,10 +46,9 @@ public class BiomeGenMarsh extends BOPBiome
this.sidewaysNoiseAmount = 0.0D;
this.setOctaveWeights(5, 5, 0, 0, 1, 1);
IBlockState mud = BOPBlocks.mud.getDefaultState().withProperty(BlockBOPMud.VARIANT, BlockBOPMud.MudType.MUD);
this.topBlock = BOPBlocks.grass.getDefaultState().withProperty(BlockBOPGrass.VARIANT, BlockBOPGrass.BOPGrassType.SILTY);
this.fillerBlock = BOPBlocks.dirt.getDefaultState().withProperty(BlockBOPDirt.VARIANT, BlockBOPDirt.BOPDirtType.SILTY);
this.seaFloorBlock = mud;
this.seaFloorBlock = BOPBlocks.mud.getDefaultState();
this.setColor(0x66A06E);
this.setTemperatureRainfall(0.5F, 0.9F);
@ -64,8 +61,8 @@ public class BiomeGenMarsh extends BOPBiome
// TODO: find a way to make the lakes shallower
// mud
this.addGenerator("mud", GeneratorStage.SAND_PASS2, (new GeneratorWaterside.Builder()).amountPerChunk(8).maxRadius(7).with(mud).create());
this.addGenerator("mud_patches", GeneratorStage.SAND_PASS2, (new GeneratorSplotches.Builder()).amountPerChunk(1).splotchSize(12).replace(this.topBlock).with(mud).scatterYMethod(ScatterYMethod.AT_SURFACE).create());
this.addGenerator("mud", GeneratorStage.SAND_PASS2, (new GeneratorWaterside.Builder()).amountPerChunk(8).maxRadius(7).with(BOPBlocks.mud.getDefaultState()).create());
this.addGenerator("mud_patches", GeneratorStage.SAND_PASS2, (new GeneratorSplotches.Builder()).amountPerChunk(1).splotchSize(12).replace(this.topBlock).with(BOPBlocks.mud.getDefaultState()).scatterYMethod(ScatterYMethod.AT_SURFACE).create());
// other plants
this.addGenerator("koru", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(0.1F).with(BOPPlants.KORU).create());

View file

@ -20,7 +20,6 @@ import biomesoplenty.common.block.BlockBOPDirt;
import biomesoplenty.common.block.BlockBOPDoublePlant;
import biomesoplenty.common.block.BlockBOPGrass;
import biomesoplenty.common.block.BlockBOPCoral;
import biomesoplenty.common.block.BlockBOPMud;
import biomesoplenty.common.enums.BOPFlowers;
import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPPlants;
@ -50,7 +49,7 @@ public class BiomeGenMoor extends BOPBiome
this.spawnableWaterCreatureList.clear();
// mud
this.addGenerator("mud", GeneratorStage.SAND_PASS2, (new GeneratorWaterside.Builder()).amountPerChunk(1).maxRadius(7).with(BOPBlocks.mud.getDefaultState().withProperty(BlockBOPMud.VARIANT, BlockBOPMud.MudType.MUD)).create());
this.addGenerator("mud", GeneratorStage.SAND_PASS2, (new GeneratorWaterside.Builder()).amountPerChunk(1).maxRadius(7).with(BOPBlocks.mud.getDefaultState()).create());
// lakes
this.addGenerator("lakes", GeneratorStage.SAND, (new GeneratorLakes.Builder()).amountPerChunk(1.5F).waterLakeForBiome(this).create());

View file

@ -246,7 +246,7 @@ public class BlockBOPFlower extends BlockBOPDecoration
Block groundBlock = groundState.getBlock();
boolean onFertile = (groundBlock == Blocks.dirt || groundBlock == Blocks.farmland || groundBlock == BOPBlocks.dirt || groundBlock == Blocks.grass);
boolean onDry = (groundBlock == BOPBlocks.hard_dirt || groundBlock == Blocks.hardened_clay || groundBlock == Blocks.sand || groundBlock == BOPBlocks.hard_sand);
boolean onDry = (groundBlock == BOPBlocks.hard_dirt || groundBlock == Blocks.hardened_clay || groundBlock == BOPBlocks.sand || groundBlock == Blocks.sand || groundBlock == BOPBlocks.hard_sand);
boolean onNetherrack = (groundBlock == Blocks.netherrack);
boolean onStone = (groundBlock == Blocks.stone);
boolean onSpectralMoss = false;

View file

@ -37,7 +37,7 @@ public class BlockBOPMud extends Block implements IBOPBlock
// add properties
public static enum MudType implements IStringSerializable
{
MUD, QUICKSAND;
MUD;
@Override
public String getName()
{
@ -71,11 +71,12 @@ public class BlockBOPMud extends Block implements IBOPBlock
public BlockBOPMud() {
super(Material.sand);
// TODO: use a custom material and sount type for mud? A squelching sound?
super(Material.ground);
// set some defaults
this.setHardness(0.6F);
this.setStepSound(Block.soundTypeSand);
this.setStepSound(Block.soundTypeGrass);
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, MudType.MUD) );
}
@ -96,7 +97,7 @@ public class BlockBOPMud extends Block implements IBOPBlock
@Override
public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state)
{
float heightOffset = 0.0F;
float heightOffset;
switch ((MudType) state.getValue(VARIANT))
{
// sink a little when standing on mud
@ -104,9 +105,9 @@ public class BlockBOPMud extends Block implements IBOPBlock
heightOffset = 0.35F;
break;
// no bounding box at all for quicksand - you're supposed to sink into it
case QUICKSAND:
return null;
default:
heightOffset = 0.0F;
break;
}
return new AxisAlignedBB((double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), (double) (pos.getX() + 1), (double) ((float) (pos.getY() + 1) - heightOffset), (double) (pos.getZ() + 1));
}
@ -129,26 +130,16 @@ public class BlockBOPMud extends Block implements IBOPBlock
entity.motionZ *= 0.1D;
break;
// quicksand behaves like being trapped in a spider web
case QUICKSAND:
entity.setInWeb();
default:
break;
}
}
// drop 4 balls of the item instead of one block
// drop 4 balls of mud instead of one block
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
switch ((MudType) state.getValue(VARIANT))
{
case MUD:
return BOPItems.mudball;
case QUICKSAND:
break;
}
return super.getItemDropped(state,rand,fortune);
return BOPItems.mudball;
}
@Override
@ -161,29 +152,19 @@ public class BlockBOPMud extends Block implements IBOPBlock
@Override
public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable)
{
IBlockState state = world.getBlockState(pos);
net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));
MudType mudType = (MudType) state.getValue(VARIANT);
switch (plantType)
{
case Desert:
return (mudType == MudType.QUICKSAND);
case Plains:
return (mudType == MudType.MUD);
return true;
case Beach:
if (mudType == MudType.QUICKSAND)
{
return (
world.getBlockState(pos.east()).getBlock().getMaterial() == Material.water ||
world.getBlockState(pos.west()).getBlock().getMaterial() == Material.water ||
world.getBlockState(pos.north()).getBlock().getMaterial() == Material.water ||
world.getBlockState(pos.south()).getBlock().getMaterial() == Material.water
);
} else {
return false;
}
return (
world.getBlockState(pos.east()).getBlock().getMaterial() == Material.water ||
world.getBlockState(pos.west()).getBlock().getMaterial() == Material.water ||
world.getBlockState(pos.north()).getBlock().getMaterial() == Material.water ||
world.getBlockState(pos.south()).getBlock().getMaterial() == Material.water
);
// don't support anything else by default
default:
return false;

View file

@ -378,9 +378,9 @@ public class BlockBOPPlant extends BlockBOPDecoration implements IShearable
// That looks bonkers to me, so I'm ignoring it for now - need to ask the others
boolean onFertile = (adjacentBlock == Blocks.dirt || adjacentBlock == BOPBlocks.dirt || adjacentBlock == Blocks.mycelium || adjacentBlock == Blocks.grass);
boolean onMud = (adjacentBlock == BOPBlocks.mud && adjacentBlockState.getValue(BlockBOPMud.VARIANT) == BlockBOPMud.MudType.MUD);
boolean onDry = (adjacentBlock == BOPBlocks.hard_dirt || adjacentBlock == Blocks.hardened_clay || adjacentBlock == Blocks.sand || adjacentBlock == BOPBlocks.hard_sand || adjacentBlock == Blocks.soul_sand);
boolean onSand = (adjacentBlock == Blocks.sand || adjacentBlock == Blocks.soul_sand);
boolean onMud = (adjacentBlock == BOPBlocks.mud);
boolean onDry = (adjacentBlock == BOPBlocks.hard_dirt || adjacentBlock == Blocks.hardened_clay || adjacentBlock == Blocks.sand || adjacentBlock == BOPBlocks.sand || adjacentBlock == BOPBlocks.hard_sand || adjacentBlock == Blocks.soul_sand);
boolean onSand = (adjacentBlock == Blocks.sand || adjacentBlock == BOPBlocks.sand || adjacentBlock == Blocks.soul_sand);
boolean onGrass = (adjacentBlock == Blocks.grass);
boolean onSpectralMoss = false;

View file

@ -0,0 +1,145 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemBlock;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import biomesoplenty.api.block.IBOPBlock;
import biomesoplenty.common.item.ItemBOPBlock;
public class BlockBOPSand extends BlockFalling implements IBOPBlock
{
// add properties
public static enum SandType implements IStringSerializable
{
QUICKSAND;
@Override
public String getName()
{
return this.name().toLowerCase();
}
@Override
public String toString()
{
return this.getName();
}
};
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", SandType.class);
@Override
protected BlockState createBlockState() {return new BlockState(this, new IProperty[] { VARIANT });}
// implement IBOPBlock
@Override
public Class<? extends ItemBlock> getItemClass() { return ItemBOPBlock.class; }
@Override
public int getItemRenderColor(IBlockState state, int tintIndex) { return this.getRenderColor(state); }
@Override
public IProperty[] getPresetProperties() { return new IProperty[] {VARIANT}; }
@Override
public IProperty[] getNonRenderingProperties() { return null; }
@Override
public String getStateName(IBlockState state)
{
return ((SandType) state.getValue(VARIANT)).getName();
}
public BlockBOPSand() {
super(Material.sand);
// set some defaults
this.setHardness(0.6F);
this.setStepSound(Block.soundTypeSand);
this.setDefaultState( this.blockState.getBaseState().withProperty(VARIANT, SandType.QUICKSAND) );
}
// map from state to meta and vice verca
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT, SandType.values()[meta]);
}
@Override
public int getMetaFromState(IBlockState state)
{
return ((SandType) state.getValue(VARIANT)).ordinal();
}
@Override
public int damageDropped(IBlockState state)
{
return this.getMetaFromState(state);
}
@Override
public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state)
{
switch ((SandType) state.getValue(VARIANT))
{
// no bounding box for quicksand - you're supposed to sink into it
case QUICKSAND:
return null;
default:
return super.getCollisionBoundingBox(world, pos, state);
}
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{
switch ((SandType) state.getValue(VARIANT))
{
// quicksand behaves like being trapped in a spider web
case QUICKSAND:
entity.setInWeb();
break;
default:
break;
}
}
@Override
public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable)
{
net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));
switch (plantType)
{
case Desert:
return true;
case Beach:
return (
world.getBlockState(pos.east()).getBlock().getMaterial() == Material.water ||
world.getBlockState(pos.west()).getBlock().getMaterial() == Material.water ||
world.getBlockState(pos.north()).getBlock().getMaterial() == Material.water ||
world.getBlockState(pos.south()).getBlock().getMaterial() == Material.water
);
// don't support anything else by default
default:
return false;
}
}
}

View file

@ -137,7 +137,7 @@ public class BlockBOPSeaweed extends BlockBOPDecoration implements IBOPBlock
boolean hasWaterAbove = (blockAbove == Blocks.water || blockAbove == Blocks.flowing_water);
boolean sameSeaweedAbove = ( (blockAbove == this) && ((SeaweedType)state.getValue(VARIANT) == (SeaweedType)stateAbove.getValue(VARIANT)) );
boolean hasEarthBelow = (blockBelow == Blocks.dirt || blockBelow == BOPBlocks.dirt || blockBelow == BOPBlocks.mud || blockBelow == Blocks.sand || blockBelow == Blocks.sponge || blockBelow == Blocks.stone || blockBelow == Blocks.clay || blockBelow == Blocks.gravel);
boolean hasEarthBelow = (blockBelow == Blocks.dirt || blockBelow == BOPBlocks.dirt || blockBelow == BOPBlocks.mud || blockBelow == BOPBlocks.sand || blockBelow == Blocks.sand || blockBelow == Blocks.sponge || blockBelow == Blocks.stone || blockBelow == Blocks.clay || blockBelow == Blocks.gravel);
boolean sameSeaweedBelow = ( (blockBelow == this) && ((SeaweedType)state.getValue(VARIANT) == (SeaweedType)stateBelow.getValue(VARIANT)) );
return (hasWaterAbove || sameSeaweedAbove) && (hasEarthBelow || sameSeaweedBelow);

View file

@ -60,6 +60,7 @@ public class ModBlocks
mushroom = registerBlock( new BlockBOPMushroom(), "mushroom" );
stone = registerBlock( new BlockBOPStone(), "stone" );
mud = registerBlock( new BlockBOPMud(), "mud" );
sand = registerBlock( new BlockBOPSand(), "sand" );
turnip_block = registerBlock( new BlockBOPTurnip(), "turnip_block", null ); // no creative tab
flesh = registerBlock( new BlockBOPFlesh(), "flesh" );
grass = registerBlock( new BlockBOPGrass(), "grass" );

View file

@ -1,6 +1,5 @@
{
"variants": {
"variant=mud": { "model": "biomesoplenty:mud" },
"variant=quicksand": { "model": "biomesoplenty:quicksand" }
"variant=mud": { "model": "biomesoplenty:mud" }
}
}

View file

@ -0,0 +1,5 @@
{
"variants": {
"variant=quicksand": { "model": "biomesoplenty:quicksand" }
}
}

View file

@ -108,7 +108,7 @@ tile.log3.jacaranda.name=Jacaranda Wood
tile.log4.mahogany.name=Mahogany Wood
tile.mud.mud.name=Mud
tile.mud.quicksand.name=Quicksand
tile.sand.quicksand.name=Quicksand
tile.mushroom.toadstool.name=Toadstool
tile.mushroom.portobello.name=Portobello