Updated a bunch of stuff, began work on switching over the biome config setup to the new 'BiomeProperties'

This commit is contained in:
Adubbz 2016-03-03 20:51:19 +11:00
parent 46cf8ba098
commit c1dd0cdf7a
16 changed files with 206 additions and 176 deletions

View file

@ -8,6 +8,7 @@
package biomesoplenty.api.biome;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -21,10 +22,13 @@ import biomesoplenty.api.biome.generation.GeneratorStage;
import biomesoplenty.api.biome.generation.IGenerator;
import biomesoplenty.common.enums.BOPClimates;
import biomesoplenty.common.enums.BOPPlants;
import biomesoplenty.common.init.ModBiomes;
import biomesoplenty.common.util.config.BOPConfig;
import biomesoplenty.common.util.config.BOPConfig.IConfigObj;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.TerrainSettings;
import biomesoplenty.common.world.feature.GeneratorFlora;
import biomesoplenty.core.BiomesOPlenty;
import net.minecraft.block.BlockSand;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
@ -57,10 +61,13 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
public boolean noNeighborTerrainInfuence = false;
public int avgDirtDepth = 3;
public BOPBiome()
{
super(-1, false);
public final String idName;
public BOPBiome(String idName, BiomeProps defaultProps)
{
super(configureBiome(idName, defaultProps));
this.idName = idName;
this.terrainSettings.setDefaults();
this.theBiomeDecorator.treesPerChunk = -999;
@ -74,15 +81,17 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
this.addGenerator("roots", GeneratorStage.FLOWERS,(new GeneratorFlora.Builder()).amountPerChunk(4.0F).with(BOPPlants.ROOT).create());
}
@Override
public void applySettings(BOPWorldSettings settings){}
@Override
public void configure(IConfigObj conf)
public static BiomeProps configureBiome(String idName, BiomeProps props)
{
BOPConfig.IConfigObj conf = ModBiomes.readConfigFile(idName);
// If there isn't a valid config file, don't use it to configure the biome
if (conf.isEmpty())
return props;
// Allow name to be overridden
this.biomeName = conf.getString("biomeName",this.biomeName);
props = new BiomeProps(conf.getString("biomeName",props.biomeName));
// Allow basic properties to be overridden
this.topBlock = conf.getBlockState("topBlock", this.topBlock);
@ -208,8 +217,12 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
}
}
return props;
}
@Override
public void applySettings(BOPWorldSettings settings){}
@Override
public BiomeOwner getBiomeOwner()
@ -269,14 +282,6 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
return (this.skyColor == -1) ? super.getSkyColorByTemp(temperature) : this.skyColor;
}
@Override
public BiomeGenBase setTemperatureRainfall(float temp, float rain)
{
this.temperature = temp;
this.rainfall = rain;
return this;
}
@Override
public void genTerrainBlocks(World world, Random rand, ChunkPrimer primer, int x, int z, double stoneNoiseVal)
{
@ -308,14 +313,14 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
continue;
}
if (state.getBlock().getMaterial() == Material.air)
if (state.getMaterial() == Material.air)
{
// topBlocks and dirtBlocks can occur after any pocket of air
topBlocksToFill = (topBlock == null ? 0 : 1);
dirtBlocksToFill = dirtDepth;
continue;
}
else if (!hitFloorYet && state.getBlock().getMaterial() == Material.water)
else if (!hitFloorYet && state.getMaterial() == Material.water)
{
// seaFloorBlocks can occur after surface water
seaFloorBlocksToFill = seaFloorDepth;
@ -373,4 +378,84 @@ public class BOPBiome extends BiomeGenBase implements IExtendedBiome
{
return this;
}
@Override
public String getIdName()
{
return this.idName;
}
//TODO: Convert this to a proper builder
private static class BiomePropsBuilder extends BiomeGenBase.BiomeProperties
{
/**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;
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 enableRain = true;
private String baseBiomeRegName;
public BiomeProps(String name) { super(name); }
public BiomeProps setGuiColour(int colour)
{
this.guiColour = colour;
return this;
}
@Override
public BiomeProps setTemperature(float temperature)
{
return (BiomeProps)super.setTemperature(temperature);
}
@Override
public BiomeProps setRainfall(float rainfall)
{
return (BiomeProps) super.setRainfall(rainfall);
}
@Override
public BiomeProps setBaseHeight(float baseHeight)
{
return (BiomeProps)super.setBaseHeight(baseHeight);
}
@Override
public BiomeProps setHeightVariation(float heightVariation)
{
return (BiomeProps)super.setHeightVariation(heightVariation);
}
@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);
}
}
}

View file

@ -14,14 +14,12 @@ 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);
@ -34,4 +32,5 @@ public interface IExtendedBiome
/**Get the base biome associated with this extension**/
public BiomeGenBase getBaseBiome();
public String getIdName();
}

View file

@ -17,18 +17,17 @@ import biomesoplenty.common.world.feature.GeneratorLakes;
import biomesoplenty.common.world.feature.GeneratorOreSingle;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.world.biome.BiomeGenBase;
public class BiomeGenAlps extends BOPBiome
{
public BiomeGenAlps()
{
super(new BiomeProps("Alps").setGuiColour(13421772).setSnowEnabled().setTemperature(-0.5F).setRainfall(0.3F));
// terrain
this.terrainSettings.avgHeight(198).heightVariation(12, 12).octaves(1, 1, 2, 2, 3, 3);
this.setColor(13421772);
this.setEnableSnow();
this.setTemperatureRainfall(-0.5F, 0.3F);
this.canGenerateRivers = false;
this.canSpawnInBiome = false;
this.canGenerateVillages = false;

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import biomesoplenty.common.world.layer.BOPGenLayer;
import net.minecraft.init.Biomes;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.BiomeManager.BiomeType;
@ -64,11 +65,11 @@ public enum BOPClimates {
switch (this)
{
case ICE_CAP:
return (layer.nextInt(2)==0) ? this.getRandomLandBiome(layer) : BiomeGenBase.frozenOcean;
return (layer.nextInt(2)==0) ? this.getRandomLandBiome(layer) : Biomes.frozenOcean;
case TUNDRA: case BOREAL:
return (layer.nextInt(3)!=0) ? (deep ? BiomeGenBase.deepOcean : BiomeGenBase.ocean) : BiomeGenBase.frozenOcean;
return (layer.nextInt(3)!=0) ? (deep ? Biomes.deepOcean : Biomes.ocean) : Biomes.frozenOcean;
default:
return (deep ? BiomeGenBase.deepOcean : BiomeGenBase.ocean);
return (deep ? Biomes.deepOcean : Biomes.ocean);
}
}
@ -76,20 +77,20 @@ public enum BOPClimates {
{
// set up vanilla biomes
BOPClimates.ICE_CAP.addLandBiome(10,BiomeGenBase.icePlains);
BOPClimates.TUNDRA.addLandBiome(10, BiomeGenBase.coldTaiga).addLandBiome(10, BiomeGenBase.extremeHills);
BOPClimates.BOREAL.addLandBiome(5, BiomeGenBase.megaTaiga).addLandBiome(5, BiomeGenBase.extremeHills).addLandBiome(20, BiomeGenBase.taiga);
BOPClimates.COLD_SWAMP.addLandBiome(5, BiomeGenBase.swampland);
BOPClimates.WET_TEMPERATE.addLandBiome(20, BiomeGenBase.roofedForest).addLandBiome(5, BiomeGenBase.forest);
BOPClimates.DRY_TEMPERATE.addLandBiome(5, BiomeGenBase.plains);
BOPClimates.COOL_TEMPERATE.addLandBiome(15, BiomeGenBase.forest).addLandBiome(10, BiomeGenBase.birchForest);
BOPClimates.WARM_TEMPERATE.addLandBiome(20, BiomeGenBase.plains).addLandBiome(5, BiomeGenBase.birchForest);
BOPClimates.HOT_SWAMP.addLandBiome(5, BiomeGenBase.swampland);
BOPClimates.TROPICAL.addLandBiome(15, BiomeGenBase.jungle);
BOPClimates.MEDITERANEAN.addLandBiome(5, BiomeGenBase.plains);
BOPClimates.SAVANNA.addLandBiome(20, BiomeGenBase.savanna);
BOPClimates.HOT_DESERT.addLandBiome(30, BiomeGenBase.desert).addLandBiome(10, BiomeGenBase.mesaPlateau);
BOPClimates.WASTELAND.addLandBiome(1, BiomeGenBase.desert);
BOPClimates.ICE_CAP.addLandBiome(10,Biomes.icePlains);
BOPClimates.TUNDRA.addLandBiome(10, Biomes.coldTaiga).addLandBiome(10, Biomes.extremeHills);
BOPClimates.BOREAL.addLandBiome(5, Biomes.megaTaiga).addLandBiome(5, Biomes.extremeHills).addLandBiome(20, Biomes.taiga);
BOPClimates.COLD_SWAMP.addLandBiome(5, Biomes.swampland);
BOPClimates.WET_TEMPERATE.addLandBiome(20, Biomes.roofedForest).addLandBiome(5, Biomes.forest);
BOPClimates.DRY_TEMPERATE.addLandBiome(5, Biomes.plains);
BOPClimates.COOL_TEMPERATE.addLandBiome(15, Biomes.forest).addLandBiome(10, Biomes.birchForest);
BOPClimates.WARM_TEMPERATE.addLandBiome(20, Biomes.plains).addLandBiome(5, Biomes.birchForest);
BOPClimates.HOT_SWAMP.addLandBiome(5, Biomes.swampland);
BOPClimates.TROPICAL.addLandBiome(15, Biomes.jungle);
BOPClimates.MEDITERANEAN.addLandBiome(5, Biomes.plains);
BOPClimates.SAVANNA.addLandBiome(20, Biomes.savanna);
BOPClimates.HOT_DESERT.addLandBiome(30, Biomes.desert).addLandBiome(10, Biomes.mesaPlateau);
BOPClimates.WASTELAND.addLandBiome(1, Biomes.desert);
}
@ -146,7 +147,7 @@ public enum BOPClimates {
{
for (WeightedBiomeEntry entry : climate.landBiomes)
{
System.out.println(climate.name()+" "+entry.biome.biomeName+" "+entry.weight);
System.out.println(climate.name()+" "+entry.biome.getBiomeName()+" "+entry.weight);
}
}
}

View file

@ -20,6 +20,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@ -31,14 +32,14 @@ public class BucketEventHandler
public void onRightClickHoldingBucket(FillBucketEvent event)
{
// check we're using a bucket, on a block we can modify
if (event.current.getItem() != Items.bucket) {return;}
if (event.target.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) {return;}
BlockPos blockpos = event.target.getBlockPos();
if (!event.world.isBlockModifiable(event.entityPlayer, blockpos)) {return;}
if (!event.entityPlayer.canPlayerEdit(blockpos.offset(event.target.sideHit), event.target.sideHit, event.current)) {return;}
if (event.getEmptyBucket().getItem() != Items.bucket) {return;}
if (event.getTarget().typeOfHit != RayTraceResult.Type.BLOCK) {return;}
BlockPos blockpos = event.getTarget().getBlockPos();
if (!event.getWorld().isBlockModifiable(event.entityPlayer, blockpos)) {return;}
if (!event.entityPlayer.canPlayerEdit(blockpos.offset(event.getTarget().sideHit), event.getTarget().sideHit, event.getEmptyBucket())) {return;}
// determine if the block is one of our BOP fluids
IBlockState iblockstate = event.world.getBlockState(blockpos);
IBlockState iblockstate = event.getWorld().getBlockState(blockpos);
Item filled_bucket = null;
if (iblockstate.getBlock() == BOPBlocks.honey && ((Integer)iblockstate.getValue(BlockHoneyFluid.LEVEL)).intValue() == 0)
{
@ -63,9 +64,9 @@ public class BucketEventHandler
// remove the fluid and return the appropriate filled bucket
event.setResult(Result.ALLOW);
event.result = new ItemStack(filled_bucket);
event.world.setBlockToAir(blockpos);
event.entityPlayer.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(event.current.getItem())]);
event.setFilledBucket(new ItemStack(filled_bucket));
event.getWorld().setBlockToAir(blockpos);
event.entityPlayer.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(event.getEmptyBucket().getItem())]);
}
}

View file

@ -24,7 +24,7 @@ public class DyeEventHandler
@SubscribeEvent
public void entityInteract(EntityInteractEvent event)
{
ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
ItemStack stack = event.entityPlayer.getHeldItem(event.getHand());
if (stack == null) {return;}
Item item = stack.getItem();
@ -36,7 +36,7 @@ public class DyeEventHandler
else if (item == BOPItems.white_dye) {dyeColor = EnumDyeColor.WHITE;}
else {return;}
Entity target = event.target;
Entity target = event.getTarget();
if (target instanceof EntityWolf)
{
EntityWolf wolf = (EntityWolf)target;

View file

@ -57,7 +57,7 @@ public class TrailsEventHandler
BlockPos groundPos = playerPos.add(offsetX, -1, offsetZ);
if (!world.isAirBlock(groundPos) && world.getBlockState(groundPos).getBlock().isSideSolid(world, groundPos, EnumFacing.UP)) //Only place particles on blocks with a solid top
if (!world.isAirBlock(groundPos) && world.getBlockState(groundPos).isSideSolid(world, groundPos, EnumFacing.UP)) //Only place particles on blocks with a solid top
{
if (player.posX != player.prevPosX || player.posZ != player.prevPosZ) //Particles should only spawn if the player is moving
{

View file

@ -117,6 +117,7 @@ import com.google.common.collect.Sets;
import biomesoplenty.api.biome.BOPBiome;
import biomesoplenty.api.biome.BOPBiomes;
import biomesoplenty.api.biome.IExtendedBiome;
import biomesoplenty.api.biome.BOPBiome.BiomeProps;
import biomesoplenty.common.biome.overworld.BiomeGenAlps;
import biomesoplenty.common.biome.overworld.BiomeGenBambooForest;
import biomesoplenty.common.biome.overworld.BiomeGenBayou;
@ -232,7 +233,6 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
public static Set<BiomeGenBase> presentBiomes;
public static Map<Integer, List<Integer>> subBiomesMap;
public static Map<Integer, List<Integer>> mutatedBiomesMap;
public static Map<Integer, Integer> islandBiomesMap = new HashMap<Integer, Integer>();
public static int totalIslandBiomesWeight;
@ -273,7 +273,6 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
}
initSubBiomes();
initMutatedBiomes();
registerBiomes();
registerBiomeDictionaryTags();
@ -319,41 +318,6 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
}
public static void initMutatedBiomes()
{
mutatedBiomesMap = new HashMap<Integer, List<Integer>>();
// Add vanilla mutated biomes
// the mutated versions of vanilla biomes aren't actually saved to static variables in BiomeGenBase
// instead, they just manually create mutated versions of many of their biomes via a hard coded list in BiomeGenBase
// and by default assume a biome id which is the old one + 128
// this severely limits the number of new biomes we can add (we'd have to keep the number below 128 to avoid clashes)
// we hard code the list of vanilla biomes with mutated versions below, which enables other biomes to use the biome ids which are not taken
setSubBiome(Biomes.plains, BiomeGenBase.getBiome(Biomes.plains.biomeID + 128));
setSubBiome(Biomes.desert, BiomeGenBase.getBiome(Biomes.desert.biomeID + 128));
setSubBiome(Biomes.forest, BiomeGenBase.getBiome(Biomes.forest.biomeID + 128));
setSubBiome(Biomes.taiga, BiomeGenBase.getBiome(Biomes.taiga.biomeID + 128));
setSubBiome(Biomes.swampland, BiomeGenBase.getBiome(Biomes.swampland.biomeID + 128));
setSubBiome(Biomes.icePlains, BiomeGenBase.getBiome(Biomes.icePlains.biomeID + 128));
setSubBiome(Biomes.jungle, BiomeGenBase.getBiome(Biomes.jungle.biomeID + 128));
setSubBiome(Biomes.jungleEdge, BiomeGenBase.getBiome(Biomes.jungleEdge.biomeID + 128));
setSubBiome(Biomes.coldTaiga, BiomeGenBase.getBiome(Biomes.coldTaiga.biomeID + 128));
setSubBiome(Biomes.savanna, BiomeGenBase.getBiome(Biomes.savanna.biomeID + 128));
setSubBiome(Biomes.savannaPlateau, BiomeGenBase.getBiome(Biomes.savannaPlateau.biomeID + 128));
setSubBiome(Biomes.mesa, BiomeGenBase.getBiome(Biomes.mesa.biomeID + 128));
setSubBiome(Biomes.mesaPlateau, BiomeGenBase.getBiome(Biomes.mesaPlateau.biomeID + 128));
setSubBiome(Biomes.mesaPlateau_F, BiomeGenBase.getBiome(Biomes.mesaPlateau_F.biomeID + 128));
setSubBiome(Biomes.birchForest, BiomeGenBase.getBiome(Biomes.birchForest.biomeID + 128));
setSubBiome(Biomes.birchForestHills, BiomeGenBase.getBiome(Biomes.birchForestHills.biomeID + 128));
setSubBiome(Biomes.roofedForest, BiomeGenBase.getBiome(Biomes.roofedForest.biomeID + 128));
setSubBiome(Biomes.megaTaiga, BiomeGenBase.getBiome(Biomes.megaTaiga.biomeID + 128));
setSubBiome(Biomes.extremeHills, BiomeGenBase.getBiome(Biomes.extremeHills.biomeID + 128));
setSubBiome(Biomes.extremeHillsPlus, BiomeGenBase.getBiome(Biomes.extremeHillsPlus.biomeID + 128));
setSubBiome(Biomes.megaTaigaHills, BiomeGenBase.getBiome(Biomes.megaTaigaHills.biomeID + 128));
}
private static void registerBiomes()
{
// beach biomes (normal biomes rely on these being registered first)
@ -422,10 +386,10 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
coral_reef = registerBOPBiome(new BiomeGenCoralReef(), "Coral Reef");
kelp_forest = registerBOPBiome(new BiomeGenKelpForest(), "Kelp Forest");
setSubBiome(Optional.of(BiomeGenBase.icePlains), BOPBiomes.glacier);
setSubBiome(Optional.of(BiomeGenBase.desert), BOPBiomes.oasis);
setSubBiome(Optional.of(BiomeGenBase.ocean), BOPBiomes.coral_reef);
setSubBiome(Optional.of(BiomeGenBase.ocean), BOPBiomes.kelp_forest);
setSubBiome(Optional.of(Biomes.icePlains), BOPBiomes.glacier);
setSubBiome(Optional.of(Biomes.desert), BOPBiomes.oasis);
setSubBiome(Optional.of(Biomes.ocean), BOPBiomes.coral_reef);
setSubBiome(Optional.of(Biomes.ocean), BOPBiomes.kelp_forest);
// island biomes
@ -604,12 +568,18 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
return ImmutableSet.copyOf(presentBiomes);
}
private static void setSubBiome(Optional<BiomeGenBase> parent, Optional<BiomeGenBase>... subBiomes)
public static BOPConfig.IConfigObj readConfigFile(String idName)
{
setSubBiome(parent, false, subBiomes);
File configFile = new File(new File(BiomesOPlenty.configDirectory, "biomes"), idName + ".json");
BOPConfig.IConfigObj conf = new BOPConfig.ConfigFileObj(configFile);
// log any warnings from parsing the config file
for (String msg : conf.flushMessages()) {BiomesOPlenty.logger.warn(msg);}
return conf;
}
private static void setSubBiome(Optional<BiomeGenBase> parent, boolean mutated, Optional<BiomeGenBase>... subBiomes)
private static void setSubBiome(Optional<BiomeGenBase> parent, Optional<BiomeGenBase>... subBiomes)
{
if (parent.isPresent())
{
@ -617,7 +587,7 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
{
if (subBiome.isPresent())
{
setSubBiome(parent.get(), mutated, subBiome.get());
setSubBiome(parent.get(), subBiome.get());
}
}
}
@ -625,12 +595,7 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
private static void setSubBiome(BiomeGenBase parent, BiomeGenBase... subBiomes)
{
setSubBiome(parent, false, subBiomes);
}
private static void setSubBiome(BiomeGenBase parent, boolean mutated, BiomeGenBase... subBiomes)
{
Map<Integer, List<Integer>> map = mutated ? mutatedBiomesMap : subBiomesMap;
Map<Integer, List<Integer>> map = subBiomesMap;
int parentId = parent.biomeID;
if (!map.containsKey(parentId))
{
@ -651,17 +616,6 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
}
}
private static void configureBiome(IExtendedBiome biome, String idName)
{
File configFile = new File(new File(BiomesOPlenty.configDirectory, "biomes"), idName + ".json");
BOPConfig.IConfigObj conf = new BOPConfig.ConfigFileObj(configFile);
// If there was a valid config file, then use it to configure the biome
if (!conf.isEmpty()) {biome.configure(conf);}
// log any warnings from parsing the config file
for (String msg : conf.flushMessages()) {BiomesOPlenty.logger.warn(msg);}
}
private static IExtendedBiome registerWrappedBiome(IExtendedBiome extendedBiome, String idName)
{
//Non-wrapped biomes should not be registered this way
@ -671,23 +625,17 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
return BOPBiomes.REG_INSTANCE.registerBiome(extendedBiome, idName);
}
private static Optional<BiomeGenBase> registerBOPBiome(BOPBiome biome, String name)
private static Optional<BiomeGenBase> registerBOPBiome(BOPBiome biome, String idName)
{
biome.setBiomeName(name);
String idName = BiomeUtils.getBiomeIdentifier(biome);
Integer id = biomeIdMapConf.getInt(idName, null);
if (id == null) {id = new Integer(getNextFreeBiomeId());}
biomeIdMap.put(idName, id);
if (id > -1) {
BOPCommand.biomeCount++;
biome.biomeID = id;
BOPBiomes.REG_INSTANCE.registerBiome(biome, idName);
BiomeGenBase.getBiomeGenArray()[id] = biome;
BiomeGenBase.registerBiome(id, idName, biome);
//Enable spwning and village generation in the biome
if (biome.canSpawnInBiome)
@ -715,7 +663,7 @@ public class ModBiomes implements BOPBiomes.IBiomeRegistry
{
for (int i = nextBiomeId; i < 256; i++)
{
if (BiomeGenBase.getBiomeGenArray()[i] != null)
if (BiomeGenBase.getBiome(i) != null)
{
if (i == 255) throw new IllegalArgumentException("There are no more biome ids avaliable!");
continue;

View file

@ -25,7 +25,7 @@ public class ModChecks
String biomeIdentifier = entry.getKey();
int id = entry.getValue();
//Ensure the id is valid
//Ensure the id is valid (some biomes may be set to -1 as they are disabled)
if (id >= 0 && id <= BiomeGenBase.getBiomeGenArray().length)
{
BiomeGenBase biome = BiomeGenBase.getBiome(id);

View file

@ -123,6 +123,7 @@ import net.minecraft.client.renderer.block.model.ModelBakery;
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.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor;
@ -136,6 +137,7 @@ import net.minecraft.item.ItemSpade;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.common.util.EnumHelper;
@ -163,7 +165,7 @@ public class ModItems
saladfruit = registerItem(new ItemSoup(6), "saladfruit");
((ItemFood)saladfruit).setPotionEffect(Potion.digSpeed.id, 775, 1, 0.05F);
saladveggie = registerItem(new ItemSoup(6), "saladveggie");
((ItemFood)saladveggie).setPotionEffect(Potion.nightVision.id, 1100, 1, 0.05F); // TODO: Is this the right potion effect for veggie salad?
((ItemFood)saladveggie).setPotionEffect(new PotionEffect(MobEffects.nightVision, 1100, 1), 0.05F); // TODO: Is this the right potion effect for veggie salad?
saladshroom = registerItem(new ItemSoup(6), "saladshroom");
((ItemFood)saladshroom).setPotionEffect(Potion.jump.id, 550, 1, 0.05F);
ricebowl = registerItem(new ItemSoup(2), "ricebowl");
@ -271,7 +273,7 @@ public class ModItems
stone_scythe = registerItem(new ItemBOPScythe(ToolMaterial.STONE), "stone_scythe");
iron_scythe = registerItem(new ItemBOPScythe(ToolMaterial.IRON), "iron_scythe");
gold_scythe = registerItem(new ItemBOPScythe(ToolMaterial.GOLD), "gold_scythe");
diamond_scythe = registerItem(new ItemBOPScythe(ToolMaterial.EMERALD), "diamond_scythe");
diamond_scythe = registerItem(new ItemBOPScythe(ToolMaterial.DIAMOND), "diamond_scythe");
amethyst_scythe = registerItem(new ItemBOPScythe(amethyst_tool_material), "amethyst_scythe");
dart = registerItem(new ItemDart(), "dart");

View file

@ -7,6 +7,7 @@ import biomesoplenty.common.entities.projectiles.dispenser.DispenserBehaviorMudb
import biomesoplenty.common.enums.BOPGems;
import biomesoplenty.common.enums.BOPTrees;
import net.minecraft.block.BlockDispenser;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
@ -38,31 +39,31 @@ public class ModVanillaCompat
ChestGenHooks bonusChest = ChestGenHooks.getInfo(ChestGenHooks.BONUS_CHEST);
ChestGenHooks netherFortress = ChestGenHooks.getInfo(ChestGenHooks.NETHER_FORTRESS);
bonusChest.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.peach), 1, 3, 10));
bonusChest.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.pear), 1, 3, 10));
bonusChest.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.persimmon), 1, 3, 10));
bonusChest.addItem(new WeightedRandomChestContent(BOPItems.peach, 0, 1, 3, 10));
bonusChest.addItem(new WeightedRandomChestContent(BOPItems.pear, 0, 1, 3, 10));
bonusChest.addItem(new WeightedRandomChestContent(BOPItems.persimmon, 0, 1, 3, 10));
netherFortress.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.fleshchunk), 2, 6, 5));
netherFortress.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.honeycomb), 2, 6, 5));
netherFortress.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.filled_honeycomb), 2, 6, 3));
netherFortress.addItem(new WeightedRandomChestContent(BOPItems.fleshchunk, 0, 2, 6, 5));
netherFortress.addItem(new WeightedRandomChestContent(BOPItems.honeycomb, 0, 2, 6, 5));
netherFortress.addItem(new WeightedRandomChestContent(BOPItems.filled_honeycomb, 0, 2, 6, 3));
mineshaft.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.turnip_seeds), 3, 6, 25));
mineshaft.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.gem, 1, BOPGems.RUBY.ordinal()), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.gem, 1, BOPGems.AMBER.ordinal()), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.gem, 1, BOPGems.MALACHITE.ordinal()), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.gem, 1, BOPGems.PERIDOT.ordinal()), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.gem, 1, BOPGems.SAPPHIRE.ordinal()), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.gem, 1, BOPGems.TANZANITE.ordinal()), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.gem, 1, BOPGems.TOPAZ.ordinal()), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(BOPItems.turnip_seeds, 0, 3, 6, 25));
mineshaft.addItem(new WeightedRandomChestContent(BOPItems.gem, BOPGems.RUBY.ordinal(), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(BOPItems.gem, BOPGems.AMBER.ordinal(), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(BOPItems.gem, BOPGems.MALACHITE.ordinal(), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(BOPItems.gem, BOPGems.PERIDOT.ordinal(), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(BOPItems.gem, BOPGems.SAPPHIRE.ordinal(), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(BOPItems.gem, BOPGems.TANZANITE.ordinal(), 1, 4, 3));
mineshaft.addItem(new WeightedRandomChestContent(BOPItems.gem, BOPGems.TOPAZ.ordinal(), 1, 4, 3));
strongholdCorridor.addItem(new WeightedRandomChestContent(new ItemStack(BOPBlocks.sapling_1, 1, BOPTrees.SACRED_OAK.ordinal()), 1, 1, 1));
strongholdCrossing.addItem(new WeightedRandomChestContent(new ItemStack(BOPBlocks.sapling_1, 1, BOPTrees.SACRED_OAK.ordinal()), 1, 1, 1));
strongholdLibrary.addItem(new WeightedRandomChestContent(new ItemStack(BOPBlocks.sapling_1, 1, BOPTrees.SACRED_OAK.ordinal()), 1, 1, 1));
strongholdCorridor.addItem(new WeightedRandomChestContent(Item.getItemFromBlock(BOPBlocks.sapling_1), BOPTrees.SACRED_OAK.ordinal(), 1, 1, 1));
strongholdCrossing.addItem(new WeightedRandomChestContent(Item.getItemFromBlock(BOPBlocks.sapling_1), BOPTrees.SACRED_OAK.ordinal(), 1, 1, 1));
strongholdLibrary.addItem(new WeightedRandomChestContent(Item.getItemFromBlock(BOPBlocks.sapling_1), BOPTrees.SACRED_OAK.ordinal(), 1, 1, 1));
village.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.wading_boots), 1, 1, 15));
village.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.flippers), 1, 1, 15));
village.addItem(new WeightedRandomChestContent(BOPItems.wading_boots, 0, 1, 1, 15));
village.addItem(new WeightedRandomChestContent(BOPItems.flippers, 0, 1, 1, 15));
desertTemple.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.gem, 1, BOPGems.RUBY.ordinal()), 2, 8, 10));
jungleTemple.addItem(new WeightedRandomChestContent(new ItemStack(BOPItems.gem, 1, BOPGems.TOPAZ.ordinal()), 2, 8, 10));
desertTemple.addItem(new WeightedRandomChestContent(BOPItems.gem, BOPGems.RUBY.ordinal(), 2, 8, 10));
jungleTemple.addItem(new WeightedRandomChestContent(BOPItems.gem, BOPGems.TOPAZ.ordinal(), 2, 8, 10));
}
}

