Make sure all BOP blocks support canSustainPlant() properly
This commit is contained in:
parent
434ef3fdd5
commit
01f2e8a6a9
4 changed files with 62 additions and 26 deletions
|
@ -105,10 +105,9 @@ public class BlockBOPDirt extends Block implements IBOPBlock
|
|||
|
||||
switch (plantType)
|
||||
{
|
||||
// support desert and plains plants
|
||||
case Desert: case Plains: return true;
|
||||
// support cave plants
|
||||
case Cave: return isSideSolid(world, pos, EnumFacing.UP);
|
||||
// support desert, plains and cave plants
|
||||
case Desert: case Plains: case Cave:
|
||||
return true;
|
||||
// support beach plants if there's water alongside
|
||||
case Beach:
|
||||
return (
|
||||
|
|
|
@ -117,12 +117,8 @@ public class BlockBOPGrass extends BlockGrass implements IBOPBlock
|
|||
IBlockState state = world.getBlockState(pos);
|
||||
net.minecraftforge.common.EnumPlantType plantType = plantable.getPlantType(world, pos.offset(direction));
|
||||
|
||||
//Forge calls this method regardless of whether the block is infact ours, so we have to check this
|
||||
//(Somewhat illogical, I know)
|
||||
if (state.getBlock() == this)
|
||||
switch ((BOPGrassType) state.getValue(VARIANT))
|
||||
{
|
||||
switch ((BOPGrassType) state.getValue(VARIANT))
|
||||
{
|
||||
// smoldering grass supports no plants
|
||||
case SMOLDERING:
|
||||
return false;
|
||||
|
@ -137,14 +133,13 @@ public class BlockBOPGrass extends BlockGrass implements IBOPBlock
|
|||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (plantType)
|
||||
{
|
||||
// support desert and plains plants
|
||||
case Desert: case Plains: return true;
|
||||
// support cave plants
|
||||
case Cave: return isSideSolid(world, pos, EnumFacing.UP);
|
||||
switch (plantType)
|
||||
{
|
||||
// support desert, plains and cave plants
|
||||
case Desert: case Plains: case Cave:
|
||||
return true;
|
||||
// support beach plants if there's water alongside
|
||||
case Beach:
|
||||
return (
|
||||
|
@ -156,10 +151,8 @@ public class BlockBOPGrass extends BlockGrass implements IBOPBlock
|
|||
// don't support nether plants, water plants, or crops (require farmland), or anything else by default
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return super.canSustainPlant(world, pos, direction, plantable);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -122,11 +123,6 @@ public class BlockBamboo extends BlockDecoration
|
|||
}
|
||||
}
|
||||
|
||||
@Override public boolean canSustainLeaves(net.minecraft.world.IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Block.EnumOffsetType getOffsetType()
|
||||
|
@ -139,4 +135,18 @@ public class BlockBamboo extends BlockDecoration
|
|||
this.setBlockBoundsByRadiusAndHeight(0.2F, 1.0F);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean canSustainLeaves(net.minecraft.world.IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// bamboo doesn't sustain plants (except more bamboo on top)
|
||||
@Override
|
||||
public boolean canSustainPlant(IBlockAccess world, BlockPos pos, EnumFacing direction, net.minecraftforge.common.IPlantable plantable)
|
||||
{
|
||||
return direction == EnumFacing.UP && plantable.getPlant(world, pos.offset(direction)).getBlock() == this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@ import net.minecraft.item.Item;
|
|||
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.api.item.BOPItems;
|
||||
|
@ -156,4 +158,36 @@ public class BlockMud 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);
|
||||
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;
|
||||
}
|
||||
// don't support anything else by default
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue