mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 04:09:51 +00:00
Defer firing CreateDecorator until it's likely mods have had a chance to register their listener. Should close #759
This commit is contained in:
1 parent
0443ef5a9e
commit
c84d99aa22
5 files changed
+72
-11
No files matched your search
@@ -1,7 +1,10 @@
|
||||
package net.minecraftforge.common;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import net.minecraft.world.biome.*;
|
||||
import net.minecraftforge.event.terraingen.DeferredBiomeDecorator;
|
||||
import static net.minecraft.world.biome.BiomeGenBase.*;
|
||||
import static net.minecraftforge.common.BiomeDictionary.Type.*;
|
||||
|
||||
@@ -185,19 +188,30 @@ public class BiomeDictionary
|
||||
return biomeList[biomeID] != null;
|
||||
}
|
||||
|
||||
public static void registerAllBiomes()
|
||||
{
|
||||
FMLLog.warning("Redundant call to BiomeDictionary.registerAllBiomes ignored");
|
||||
}
|
||||
/**
|
||||
* Loops through the biome list and automatically adds tags to any biome that does not have any
|
||||
* This should be called in postInit to make sure all biomes have been registered
|
||||
* This is called by Forge at postinit time. It will additionally dispatch any deferred decorator
|
||||
* creation events.
|
||||
*
|
||||
* DO NOT call this during world generation
|
||||
*/
|
||||
public static void registerAllBiomes()
|
||||
public static void registerAllBiomesAndGenerateEvents()
|
||||
{
|
||||
for(int i = 0; i < BIOME_LIST_SIZE; i++)
|
||||
{
|
||||
if(BiomeGenBase.biomeList[i] != null)
|
||||
BiomeGenBase biome = BiomeGenBase.biomeList[i];
|
||||
if (biome.theBiomeDecorator instanceof DeferredBiomeDecorator)
|
||||
{
|
||||
checkRegistration(BiomeGenBase.biomeList[i]);
|
||||
DeferredBiomeDecorator decorator = (DeferredBiomeDecorator) biome.theBiomeDecorator;
|
||||
decorator.fireCreateEventAndReplace();
|
||||
}
|
||||
if(biome != null)
|
||||
{
|
||||
checkRegistration(biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class ForgeDummyContainer extends DummyModContainer implements WorldAcces
|
||||
@Override
|
||||
public boolean registerBus(EventBus bus, LoadController controller)
|
||||
{
|
||||
bus.register(this);
|
||||
bus.register(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,8 @@ public class ForgeDummyContainer extends DummyModContainer implements WorldAcces
|
||||
@Subscribe
|
||||
public void postInit(FMLPostInitializationEvent evt)
|
||||
{
|
||||
ForgeChunkManager.loadConfiguration();
|
||||
BiomeDictionary.registerAllBiomesAndGenerateEvents();
|
||||
ForgeChunkManager.loadConfiguration();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -201,7 +202,7 @@ public class ForgeDummyContainer extends DummyModContainer implements WorldAcces
|
||||
DimensionManager.loadDimensionDataMap(tag.hasKey("DimensionData") ? tag.getCompoundTag("DimensionData") : null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public File getSource()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraftforge.event.terraingen;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.world.biome.BiomeDecorator;
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.minecraftforge.event.terraingen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeDecorator;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class DeferredBiomeDecorator extends BiomeDecorator {
|
||||
private BiomeDecorator wrapped;
|
||||
|
||||
public DeferredBiomeDecorator(BiomeGenBase biomeGenBase, BiomeDecorator wrappedOriginal)
|
||||
{
|
||||
super(biomeGenBase);
|
||||
this.wrapped = wrappedOriginal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(World par1World, Random par2Random, int par3, int par4)
|
||||
{
|
||||
fireCreateEventAndReplace();
|
||||
// On first call to decorate, we fire and substitute ourselves, if we haven't already done so
|
||||
biome.theBiomeDecorator.decorate(par1World, par2Random, par3, par4);
|
||||
}
|
||||
public void fireCreateEventAndReplace()
|
||||
{
|
||||
// Copy any configuration from us to the real instance.
|
||||
wrapped.bigMushroomsPerChunk = bigMushroomsPerChunk;
|
||||
wrapped.cactiPerChunk = cactiPerChunk;
|
||||
wrapped.clayPerChunk = clayPerChunk;
|
||||
wrapped.deadBushPerChunk = deadBushPerChunk;
|
||||
wrapped.flowersPerChunk = flowersPerChunk;
|
||||
wrapped.generateLakes = generateLakes;
|
||||
wrapped.grassPerChunk = grassPerChunk;
|
||||
wrapped.mushroomsPerChunk = mushroomsPerChunk;
|
||||
wrapped.reedsPerChunk = reedsPerChunk;
|
||||
wrapped.sandPerChunk = sandPerChunk;
|
||||
wrapped.sandPerChunk2 = sandPerChunk2;
|
||||
wrapped.treesPerChunk = treesPerChunk;
|
||||
wrapped.waterlilyPerChunk = waterlilyPerChunk;
|
||||
|
||||
BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(biome, wrapped);
|
||||
MinecraftForge.TERRAIN_GEN_BUS.post(event);
|
||||
biome.theBiomeDecorator = event.newBiomeDecorator;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -384,6 +387,38 @@
|
||||
@@ -384,6 +387,36 @@
|
||||
{
|
||||
double d0 = (double)MathHelper.clamp_float(this.getFloatTemperature(), 0.0F, 1.0F);
|
||||
double d1 = (double)MathHelper.clamp_float(this.getFloatRainfall(), 0.0F, 1.0F);
|
||||
@@ -40,9 +40,7 @@
|
||||
+
|
||||
+ public BiomeDecorator getModdedBiomeDecorator(BiomeDecorator original)
|
||||
+ {
|
||||
+ BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(this, original);
|
||||
+ MinecraftForge.TERRAIN_GEN_BUS.post(event);
|
||||
+ return event.newBiomeDecorator;
|
||||
+ return new DeferredBiomeDecorator(this, original);
|
||||
+ }
|
||||
+
|
||||
+ @SideOnly(Side.CLIENT)
|
||||
|
||||
Reference in new issue
Block a user