mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 01:04:24 +00:00
World Patches work.
This commit is contained in:
1 parent
8a506022d7
commit
74b2c3dfe6
41 files changed
+810
-936
No files matched your search
@@ -24,17 +24,9 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
public class ChestGenHooks
|
||||
{
|
||||
//Currently implemented categories for chests/dispensers, Dungeon loot is still in DungeonHooks
|
||||
public static final String MINESHAFT_CORRIDOR = "mineshaftCorridor";
|
||||
public static final String PYRAMID_DESERT_CHEST = "pyramidDesertyChest";
|
||||
public static final String PYRAMID_JUNGLE_CHEST = "pyramidJungleChest";
|
||||
public static final String PYRAMID_JUNGLE_DISPENSER = "pyramidJungleDispenser";
|
||||
public static final String STRONGHOLD_CORRIDOR = "strongholdCorridor";
|
||||
public static final String STRONGHOLD_LIBRARY = "strongholdLibrary";
|
||||
public static final String STRONGHOLD_CROSSING = "strongholdCrossing";
|
||||
public static final String VILLAGE_BLACKSMITH = "villageBlacksmith";
|
||||
public static final String PYRAMID_JUNGLE_DISPENSER = "pyramidJungleDispenser"; // TODO: Convert to a Loot Table
|
||||
public static final String BONUS_CHEST = "bonusChest";
|
||||
public static final String DUNGEON_CHEST = "dungeonChest";
|
||||
public static final String NETHER_FORTRESS = "netherFortress";
|
||||
|
||||
private static final HashMap<String, ChestGenHooks> chestInfo = new HashMap<String, ChestGenHooks>();
|
||||
private static boolean hasInit = false;
|
||||
@@ -53,15 +45,7 @@ public class ChestGenHooks
|
||||
hasInit = true;
|
||||
// This causes the classes static initializers to run
|
||||
new WorldGenDungeons();
|
||||
new DesertPyramid();
|
||||
new JunglePyramid();
|
||||
new StructureMineshaftPieces();
|
||||
new StructureOceanMonument();
|
||||
new StructureStrongholdPieces.ChestCorridor();
|
||||
new StructureStrongholdPieces.Library();
|
||||
new StructureStrongholdPieces.RoomCrossing();
|
||||
new StructureVillagePieces.House2();
|
||||
new StructureNetherBridgePieces.Corridor();
|
||||
WorldServer.fillChestHook();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.ChunkPrimer;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.storage.IPlayerFileData;
|
||||
import net.minecraft.world.storage.SaveHandler;
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
||||
@@ -73,6 +75,8 @@ import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerWakeUpEvent;
|
||||
import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent;
|
||||
import net.minecraftforge.event.entity.player.UseHoeEvent;
|
||||
import net.minecraftforge.event.terraingen.ChunkGeneratorEvent;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.NeighborNotifyEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent.MultiPlaceEvent;
|
||||
@@ -521,7 +525,10 @@ public class ForgeEventFactory
|
||||
|
||||
Result canContinueSleep = evt.getResult();
|
||||
if (canContinueSleep == Result.DEFAULT)
|
||||
return player.worldObj.getBlockState(player.playerLocation).getBlock().isBed(player.worldObj, player.playerLocation, player);
|
||||
{
|
||||
IBlockState state = player.worldObj.getBlockState(player.playerLocation);
|
||||
return state.getBlock().isBed(state, player.worldObj, player.playerLocation, player);
|
||||
}
|
||||
else
|
||||
return canContinueSleep == Result.ALLOW;
|
||||
}
|
||||
@@ -542,4 +549,16 @@ public class ForgeEventFactory
|
||||
return event.getCharge();
|
||||
}
|
||||
|
||||
public static boolean onReplaceBiomeBlocks(IChunkGenerator gen, int x, int z, ChunkPrimer primer, World world)
|
||||
{
|
||||
ChunkGeneratorEvent.ReplaceBiomeBlocks event = new ChunkGeneratorEvent.ReplaceBiomeBlocks(gen, x, z, primer, world);
|
||||
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getResult() != net.minecraftforge.fml.common.eventhandler.Event.Result.DENY;
|
||||
}
|
||||
|
||||
public static void onChunkPopulate(boolean pre, IChunkGenerator gen, World world, int x, int z, boolean hasVillageGenerated)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(gen, world, world.rand, x, z, hasVillageGenerated));
|
||||
}
|
||||
|
||||
}
|
||||
+11
-10
@@ -3,18 +3,19 @@ package net.minecraftforge.event.terraingen;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.ChunkPrimer;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
|
||||
public class ChunkProviderEvent extends Event
|
||||
public class ChunkGeneratorEvent extends Event
|
||||
{
|
||||
private final IChunkGenerator gen;
|
||||
|
||||
public final IChunkProvider chunkProvider;
|
||||
|
||||
public ChunkProviderEvent(IChunkProvider chunkProvider)
|
||||
public ChunkGeneratorEvent(IChunkGenerator gen)
|
||||
{
|
||||
this.chunkProvider = chunkProvider;
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
public IChunkGenerator getGenerator() { return this.gen; }
|
||||
|
||||
/**
|
||||
* This event is fired when a chunks blocks are replaced by a biomes top and
|
||||
* filler blocks.
|
||||
@@ -22,14 +23,14 @@ public class ChunkProviderEvent extends Event
|
||||
* You can set the result to DENY to prevent the default replacement.
|
||||
*/
|
||||
@HasResult
|
||||
public static class ReplaceBiomeBlocks extends ChunkProviderEvent
|
||||
public static class ReplaceBiomeBlocks extends ChunkGeneratorEvent
|
||||
{
|
||||
public final int x;
|
||||
public final int z;
|
||||
public final ChunkPrimer primer;
|
||||
public final World world; // CAN BE NULL
|
||||
|
||||
public ReplaceBiomeBlocks(IChunkProvider chunkProvider, int x, int z, ChunkPrimer primer, World world)
|
||||
public ReplaceBiomeBlocks(IChunkGenerator chunkProvider, int x, int z, ChunkPrimer primer, World world)
|
||||
{
|
||||
super(chunkProvider);
|
||||
this.x = x;
|
||||
@@ -46,7 +47,7 @@ public class ChunkProviderEvent extends Event
|
||||
* You can set the result to DENY to substitute your own noise field.
|
||||
*/
|
||||
@HasResult
|
||||
public static class InitNoiseField extends ChunkProviderEvent
|
||||
public static class InitNoiseField extends ChunkGeneratorEvent
|
||||
{
|
||||
public double[] noisefield;
|
||||
public final int posX;
|
||||
@@ -56,7 +57,7 @@ public class ChunkProviderEvent extends Event
|
||||
public final int sizeY;
|
||||
public final int sizeZ;
|
||||
|
||||
public InitNoiseField(IChunkProvider chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ)
|
||||
public InitNoiseField(IChunkGenerator chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ)
|
||||
{
|
||||
super(chunkProvider);
|
||||
this.noisefield = noisefield;
|
||||
@@ -3,20 +3,110 @@ package net.minecraftforge.event.terraingen;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.NoiseGenerator;
|
||||
import net.minecraftforge.event.world.*;
|
||||
import net.minecraft.world.gen.NoiseGeneratorOctaves;
|
||||
import net.minecraft.world.gen.NoiseGeneratorPerlin;
|
||||
import net.minecraft.world.gen.NoiseGeneratorSimplex;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
|
||||
public class InitNoiseGensEvent extends WorldEvent
|
||||
public class InitNoiseGensEvent<T extends InitNoiseGensEvent.Context> extends WorldEvent
|
||||
{
|
||||
public final Random rand;
|
||||
public final NoiseGenerator[] originalNoiseGens;
|
||||
public NoiseGenerator[] newNoiseGens;
|
||||
|
||||
public InitNoiseGensEvent(World world, Random rand, NoiseGenerator[] original)
|
||||
private final Random rand;
|
||||
private final T original;
|
||||
private T newValues;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public InitNoiseGensEvent(World world, Random rand, T original)
|
||||
{
|
||||
super(world);
|
||||
this.rand = rand;
|
||||
originalNoiseGens = original;
|
||||
newNoiseGens = original.clone();
|
||||
this.original = original;
|
||||
this.newValues = (T)original.clone();
|
||||
}
|
||||
public Random getRandom() { return this.rand; }
|
||||
public T getOriginal() { return this.original; }
|
||||
public T getNewValues() { return this.newValues; }
|
||||
|
||||
public static class Context
|
||||
{
|
||||
private NoiseGeneratorOctaves lperlin1;
|
||||
private NoiseGeneratorOctaves lperlin2;
|
||||
private NoiseGeneratorOctaves perlin;
|
||||
private NoiseGeneratorOctaves scale;
|
||||
private NoiseGeneratorOctaves depth;
|
||||
public Context(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin,
|
||||
NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth)
|
||||
{
|
||||
this.lperlin1 = lperlin1;
|
||||
this.lperlin2 = lperlin2;
|
||||
this.perlin = perlin;
|
||||
this.scale = scale;
|
||||
this.depth = depth;
|
||||
}
|
||||
public NoiseGeneratorOctaves getLPerlin1() { return lperlin1; }
|
||||
public NoiseGeneratorOctaves getLPerlin2() { return lperlin2; }
|
||||
public NoiseGeneratorOctaves getPerlin() { return perlin; }
|
||||
public NoiseGeneratorOctaves getScale() { return scale; }
|
||||
public NoiseGeneratorOctaves getDepth() { return depth; }
|
||||
public void setLPerlin1(NoiseGeneratorOctaves value) { this.lperlin1 = value; }
|
||||
public void getLPerlin2(NoiseGeneratorOctaves value) { this.lperlin2 = value; }
|
||||
public void getPerlin (NoiseGeneratorOctaves value) { this.perlin = value; }
|
||||
public void getScale (NoiseGeneratorOctaves value) { this.scale = value; }
|
||||
public void getDepth (NoiseGeneratorOctaves value) { this.depth = value; }
|
||||
|
||||
public Context clone(){ return new Context(lperlin1, lperlin2, perlin, scale, depth); }
|
||||
}
|
||||
|
||||
public static class ContextOverworld extends Context
|
||||
{
|
||||
private NoiseGeneratorPerlin height;
|
||||
private NoiseGeneratorOctaves forest;
|
||||
|
||||
public ContextOverworld(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin,
|
||||
NoiseGeneratorPerlin height, NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth, NoiseGeneratorOctaves forest)
|
||||
{
|
||||
super(lperlin1, lperlin2, perlin, scale, depth);
|
||||
this.height = height;
|
||||
this.forest = forest;
|
||||
}
|
||||
public ContextOverworld clone() { return new ContextOverworld(getLPerlin1(), getLPerlin2(), getPerlin(), height, getScale(), getDepth(), forest); }
|
||||
public NoiseGeneratorPerlin getHeight() { return height; }
|
||||
public NoiseGeneratorOctaves getForest() { return forest; }
|
||||
|
||||
public void getHeight (NoiseGeneratorPerlin value) { this.height = value; }
|
||||
public void getForest (NoiseGeneratorOctaves value) { this.forest = value; }
|
||||
}
|
||||
|
||||
public static class ContextEnd extends Context
|
||||
{
|
||||
private NoiseGeneratorSimplex island;
|
||||
public ContextEnd(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin,
|
||||
NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth, NoiseGeneratorSimplex island)
|
||||
{
|
||||
super(lperlin1, lperlin2, perlin, scale, depth);
|
||||
this.island = island;
|
||||
}
|
||||
public ContextEnd clone() { return new ContextEnd(getLPerlin1(), getLPerlin2(), getPerlin(), getScale(), getDepth(), island); }
|
||||
public NoiseGeneratorSimplex getIsland() { return island; }
|
||||
public void getIsland (NoiseGeneratorSimplex value) { this.island = value; }
|
||||
}
|
||||
|
||||
|
||||
public static class ContextHell extends Context
|
||||
{
|
||||
private NoiseGeneratorOctaves perlin2;
|
||||
private NoiseGeneratorOctaves perlin3;
|
||||
|
||||
public ContextHell(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin,
|
||||
NoiseGeneratorOctaves perlin2, NoiseGeneratorOctaves perlin3, NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth)
|
||||
{
|
||||
super(lperlin1, lperlin2, perlin, scale, depth);
|
||||
this.perlin2 = perlin2;
|
||||
this.perlin3 = perlin3;
|
||||
}
|
||||
public ContextHell clone() { return new ContextHell(getLPerlin1(), getLPerlin2(), getPerlin(), perlin2, perlin3, getScale(), getDepth()); }
|
||||
public NoiseGeneratorOctaves getPerlin2() { return perlin2; }
|
||||
public NoiseGeneratorOctaves getPerlin3() { return perlin3; }
|
||||
public void getPerlin2 (NoiseGeneratorOctaves value) { this.perlin2 = value; }
|
||||
public void getPerlin3 (NoiseGeneratorOctaves value) { this.perlin3 = value; }
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.util.Random;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.HasResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,7 @@ import net.minecraft.world.chunk.IChunkProvider;
|
||||
* <br>
|
||||
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}, except {@link Populate}, which fires on the {@link MinecraftForge#TERRAIN_GEN_BUS}.<br>
|
||||
**/
|
||||
public class PopulateChunkEvent extends ChunkProviderEvent
|
||||
public class PopulateChunkEvent extends ChunkGeneratorEvent
|
||||
{
|
||||
public final World world;
|
||||
public final Random rand;
|
||||
@@ -28,9 +29,9 @@ public class PopulateChunkEvent extends ChunkProviderEvent
|
||||
public final int chunkZ;
|
||||
public final boolean hasVillageGenerated;
|
||||
|
||||
public PopulateChunkEvent(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
|
||||
public PopulateChunkEvent(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
|
||||
{
|
||||
super(chunkProvider);
|
||||
super(gen);
|
||||
this.world = world;
|
||||
this.rand = rand;
|
||||
this.chunkX = chunkX;
|
||||
@@ -53,9 +54,9 @@ public class PopulateChunkEvent extends ChunkProviderEvent
|
||||
**/
|
||||
public static class Pre extends PopulateChunkEvent
|
||||
{
|
||||
public Pre(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
|
||||
public Pre(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
|
||||
{
|
||||
super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated);
|
||||
super(gen, world, rand, chunkX, chunkZ, hasVillageGenerated);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ public class PopulateChunkEvent extends ChunkProviderEvent
|
||||
**/
|
||||
public static class Post extends PopulateChunkEvent
|
||||
{
|
||||
public Post(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
|
||||
public Post(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
|
||||
{
|
||||
super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated);
|
||||
}
|
||||
@@ -105,9 +106,9 @@ public class PopulateChunkEvent extends ChunkProviderEvent
|
||||
|
||||
public final EventType type;
|
||||
|
||||
public Populate(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, EventType type)
|
||||
public Populate(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, EventType type)
|
||||
{
|
||||
super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated);
|
||||
super(gen, world, rand, chunkX, chunkZ, hasVillageGenerated);
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Random;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.MapGenBase;
|
||||
import net.minecraft.world.gen.NoiseGenerator;
|
||||
@@ -15,11 +16,11 @@ import net.minecraftforge.event.terraingen.PopulateChunkEvent.*;
|
||||
|
||||
public abstract class TerrainGen
|
||||
{
|
||||
public static NoiseGenerator[] getModdedNoiseGenerators(World world, Random rand, NoiseGenerator[] original)
|
||||
public static <T extends InitNoiseGensEvent.Context> T getModdedNoiseGenerators(World world, Random rand, T original)
|
||||
{
|
||||
InitNoiseGensEvent event = new InitNoiseGensEvent(world, rand, original);
|
||||
InitNoiseGensEvent<T> event = new InitNoiseGensEvent<T>(world, rand, original);
|
||||
MinecraftForge.TERRAIN_GEN_BUS.post(event);
|
||||
return event.newNoiseGens;
|
||||
return event.getNewValues();
|
||||
}
|
||||
|
||||
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
|
||||
@@ -29,7 +30,7 @@ public abstract class TerrainGen
|
||||
return event.newGen;
|
||||
}
|
||||
|
||||
public static boolean populate(IChunkProvider chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type)
|
||||
public static boolean populate(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, Populate.EventType type)
|
||||
{
|
||||
PopulateChunkEvent.Populate event = new PopulateChunkEvent.Populate(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated, type);
|
||||
MinecraftForge.TERRAIN_GEN_BUS.post(event);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* are made available under the terms of the GNU Lesser Public License v2.1
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* cpw - implementation
|
||||
*/
|
||||
@@ -15,11 +15,12 @@ package net.minecraftforge.fml.common;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
|
||||
|
||||
/**
|
||||
* This is called back during world generation.
|
||||
* This is called back during world generation.
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
@@ -37,5 +38,5 @@ public interface IWorldGenerator
|
||||
* @param chunkProvider : additionalData[2] {@link IChunkProvider} that is requesting the world generation.
|
||||
*
|
||||
*/
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider);
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider);
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkGenerator;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.IFuelHandler;
|
||||
@@ -94,7 +95,7 @@ public class GameRegistry
|
||||
* @param chunkGenerator The chunk generator
|
||||
* @param chunkProvider The chunk provider
|
||||
*/
|
||||
public static void generateWorld(int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider)
|
||||
public static void generateWorld(int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
|
||||
{
|
||||
if (sortedGeneratorList == null)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user