View file

@ -31,15 +31,16 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.event.FMLInterModComms;
//TODO: Re-add this
public class ThaumcraftCompat
{
public static void init()
{
addThaumcraftAspects();
addThaumcraftGolemsSupport();
//addThaumcraftAspects();
//addThaumcraftGolemsSupport();
}
private static void addThaumcraftAspects()
/*private static void addThaumcraftAspects()
{
//Thaumcraft sets most aspects automatically, just special cases are there
@ -211,5 +212,5 @@ public class ThaumcraftCompat
list.add(aspects[i], amounts[i]);
ThaumcraftApi.registerObjectTag(stack, list);
}
}*/
}

View file

@ -16,6 +16,7 @@ import biomesoplenty.core.BiomesOPlenty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.BiomeProvider;
import net.minecraft.world.gen.ChunkProviderSettings;
public class BiomeUtils
@ -33,16 +34,6 @@ public class BiomeUtils
}
}
//TODO: This MUST be replaced with Vanilla's new proper identifiers
@Deprecated
public static String getBiomeIdentifier(BiomeGenBase biome)
{
// Vanilla Biomes are typically named in upper camel case, sometimes with spaces
// We follow the same convention with BOP Biomes
// return a standardised identifier for use in json files, etc by converting to lowercase with underscores
return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, biome.getBiomeName().replace(" ", ""));
}
public static BlockPos spiralOutwardsLookingForBiome(World world, BiomeGenBase biomeToFind, double startX, double startZ)
{
int sampleSpacing = 4 << BiomeUtils.getBiomeSize(world);
@ -56,7 +47,7 @@ public class BiomeUtils
{
if (maxDist <= 0 || sampleSpace <= 0) {throw new IllegalArgumentException("maxDist and sampleSpace must be positive");}
WorldChunkManager chunkManager = world.getWorldChunkManager();
BiomeProvider chunkManager = world.getWorldChunkManager();
double a = sampleSpace / Math.sqrt(Math.PI);
double b = 2 * Math.sqrt(Math.PI);
double x = 0;

View file

@ -302,15 +302,15 @@ public class BlockQuery
case Desert: return block == Blocks.sand || block == Blocks.hardened_clay || block == Blocks.stained_hardened_clay || block == Blocks.dirt;
case Nether: return block == Blocks.soul_sand;
case Crop: return block == Blocks.farmland || block == BOPBlocks.farmland_0 || block == BOPBlocks.farmland_1;
case Cave: return block.isSideSolid(world, pos, EnumFacing.UP);
case Cave: return block.isSideSolid(state, world, pos, EnumFacing.UP);
case Plains: return block == Blocks.grass || block == Blocks.dirt || block == Blocks.farmland || block == BOPBlocks.farmland_0 || block == BOPBlocks.farmland_1 || block == Blocks.mycelium;
case Water: return block.getMaterial() == Material.water && ((Integer)state.getValue(BlockLiquid.LEVEL)) == 0;
case Water: return state.getMaterial() == Material.water && ((Integer)state.getValue(BlockLiquid.LEVEL)) == 0;
case Beach:
boolean isBeach = block == Blocks.grass || block == Blocks.dirt || block == Blocks.sand || block == Blocks.mycelium;
boolean hasWater = (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);
boolean hasWater = (world.getBlockState(pos.east()).getMaterial() == Material.water ||
world.getBlockState(pos.west()).getMaterial() == Material.water ||
world.getBlockState(pos.north()).getMaterial() == Material.water ||
world.getBlockState(pos.south()).getMaterial() == Material.water);
return isBeach && hasWater;
}
return false;
@ -496,7 +496,7 @@ public class BlockQuery
@Override
public boolean matches(IBlockState state)
{
return this.materials.contains(state.getBlock().getMaterial());
return this.materials.contains(state.getMaterial());
}
public static IBlockQuery of(String materialName, boolean negated) throws BlockQueryParseException

View file

@ -39,6 +39,7 @@ import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.MapGenBase;
import net.minecraft.world.gen.MapGenCaves;
@ -58,7 +59,7 @@ import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.terraingen.TerrainGen;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
public class ChunkProviderGenerateBOP implements IChunkProvider
public class ChunkProviderGenerateBOP implements IChunkGenerator
{
private Random rand;

View file

@ -13,7 +13,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiCreateWorld;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.biome.BiomeProvider;
import net.minecraft.world.chunk.IChunkGenerator;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -27,13 +28,13 @@ public class WorldTypeBOP extends WorldType
}
@Override
public WorldChunkManager getChunkManager(World world)
public BiomeProvider getBiomeProvider(World world)
{
return new BiomeProviderBOP(world);
}
@Override
public IChunkProvider getChunkGenerator(World world, String generatorOptions)
public IChunkGenerator getChunkGenerator(World world, String generatorOptions)
{
return new ChunkProviderGenerateBOP(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions);
//return new ChunkProviderGenerateVanilla(world, world.getSeed(), world.getWorldInfo().isMapFeaturesEnabled(), generatorOptions);