More updates, mostly finished with biome configs
This commit is contained in:
parent
603b089a4f
commit
b76b38a28c
8 changed files with 91 additions and 94 deletions
|
@ -63,9 +63,9 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
|
|||
|
||||
public final String idName;
|
||||
|
||||
public BOPBiome(String idName, BiomeProps defaultProps)
|
||||
private BOPBiome(String idName, PropsBuilder defaultBuilder, BOPConfig.IConfigObj conf)
|
||||
{
|
||||
super(configureBiome(idName, defaultProps));
|
||||
super(configureBiomeProps(idName, defaultBuilder, conf));
|
||||
|
||||
this.idName = idName;
|
||||
this.terrainSettings.setDefaults();
|
||||
|
@ -81,31 +81,46 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
|
|||
this.addGenerator("roots", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(4.0F).with(BOPPlants.ROOT).create());
|
||||
}
|
||||
|
||||
public static BiomeProps configureBiome(String idName, BiomeProps props)
|
||||
public BOPBiome(String idName, PropsBuilder defaultBuilder)
|
||||
{
|
||||
BOPConfig.IConfigObj conf = ModBiomes.readConfigFile(idName);
|
||||
this(idName, defaultBuilder, ModBiomes.readConfigFile(idName));
|
||||
}
|
||||
|
||||
public static BiomeProps configureBiomeProps(String idName, PropsBuilder defaultBuilder, BOPConfig.IConfigObj conf)
|
||||
{
|
||||
// If there isn't a valid config file, don't use it to configure the biome
|
||||
if (conf.isEmpty())
|
||||
return props;
|
||||
return defaultBuilder.build();
|
||||
|
||||
// Allow name to be overridden
|
||||
props = new BiomeProps(conf.getString("biomeName",props.biomeName));
|
||||
defaultBuilder.withBaseHeight(conf.getFloat("rootHeight"));
|
||||
defaultBuilder.withHeightVariation(conf.getFloat("variation"));
|
||||
defaultBuilder.withTemperature(conf.getFloat("temperature"));
|
||||
defaultBuilder.withRainfall(conf.getFloat("rainfall"));
|
||||
defaultBuilder.withWaterColor(conf.getInt("waterColor"));
|
||||
|
||||
Boolean enableRain = conf.getBool("enableRain");
|
||||
if (enableRain != null && !enableRain) defaultBuilder.withRainDisabled();
|
||||
|
||||
Boolean enableSnow = conf.getBool("enableSnow");
|
||||
if (enableSnow != null && enableSnow) defaultBuilder.withSnowEnabled();
|
||||
|
||||
defaultBuilder.withBaseBiome(conf.getString("baseBiome"));
|
||||
defaultBuilder.withGuiColour(conf.getInt("guiColour"));
|
||||
|
||||
return defaultBuilder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applySettings(BOPWorldSettings settings){}
|
||||
|
||||
@Override
|
||||
public void configure(IConfigObj conf)
|
||||
{
|
||||
// Allow basic properties to be overridden
|
||||
this.topBlock = conf.getBlockState("topBlock", this.topBlock);
|
||||
this.fillerBlock = conf.getBlockState("fillerBlock", this.fillerBlock);
|
||||
this.seaFloorBlock = conf.getBlockState("seaFloorBlock", this.seaFloorBlock);
|
||||
|
||||
this.minHeight = conf.getFloat("rootHeight", this.getBaseHeight());
|
||||
this.maxHeight = conf.getFloat("variation", this.maxHeight);
|
||||
this.temperature = conf.getFloat("temperature", this.temperature);
|
||||
this.rainfall = conf.getFloat("rainfall", this.rainfall);
|
||||
this.color = conf.getInt("color",this.color);
|
||||
this.waterColorMultiplier = conf.getInt("waterColorMultiplier", this.waterColorMultiplier);
|
||||
this.enableRain = conf.getBool("enableRain", this.enableRain);
|
||||
this.enableSnow = conf.getBool("enableSnow", this.enableSnow);
|
||||
this.skyColor = conf.getInt("skyColor", this.skyColor);
|
||||
this.hasBiomeEssence = conf.getBool("hasBiomeEssence", this.hasBiomeEssence);
|
||||
|
||||
|
@ -216,14 +231,8 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applySettings(BOPWorldSettings settings){}
|
||||
|
||||
|
||||
@Override
|
||||
public BiomeOwner getBiomeOwner()
|
||||
{
|
||||
|
@ -385,77 +394,62 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
|
|||
return this.idName;
|
||||
}
|
||||
|
||||
//TODO: Convert this to a proper builder
|
||||
private static class BiomePropsBuilder extends BiomeGenBase.BiomeProperties
|
||||
protected static class PropsBuilder
|
||||
{
|
||||
/**The colour of this biome as seen in guis**/
|
||||
private float guiColour = 0xffffff;
|
||||
|
||||
//Copied from Vanilla's BiomeProperties to provide us with access
|
||||
private final String biomeName;
|
||||
|
||||
/**The colour of this biome as seen in guis**/
|
||||
private int guiColour = 0xffffff;
|
||||
private float baseHeight = 0.1F;
|
||||
private float heightVariation = 0.2F;
|
||||
private float temperature = 0.5F;
|
||||
private float rainfall = 0.5F;
|
||||
private int waterColor = 16777215;
|
||||
private boolean enableSnow;
|
||||
private boolean enableSnow = false;
|
||||
private boolean enableRain = true;
|
||||
private String baseBiomeRegName;
|
||||
|
||||
public BiomeProps(String name) { super(name); }
|
||||
public PropsBuilder(String name) { this.biomeName = name; }
|
||||
|
||||
public BiomeProps setGuiColour(int colour)
|
||||
public PropsBuilder withGuiColour(int colour)
|
||||
{
|
||||
this.guiColour = colour;
|
||||
return this;
|
||||
this.guiColour = colour; return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProps setTemperature(float temperature)
|
||||
public PropsBuilder withTemperature(Float temperature) { if (temperature != null) this.temperature = temperature; return this; }
|
||||
public PropsBuilder withRainfall(Float rainfall) { if (rainfall != null) this.rainfall = rainfall; return this; }
|
||||
public PropsBuilder withBaseHeight(Float baseHeight) { if (baseHeight != null) this.baseHeight = baseHeight; return this; }
|
||||
public PropsBuilder withHeightVariation(Float heightVariation) { if (heightVariation != null) this.heightVariation = heightVariation; return this; }
|
||||
public PropsBuilder withRainDisabled() { this.enableRain = false; return this; }
|
||||
public PropsBuilder withSnowEnabled() { this.enableSnow = true; return this; }
|
||||
public PropsBuilder withWaterColor(Integer waterColor) { if (waterColor != null) this.waterColor = waterColor; return this; }
|
||||
public PropsBuilder withBaseBiome(String name) { this.baseBiomeRegName = name; return this; }
|
||||
|
||||
public BiomeProps build()
|
||||
{
|
||||
return (BiomeProps)super.setTemperature(temperature);
|
||||
return new BiomeProps(this.biomeName, this.temperature, this.rainfall, this.baseHeight, this.heightVariation, this.enableRain, this.enableSnow, this.waterColor, this.baseBiomeRegName, this.guiColour);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProps setRainfall(float rainfall)
|
||||
private static class BiomeProps extends BiomeGenBase.BiomeProperties
|
||||
{
|
||||
return (BiomeProps) super.setRainfall(rainfall);
|
||||
}
|
||||
/**The colour of this biome as seen in guis**/
|
||||
private int guiColour = 0xffffff;
|
||||
|
||||
@Override
|
||||
public BiomeProps setBaseHeight(float baseHeight)
|
||||
private BiomeProps(String name, float temperature, float rainfall, float baseHeight, float heightVariation, boolean enableRain, boolean enableSnow, int waterColor, String baseBiomeRegName, int guiColour)
|
||||
{
|
||||
return (BiomeProps)super.setBaseHeight(baseHeight);
|
||||
}
|
||||
super(name);
|
||||
|
||||
@Override
|
||||
public BiomeProps setHeightVariation(float heightVariation)
|
||||
{
|
||||
return (BiomeProps)super.setHeightVariation(heightVariation);
|
||||
}
|
||||
this.setTemperature(temperature);
|
||||
this.setRainfall(rainfall);
|
||||
this.setBaseHeight(baseHeight);
|
||||
this.setHeightVariation(heightVariation);
|
||||
if (!enableRain) this.setRainDisabled();
|
||||
if (enableSnow) this.setSnowEnabled();
|
||||
this.setWaterColor(waterColor);
|
||||
this.setBaseBiome(baseBiomeRegName);
|
||||
|
||||
@Override
|
||||
public BiomeProps setRainDisabled()
|
||||
{
|
||||
return (BiomeProps)super.setRainDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProps setSnowEnabled()
|
||||
{
|
||||
return (BiomeProps)super.setSnowEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProps setWaterColor(int waterColor)
|
||||
{
|
||||
return (BiomeProps)super.setWaterColor(waterColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProps setBaseBiome(String name)
|
||||
{
|
||||
return (BiomeProps)super.setBaseBiome(name);
|
||||
this.guiColour = guiColour;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,12 +14,14 @@ import biomesoplenty.api.biome.generation.GenerationManager;
|
|||
import biomesoplenty.api.biome.generation.GeneratorStage;
|
||||
import biomesoplenty.api.biome.generation.IGenerator;
|
||||
import biomesoplenty.common.enums.BOPClimates;
|
||||
import biomesoplenty.common.util.config.BOPConfig.IConfigObj;
|
||||
import biomesoplenty.common.world.BOPWorldSettings;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public interface IExtendedBiome
|
||||
{
|
||||
public void applySettings(BOPWorldSettings settings);
|
||||
public void configure(IConfigObj conf);
|
||||
|
||||
public BiomeOwner getBiomeOwner();
|
||||
public void addGenerator(String name, GeneratorStage stage, IGenerator generator);
|
||||
|
|
|
@ -67,7 +67,7 @@ public class ModBlockQueries
|
|||
@Override
|
||||
public boolean matches(World world, BlockPos pos)
|
||||
{
|
||||
return (world.getBlockState(pos.west()).getBlock().getMaterial() == Material.water || world.getBlockState(pos.east()).getBlock().getMaterial() == Material.water || world.getBlockState(pos.north()).getBlock().getMaterial() == Material.water || world.getBlockState(pos.south()).getBlock().getMaterial() == Material.water);
|
||||
return (world.getBlockState(pos.west()).getMaterial() == Material.water || world.getBlockState(pos.east()).getMaterial() == Material.water || world.getBlockState(pos.north()).getBlock().getMaterial() == Material.water || world.getBlockState(pos.south()).getBlock().getMaterial() == Material.water);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class ModBlockQueries
|
|||
@Override
|
||||
public boolean matches(World world, BlockPos pos)
|
||||
{
|
||||
return world.getBlockState(pos).getBlock().getMaterial() == Material.water && world.getBlockState(pos.up()).getBlock().getMaterial() == Material.water;
|
||||
return world.getBlockState(pos).getMaterial() == Material.water && world.getBlockState(pos.up()).getMaterial() == Material.water;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class ModBlockQueries
|
|||
@Override
|
||||
public boolean matches(World world, BlockPos pos)
|
||||
{
|
||||
return world.getBlockState(pos).getBlock().getBlockHardness(world, pos) >= 0.0F;
|
||||
return world.getBlockState(pos).getBlockHardness(world, pos) >= 0.0F;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class ModBlockQueries
|
|||
@Override
|
||||
public boolean matches(World world, BlockPos pos)
|
||||
{
|
||||
return world.isSideSolid(pos, EnumFacing.UP);
|
||||
return world.getBlockState(pos).isSideSolid(world, pos, EnumFacing.UP);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class ModBlockQueries
|
|||
@Override public boolean matches(World world, BlockPos pos) {
|
||||
BlockPos groundPos = pos.down();
|
||||
return world.getBlockState(pos).getBlock() == Blocks.water &&
|
||||
(world.getBlockState(groundPos).getBlock() != Blocks.water && world.getBlockState(groundPos).getBlock().isSideSolid(world, groundPos, EnumFacing.UP));
|
||||
(world.getBlockState(groundPos).getBlock() != Blocks.water && world.getBlockState(groundPos).isSideSolid(world, groundPos, EnumFacing.UP));
|
||||
}
|
||||
}).withLightAboveAtLeast(8).create();
|
||||
rootsCanDigThrough = new BlockQueryMaterial(Material.air, Material.water, Material.ground, Material.grass, Material.sand, Material.clay, Material.plants, Material.leaves);
|
||||
|
|
|
@ -107,7 +107,7 @@ public class ModCompatibility
|
|||
|
||||
WrappedBiomeEntry other = (WrappedBiomeEntry)input;
|
||||
|
||||
return other.biomeEntry.itemWeight == this.biomeEntry.itemWeight && other.biomeEntry.biome.biomeID == this.biomeEntry.biome.biomeID;
|
||||
return other.biomeEntry.itemWeight == this.biomeEntry.itemWeight && other.biomeEntry.biome == this.biomeEntry.biome;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
|||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Item.ToolMaterial;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
|
@ -230,14 +231,14 @@ public class ModItems
|
|||
exotic_flower_band = registerItem(new ItemFlowerBand(exotic_flower_band_material, 0), "exotic_flower_band");
|
||||
dull_flower_band = registerItem(new ItemFlowerBand(dull_flower_band_material, 0), "dull_flower_band");
|
||||
|
||||
mud_helmet = registerItem(new ItemArmor(mud_armor_material, 0, 0), "mud_helmet");
|
||||
mud_chestplate = registerItem(new ItemArmor(mud_armor_material, 0, 1), "mud_chestplate");
|
||||
mud_leggings = registerItem(new ItemArmor(mud_armor_material, 0, 2), "mud_leggings");
|
||||
mud_boots = registerItem(new ItemArmor(mud_armor_material, 0, 3), "mud_boots");
|
||||
amethyst_helmet = registerItem(new ItemArmor(amethyst_armor_material, 0, 0), "amethyst_helmet");
|
||||
amethyst_chestplate = registerItem(new ItemArmor(amethyst_armor_material, 0, 1), "amethyst_chestplate");
|
||||
amethyst_leggings = registerItem(new ItemArmor(amethyst_armor_material, 0, 2), "amethyst_leggings");
|
||||
amethyst_boots = registerItem(new ItemArmor(amethyst_armor_material, 0, 3), "amethyst_boots");
|
||||
mud_helmet = registerItem(new ItemArmor(mud_armor_material, 0, EntityEquipmentSlot.HEAD), "mud_helmet");
|
||||
mud_chestplate = registerItem(new ItemArmor(mud_armor_material, 0, EntityEquipmentSlot.CHEST), "mud_chestplate");
|
||||
mud_leggings = registerItem(new ItemArmor(mud_armor_material, 0, EntityEquipmentSlot.LEGS), "mud_leggings");
|
||||
mud_boots = registerItem(new ItemArmor(mud_armor_material, 0, EntityEquipmentSlot.FEET), "mud_boots");
|
||||
amethyst_helmet = registerItem(new ItemArmor(amethyst_armor_material, 0, EntityEquipmentSlot.HEAD), "amethyst_helmet");
|
||||
amethyst_chestplate = registerItem(new ItemArmor(amethyst_armor_material, 0, EntityEquipmentSlot.CHEST), "amethyst_chestplate");
|
||||
amethyst_leggings = registerItem(new ItemArmor(amethyst_armor_material, 0, EntityEquipmentSlot.LEGS), "amethyst_leggings");
|
||||
amethyst_boots = registerItem(new ItemArmor(amethyst_armor_material, 0, EntityEquipmentSlot.FEET), "amethyst_boots");
|
||||
|
||||
// tools
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ public class GeneratorBigFlower extends BOPGeneratorBase
|
|||
return false;
|
||||
}
|
||||
|
||||
world.getBlockState(pos.down()).getBlock().onPlantGrow(world, pos.down(), pos);
|
||||
world.getBlockState(pos.down()).getBlock().onPlantGrow(world.getBlockState(pos.down()), world, pos.down(), pos);
|
||||
|
||||
this.setStem(world, pos);
|
||||
this.setStem(world, pos.up(1));
|
||||
|
|
|
@ -167,7 +167,7 @@ public class GeneratorLakes extends BOPGeneratorBase
|
|||
{
|
||||
if (this.isCavityEdge(x, y, z, cavityShape)) {
|
||||
|
||||
Material material = world.getBlockState(startPos.add(x, y, z)).getBlock().getMaterial();
|
||||
Material material = world.getBlockState(startPos.add(x, y, z)).getMaterial();
|
||||
|
||||
// abandon if there's liquid at the edge of the cavity above the water level
|
||||
if (y >= 4 && material.isLiquid())
|
||||
|
@ -272,7 +272,7 @@ public class GeneratorLakes extends BOPGeneratorBase
|
|||
{
|
||||
if (this.isCavityEdge(x, y, z, cavityShape))
|
||||
{
|
||||
if ((y < 4 || rand.nextInt(2) != 0) && world.getBlockState(pos.add(x, y, z)).getBlock().getMaterial().isSolid())
|
||||
if ((y < 4 || rand.nextInt(2) != 0) && world.getBlockState(pos.add(x, y, z)).getMaterial().isSolid())
|
||||
{
|
||||
world.setBlockState(pos.add(x, y, z), this.lineWith, 2);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ public class GeneratorWaterside extends GeneratorReplacing
|
|||
public boolean generate(World world, Random random, BlockPos pos)
|
||||
{
|
||||
//Check we are generating around water
|
||||
if (world.getBlockState(pos).getBlock().getMaterial() != Material.water)
|
||||
if (world.getBlockState(pos).getMaterial() != Material.water)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue