World and TileEntity patch work.

TerrtainGen events are removed, 1.13's world gen re-write invalidates them all.
This commit is contained in:
LexManos committed 2018-12-13 01:15:53 -08:00
1 parent b7b5dd5bea
commit f13465012b
111 files changed
+2790 -5201

No files matched your search

@@ -119,8 +119,6 @@ import net.minecraftforge.event.entity.player.SleepingLocationCheckEvent;
import net.minecraftforge.event.entity.player.SleepingTimeCheckEvent;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent;
import net.minecraftforge.event.terraingen.ChunkGeneratorEvent;
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.CreateFluidSourceEvent;
import net.minecraftforge.event.world.BlockEvent.MultiPlaceEvent;
@@ -128,6 +126,7 @@ import net.minecraftforge.event.world.BlockEvent.NeighborNotifyEvent;
import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
import net.minecraftforge.event.world.ExplosionEvent;
import net.minecraftforge.event.world.GetCollisionBoxesEvent;
import net.minecraftforge.event.world.SaplingGrowTreeEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.Result;
@@ -641,18 +640,6 @@ public class ForgeEventFactory
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Throwable(throwable, ray));
}
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.eventbus.api.Event.Result.DENY;
}
public static void onChunkPopulate(boolean pre, IChunkGenerator gen, World world, Random rand, int x, int z, boolean hasVillageGenerated)
{
MinecraftForge.EVENT_BUS.post(pre ? new PopulateChunkEvent.Pre(gen, world, rand, x, z, hasVillageGenerated) : new PopulateChunkEvent.Post(gen, world, rand, x, z, hasVillageGenerated));
}
public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTableManager lootTableManager)
{
LootTableLoadEvent event = new LootTableLoadEvent(name, table, lootTableManager);
@@ -701,4 +688,11 @@ public class ForgeEventFactory
Result result = event.getResult();
return result == Result.DEFAULT ? world.getGameRules().getBoolean("mobGriefing") : result == Result.ALLOW;
}
public static boolean saplingGrowTree(IWorld world, Random rand, BlockPos pos)
{
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(world, rand, pos);
MinecraftForge.EVENT_BUS.post(event);
return event.getResult() != Result.DENY;
}
}
@@ -1,152 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.block.state.IBlockState;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* BiomeEvent is fired whenever an event involving biomes occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}
* unless stated otherwise in their Javadocs.
**/
public class BiomeEvent extends net.minecraftforge.eventbus.api.Event
{
private final Biome biome;
public BiomeEvent(Biome biome)
{
this.biome = biome;
}
public Biome getBiome()
{
return biome;
}
/**
* BiomeColor is fired whenever an event involving biome colors occurs. <br>
* If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.
**/
public static class BiomeColor extends BiomeEvent
{
private final int originalColor;
private int newColor;
public BiomeColor(Biome biome, int original)
{
super(biome);
originalColor = original;
setNewColor(original);
}
public int getOriginalColor()
{
return originalColor;
}
public int getNewColor()
{
return newColor;
}
public void setNewColor(int newColor)
{
this.newColor = newColor;
}
}
/**
* This event is fired when the village generator attempts to choose a block ID
* based on the village's biome.
*
* You can cancel the event to override default values
*/
@HasResult
public static class GetVillageBlockID extends BiomeEvent
{
private final IBlockState original;
private IBlockState replacement;
public GetVillageBlockID(Biome biome, IBlockState original)
{
super(biome);
this.original = original;
}
public IBlockState getOriginal()
{
return original;
}
public IBlockState getReplacement()
{
return replacement;
}
public void setReplacement(IBlockState replacement)
{
this.replacement = replacement;
}
}
/**
* This event is fired when a biome is queried for its grass color.
*/
public static class GetGrassColor extends BiomeColor
{
public GetGrassColor(Biome biome, int original)
{
super(biome, original);
}
}
/**
* This event is fired when a biome is queried for its grass color.
*/
public static class GetFoliageColor extends BiomeColor
{
public GetFoliageColor(Biome biome, int original)
{
super(biome, original);
}
}
/**
* This event is fired when a biome is queried for its water color.
*/
public static class GetWaterColor extends BiomeColor
{
public GetWaterColor(Biome biome, int original)
{
super(biome, original);
}
}
}
@@ -1,111 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
import net.minecraft.world.World;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.gen.IChunkGenSettings;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.eventbus.api.Event.HasResult;
public class ChunkGeneratorEvent extends net.minecraftforge.eventbus.api.Event
{
private final IChunkGenerator<? extends IChunkGenSettings> gen;
public ChunkGeneratorEvent(IChunkGenerator<? extends IChunkGenSettings> gen)
{
this.gen = gen;
}
public IChunkGenerator<? extends IChunkGenSettings> getGenerator() { return this.getGen(); }
public IChunkGenerator<? extends IChunkGenSettings> getGen()
{
return gen;
}
/**
* This event is fired when a chunks blocks are replaced by a biomes top and
* filler blocks.
*
* You can set the result to DENY to prevent the default replacement.
*/
@HasResult
public static class ReplaceBiomeBlocks extends ChunkGeneratorEvent
{
private final int x;
private final int z;
private final ChunkPrimer primer;
private final World world; // CAN BE NULL
public ReplaceBiomeBlocks(IChunkGenerator<? extends IChunkGenSettings> chunkProvider, int x, int z, ChunkPrimer primer, World world)
{
super(chunkProvider);
this.x = x;
this.z = z;
this.primer = primer;
this.world = world;
}
public int getX() { return x; }
public int getZ() { return z; }
public ChunkPrimer getPrimer() { return primer; }
public World getWorld() { return world; }
}
/**
* This event is fired before a chunks terrain noise field is initialized.
*
* You can set the result to DENY to substitute your own noise field.
*/
@HasResult
public static class InitNoiseField extends ChunkGeneratorEvent
{
private double[] noisefield;
private final int posX;
private final int posY;
private final int posZ;
private final int sizeX;
private final int sizeY;
private final int sizeZ;
public InitNoiseField(IChunkGenerator<? extends IChunkGenSettings> chunkProvider, double[] noisefield, int posX, int posY, int posZ, int sizeX, int sizeY, int sizeZ)
{
super(chunkProvider);
this.setNoisefield(noisefield);
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
this.sizeX = sizeX;
this.sizeY = sizeY;
this.sizeZ = sizeZ;
}
public double[] getNoisefield() { return noisefield; }
public void setNoisefield(double[] noisefield) { this.noisefield = noisefield; }
public int getPosX() { return posX; }
public int getPosY() { return posY; }
public int getPosZ() { return posZ; }
public int getSizeX() { return sizeX; }
public int getSizeY() { return sizeY; }
public int getSizeZ() { return sizeZ; }
}
}
@@ -1,144 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* DecorateBiomeEvent is fired when a BiomeDecorator is created.
* <br>
* This event is fired whenever a BiomeDecorator is created in
* {@link DeferredBiomeDecorator#fireCreateEventAndReplace(Biome)}.<br>
* <br>
* {@link #world} contains the world that is being decorated. <br>
* {@link #rand} contains an instance of Random to be used. <br>
* {@link #chunkPos} contains the original chunk for the decorator. <br>
* <br>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.
* <br>
* This event does not have a result. {@link HasResult}
* <br>
* This event is fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.
**/
public class DecorateBiomeEvent extends Event
{
private final World world;
private final Random rand;
private final ChunkPos chunkPos;
public DecorateBiomeEvent(World world, Random rand, ChunkPos chunkPos)
{
this.world = world;
this.rand = rand;
this.chunkPos = chunkPos;
}
public World getWorld()
{
return world;
}
public Random getRand()
{
return rand;
}
public ChunkPos getChunkPos()
{
return chunkPos;
}
/**
* This event is fired before a chunk is decorated with a biome feature.
*/
public static class Pre extends DecorateBiomeEvent
{
public Pre(World world, Random rand, ChunkPos chunkPos)
{
super(world, rand, chunkPos);
}
}
/**
* This event is fired after a chunk is decorated with a biome feature.
*/
public static class Post extends DecorateBiomeEvent
{
public Post(World world, Random rand, ChunkPos chunkPos)
{
super(world, rand, chunkPos);
}
}
/**
* This event is fired when a chunk is decorated with a biome feature.
* <p>
* You can set the result to DENY to prevent the default biome decoration.
*/
@HasResult
public static class Decorate extends DecorateBiomeEvent
{
/**
* Use {@link EventType#CUSTOM} to filter custom event types
*/
public enum EventType
{
BIG_SHROOM, CACTUS, CLAY, DEAD_BUSH, DESERT_WELL, LILYPAD, FLOWERS, FOSSIL, GRASS, ICE, LAKE_WATER, LAKE_LAVA, PUMPKIN, REED, ROCK, SAND, SAND_PASS2, SHROOM, TREE, CUSTOM
}
private final EventType type;
@Nullable
private final BlockPos placementPos;
public Decorate(World world, Random rand, ChunkPos chunkPos, @Nullable BlockPos placementPos, EventType type)
{
super(world, rand, chunkPos);
this.type = type;
this.placementPos = placementPos;
}
public EventType getType()
{
return type;
}
/**
* This may be anywhere inside the 2x2 chunk area for generation.
* To get the original chunk position of the generation before a random location was chosen, use {@link #getChunkPos()}.
*
* @return the position used for original decoration, or null if it is not specified.
*/
@Nullable
public BlockPos getPlacementPos()
{
return this.placementPos;
}
}
}
@@ -1,46 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
import net.minecraftforge.eventbus.api.Event;
public class InitMapGenEvent extends Event
{
/** Use CUSTOM to filter custom event types
*/
public static enum EventType { CAVE, MINESHAFT, NETHER_BRIDGE, NETHER_CAVE, RAVINE, SCATTERED_FEATURE, STRONGHOLD, VILLAGE, OCEAN_MONUMENT, WOODLAND_MANSION, END_CITY, CUSTOM }
/* TODO: Re-Evaluate
private final EventType type;
private final MapGenBase originalGen;
private MapGenBase newGen;
InitMapGenEvent(EventType type, MapGenBase original)
{
this.type = type;
this.originalGen = original;
this.setNewGen(original);
}
public EventType getType() { return type; }
public MapGenBase getOriginalGen() { return originalGen; }
public MapGenBase getNewGen() { return newGen; }
public void setNewGen(MapGenBase newGen) { this.newGen = newGen; }
*/
}
@@ -1,135 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
import java.util.Random;
import net.minecraft.world.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<T extends InitNoiseGensEvent.Context> extends WorldEvent
{
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;
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; }
@Override
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;
}
@Override
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;
}
@Override
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;
}
@Override
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; }
}
}
@@ -1,157 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.eventbus.api.Event;
//import net.minecraft.world.biome.BiomeDecorator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
//import net.minecraft.world.gen.feature.WorldGenerator;
/**
* OreGenEvent is fired when an event involving ore generation occurs.<br>
* If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #world} contains the world this event is occurring in.<br>
* {@link #rand} contains an instance of random that can be used in this event.<br>
* {@link #pos} contains the coordinates of the chunk position currently being populated with ores.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#ORE_GEN_BUS}.<br>
**/
public class OreGenEvent extends Event
{
private final World world;
private final Random rand;
private final BlockPos pos;
public OreGenEvent(World world, Random rand, BlockPos pos)
{
this.world = world;
this.rand = rand;
this.pos = pos;
}
public World getWorld()
{
return world;
}
public Random getRand()
{
return rand;
}
public BlockPos getPos()
{
return pos;
}
/**
* OreGenEvent.Pre is fired just before a chunk is populated with ores.<br>
* This event is fired just before ore generation in
* {@link BiomeDecorator#generateOres(World, Random)}.<br>
* <br>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#ORE_GEN_BUS}.<br>
**/
public static class Pre extends OreGenEvent
{
public Pre(World world, Random rand, BlockPos pos)
{
super(world, rand, pos);
}
}
/**
* OreGenEvent.Post is fired just after a chunk is populated with ores.<br>
* This event is fired just after ore generation in
* {@link BiomeDecorator#generateOres(World, Random)}.<br>
* <br>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#ORE_GEN_BUS}.<br>
**/
public static class Post extends OreGenEvent
{
public Post(World world, Random rand, BlockPos pos)
{
super(world, rand, pos);
}
}
/**
* GenerateMinable is fired when a mineable block is generated in a chunk.<br>
* This event is fired just after ore generation in
* {@link BiomeDecorator#generateOres(World, Random)}.<br>
* <br>
* {@link #type} contains the enum value for the Ore attempting to be generated.<br>
* {@link #generator} contains the WorldGenerator generating this ore. <br>
* <br>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
* <br>
* This event has a result. {@link HasResult} <br>
* This result determines whether the ore is allowed to be generated.<br>
* <br>
* This event is fired on the {@link MinecraftForge#ORE_GEN_BUS}.<br>
**/
/* TODO Re-Evaluate
@HasResult
public static class GenerateMinable extends OreGenEvent
{
public static enum EventType { COAL, DIAMOND, DIRT, GOLD, GRAVEL, IRON, LAPIS, REDSTONE, QUARTZ, DIORITE, GRANITE, ANDESITE, EMERALD, SILVERFISH, CUSTOM }
private final EventType type;
private final WorldGenerator generator;
public GenerateMinable(World world, Random rand, WorldGenerator generator, BlockPos pos, EventType type)
{
super(world, rand, pos);
this.generator = generator;
this.type = type;
}
public EventType getType()
{
return type;
}
public WorldGenerator getGenerator()
{
return generator;
}
}
*/
}
@@ -1,146 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* PopulateChunkEvent is fired when an event involving chunk terrain feature population occurs.<br>
* If a method utilizes this {@link net.minecraftforge.eventbus.api.Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #world} contains the world this event is occurring in.<br>
* {@link #rand} contains an instance of random that can be used in this event.<br>
* {@link #chunkX} contains the x-coordinate of the chunk currently being populated with a terrain feature.<br>
* {@link #chunkZ} contains the z-coordinate of the chunk currently being populated with ores.<br>
* {@link #hasVillageGenerated} contains the boolean value stating if the chunk already has a village spawned in it.<br>
* <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 ChunkGeneratorEvent
{
private final World world;
private final Random rand;
private final int chunkX;
private final int chunkZ;
private final boolean hasVillageGenerated;
public PopulateChunkEvent(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
{
super(gen);
this.world = world;
this.rand = rand;
this.chunkX = chunkX;
this.chunkZ = chunkZ;
this.hasVillageGenerated = hasVillageGenerated;
}
public World getWorld() { return world; }
public Random getRand() { return rand; }
public int getChunkX() { return chunkX; }
public int getChunkZ() { return chunkZ; }
public boolean isHasVillageGenerated() { return hasVillageGenerated; }
/**
* PopulateChunkEvent.Pre is fired just before a chunk is populated a terrain feature.<br>
* This event is fired just before terrain feature generation in
* {@link ChunkProviderEnd#populate(int, int)},
* {@link ChunkProviderOverworld#populate(int, int)},
* and {@link ChunkProviderHell#populate(int, int)}. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public static class Pre extends PopulateChunkEvent
{
public Pre(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
{
super(gen, world, rand, chunkX, chunkZ, hasVillageGenerated);
}
}
/**
* PopulateChunkEvent.Post is fired just after a chunk is populated with a terrain feature.<br>
* This event is fired just after terrain feature generation in
* {@link ChunkProviderEnd#populate(int, int)},
* {@link ChunkProviderOverworld#populate(int, int)},
* and {@link ChunkProviderHell#populate(int, int)}. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
public static class Post extends PopulateChunkEvent
{
public Post(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated)
{
super(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated);
}
}
/**
* PopulateChunkEvent.Populate is fired when a chunk is populated with a terrain feature.<br>
* This event is fired during terrain feature generation in
* {@link ChunkProviderEnd#populate(int, int)},
* {@link ChunkProviderOverworld#populate(int, int)},
* and {@link ChunkProviderHell#populate(int, int)}. <br>
* <br>
* {@link #type} contains the enum value for the terrain feature being generated. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event has a result. {@link HasResult} <br>
* This result determines if the chunk is populated with the terrain feature. <br>
* <br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
**/
@HasResult
public static class Populate extends PopulateChunkEvent
{
public EventType getType()
{
return type;
}
/** Use CUSTOM to filter custom event types
*/
public static enum EventType { DUNGEON, FIRE, GLOWSTONE, ICE, LAKE, LAVA, NETHER_LAVA, NETHER_LAVA2, NETHER_MAGMA, ANIMALS, CUSTOM }
private final EventType type;
public Populate(IChunkGenerator gen, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated, EventType type)
{
super(gen, world, rand, chunkX, chunkZ, hasVillageGenerated);
this.type = type;
}
}
}
@@ -1,117 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.DecorateBiomeEvent.Decorate;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate;
import net.minecraftforge.eventbus.api.Event.Result;
//import net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable;
import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate;
import net.minecraftforge.eventbus.api.Event.Result;
public abstract class TerrainGen
{
public static <T extends InitNoiseGensEvent.Context> T getModdedNoiseGenerators(World world, Random rand, T original)
{
InitNoiseGensEvent<T> event = new InitNoiseGensEvent<>(world, rand, original);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getNewValues();
}
/* TODO Re-Evaluate
public static MapGenBase getModdedMapGen(MapGenBase original, InitMapGenEvent.EventType type)
{
InitMapGenEvent event = new InitMapGenEvent(type, original);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getNewGen();
}
*/
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);
return event.getResult() != Result.DENY;
}
/**
* Use this method when there is a specific BlockPos location given for decoration.
* If only the chunk position is available, use {@link #decorate(World, Random, ChunkPos, Decorate.EventType)} instead.
*
* @param world the world being generated in
* @param rand the random generator used for decoration
* @param chunkPos the original chunk position used for generation, passed to the decorator
* @param placementPos the specific position used for generating a feature, somewhere in the 2x2 chunks used for decoration
* @param type the type of decoration
*/
public static boolean decorate(World world, Random rand, ChunkPos chunkPos, BlockPos placementPos, Decorate.EventType type)
{
Decorate event = new Decorate(world, rand, chunkPos, placementPos, type);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
/**
* Use this method when generation doesn't have a specific BlockPos location for generation in the chunk.
* If a specific BlockPos for generation is available, use {@link #decorate(World, Random, ChunkPos, BlockPos, Decorate.EventType)} instead.
*
* @param world the world being generated in
* @param rand the random generator used for decoration
* @param chunkPos the original chunk position used for generation, passed to the decorator
* @param type the type of decoration
*/
public static boolean decorate(World world, Random rand, ChunkPos chunkPos, Decorate.EventType type)
{
Decorate event = new Decorate(world, rand, chunkPos, null, type);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
@Deprecated
public static boolean decorate(World world, Random rand, BlockPos pos, Decorate.EventType type)
{
return decorate(world, rand, new ChunkPos(pos), type);
}
/* TODO Re-Evaluate
public static boolean generateOre(World world, Random rand, WorldGenerator generator, BlockPos pos, GenerateMinable.EventType type)
{
GenerateMinable event = new GenerateMinable(world, rand, generator, pos, type);
MinecraftForge.ORE_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
*/
public static boolean saplingGrowTree(IWorld world, Random rand, BlockPos pos)
{
SaplingGrowTreeEvent event = new SaplingGrowTreeEvent(world, rand, pos);
MinecraftForge.TERRAIN_GEN_BUS.post(event);
return event.getResult() != Result.DENY;
}
}
@@ -1,144 +0,0 @@
/*
* Minecraft Forge
* Copyright (c) 2016-2018.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraft.world.WorldType;
/**
* WorldTypeEvent is fired when an event involving the world occurs.<br>
* If a method utilizes this {@link Event} as its parameter, the method will
* receive every child event of this class.<br>
* <br>
* {@link #worldType} contains the WorldType of the world this event is occurring in.<br>
* <br>
* All children of this event are fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.<br>
**/
public class WorldTypeEvent extends Event
{
private final WorldType worldType;
public WorldTypeEvent(WorldType worldType)
{
this.worldType = worldType;
}
public WorldType getWorldType()
{
return worldType;
}
/**
* BiomeSize is fired when vanilla Minecraft attempts to generate biomes.<br>
* This event is fired during biome generation in
* {@link GenLayer#initializeAllBiomeGenerators(long, WorldType, ChunkProviderSettings)}. <br>
* <br>
* {@link #originalSize} the original size of the Biome. <br>
* {@link #newSize} the new size of the biome. Initially set to the {@link #originalSize}. <br>
* If {@link #newSize} is set to a new value, that value will be used for the Biome size. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.<br>
**/
public static class BiomeSize extends WorldTypeEvent
{
private final int originalSize;
private int newSize;
public BiomeSize(WorldType worldType, int original)
{
super(worldType);
originalSize = original;
setNewSize(original);
}
public int getOriginalSize()
{
return originalSize;
}
public int getNewSize()
{
return newSize;
}
public void setNewSize(int newSize)
{
this.newSize = newSize;
}
}
/**
* InitBiomeGens is fired when vanilla Minecraft attempts to initialize the biome providers.<br>
* This event is fired just during biome provider initialization in
* {@link BiomeProvider#BiomeProvider(long, WorldType, String)}. <br>
* <br>
* {@link #seed} the seed of the world. <br>
* {@link #originalBiomeGens} the array of GenLayers original intended for this Biome generation. <br>
* {@link #newBiomeGens} the array of GenLayers that will now be used for this Biome generation. <br>
* If {@link #newBiomeGens} is set to a new value, that value will be used for the Biome generator. <br>
* <br>
* This event is not {@link Cancelable}.<br>
* <br>
* This event does not have a result. {@link HasResult} <br>
* <br>
* This event is fired on the {@link MinecraftForge#TERRAIN_GEN_BUS}.<br>
**/
public static class InitBiomeGens extends WorldTypeEvent
{
private final long seed;
private final GenLayer[] originalBiomeGens;
private GenLayer[] newBiomeGens;
public InitBiomeGens(WorldType worldType, long seed, GenLayer[] original)
{
super(worldType);
this.seed = seed;
originalBiomeGens = original;
setNewBiomeGens(original.clone());
}
public long getSeed()
{
return seed;
}
public GenLayer[] getOriginalBiomeGens()
{
return originalBiomeGens;
}
public GenLayer[] getNewBiomeGens()
{
return newBiomeGens;
}
public void setNewBiomeGens(GenLayer[] newBiomeGens)
{
this.newBiomeGens = newBiomeGens;
}
}
}
@@ -20,7 +20,7 @@
package net.minecraftforge.event.world;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
import net.minecraftforge.common.MinecraftForge;
@@ -40,17 +40,17 @@ public class ChunkDataEvent extends ChunkEvent
{
private final NBTTagCompound data;
public ChunkDataEvent(Chunk chunk, NBTTagCompound data)
public ChunkDataEvent(IChunk chunk, NBTTagCompound data)
{
super(chunk);
this.data = data;
}
public NBTTagCompound getData()
{
return data;
}
/**
* ChunkDataEvent.Load is fired when vanilla Minecraft attempts to load Chunk data.<br>
* This event is fired during chunk loading in
@@ -64,15 +64,15 @@ public class ChunkDataEvent extends ChunkEvent
**/
public static class Load extends ChunkDataEvent
{
public Load(Chunk chunk, NBTTagCompound data)
public Load(IChunk chunk, NBTTagCompound data)
{
super(chunk, data);
}
}
/**
* ChunkDataEvent.Save is fired when vanilla Minecraft attempts to save Chunk data.<br>
* This event is fired during chunk saving in
* This event is fired during chunk saving in
* {@link AnvilChunkLoader#saveChunk(World, Chunk)}. <br>
* <br>
* This event is not {@link net.minecraftforge.eventbus.api.Cancelable}.<br>
@@ -83,7 +83,7 @@ public class ChunkDataEvent extends ChunkEvent
**/
public static class Save extends ChunkDataEvent
{
public Save(Chunk chunk, NBTTagCompound data)
public Save(IChunk chunk, NBTTagCompound data)
{
super(chunk, data);
}
@@ -20,10 +20,8 @@
package net.minecraftforge.event.world;
import net.minecraft.client.multiplayer.ChunkProviderClient;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunk;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
/**
* ChunkEvent is fired when an event involving a chunk occurs.<br>
@@ -36,15 +34,15 @@ import net.minecraftforge.eventbus.api.Event;
**/
public class ChunkEvent extends WorldEvent
{
private final Chunk chunk;
private final IChunk chunk;
public ChunkEvent(Chunk chunk)
public ChunkEvent(IChunk chunk)
{
super(chunk.getWorld());
this.chunk = chunk;
}
public Chunk getChunk()
public IChunk getChunk()
{
return chunk;
}
@@ -63,7 +61,7 @@ public class ChunkEvent extends WorldEvent
**/
public static class Load extends ChunkEvent
{
public Load(Chunk chunk)
public Load(IChunk chunk)
{
super(chunk);
}
@@ -82,7 +80,7 @@ public class ChunkEvent extends WorldEvent
**/
public static class Unload extends ChunkEvent
{
public Unload(Chunk chunk)
public Unload(IChunk chunk)
{
super(chunk);
}
@@ -17,7 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.event.terraingen;
package net.minecraftforge.event.world;
import java.util.Random;
@@ -29,7 +29,6 @@ import net.minecraftforge.eventbus.api.Event.HasResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraftforge.event.world.WorldEvent;
/**
* SaplingGrowTreeEvent is fired when a sapling grows into a tree.<br>