mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 18:45:09 +00:00
World and TileEntity patch work.
TerrtainGen events are removed, 1.13's world gen re-write invalidates them all.
This commit is contained in:
1 parent
b7b5dd5bea
commit
f13465012b
111 files changed
+2790
-5201
No files matched your search
@@ -50,6 +50,7 @@ import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunk;
|
||||
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
||||
import net.minecraft.world.storage.ThreadedFileIOBase;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
@@ -143,18 +144,6 @@ public class ForgeChunkManager
|
||||
}
|
||||
}
|
||||
|
||||
public static Iterator<Chunk> getPersistentChunksIterableFor(final World world, Iterator<Chunk> chunkIterator)
|
||||
{
|
||||
final ImmutableSetMultimap<ChunkPos, Ticket> persistentChunksFor = getPersistentChunksFor(world);
|
||||
final ImmutableSet.Builder<Chunk> builder = ImmutableSet.builder();
|
||||
world.profiler.startSection("forcedChunkLoading");
|
||||
builder.addAll(persistentChunksFor.keys().stream().filter(Objects::nonNull).map(input -> world.getChunk(input.x, input.z)).iterator());
|
||||
world.profiler.endStartSection("regularChunkLoading");
|
||||
builder.addAll(chunkIterator);
|
||||
world.profiler.endSection();
|
||||
return builder.build().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* All mods requiring chunkloading need to implement this to handle the
|
||||
* re-registration of chunk tickets at world loading time
|
||||
@@ -994,25 +983,29 @@ public class ForgeChunkManager
|
||||
}
|
||||
}
|
||||
|
||||
public static void storeChunkNBT(Chunk chunk, NBTTagCompound nbt)
|
||||
public static void storeChunkNBT(World world, IChunk ichunk, NBTTagCompound nbt)
|
||||
{
|
||||
if (dormantChunkCacheSize == 0) return;
|
||||
|
||||
Cache<Long, ChunkEntry> cache = dormantChunkCache.get(chunk.getWorld());
|
||||
Cache<Long, ChunkEntry> cache = dormantChunkCache.get(world);
|
||||
if (cache == null) return;
|
||||
|
||||
ChunkEntry entry = cache.getIfPresent(ChunkPos.asLong(chunk.x, chunk.z));
|
||||
ChunkEntry entry = cache.getIfPresent(ichunk.getPos().asLong());
|
||||
if (entry != null)
|
||||
{
|
||||
entry.nbt.setTag("Entities", nbt.getList("Entities", Constants.NBT.TAG_COMPOUND));
|
||||
entry.nbt.setTag("TileEntities", nbt.getList("TileEntities", Constants.NBT.TAG_COMPOUND));
|
||||
|
||||
ClassInheritanceMultiMap<Entity>[] entityLists = chunk.getEntityLists();
|
||||
for (int i = 0; i < entityLists.length; ++i)
|
||||
if (ichunk instanceof Chunk)
|
||||
{
|
||||
entityLists[i] = new ClassInheritanceMultiMap<>(Entity.class);
|
||||
Chunk chunk = (Chunk)ichunk;
|
||||
ClassInheritanceMultiMap<Entity>[] entityLists = chunk.getEntityLists();
|
||||
for (int i = 0; i < entityLists.length; ++i)
|
||||
{
|
||||
entityLists[i] = new ClassInheritanceMultiMap<>(Entity.class);
|
||||
}
|
||||
chunk.getTileEntityMap().clear();
|
||||
}
|
||||
chunk.getTileEntityMap().clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -154,12 +154,16 @@ public class ForgeConfig
|
||||
public static int clumpingThreshold() {
|
||||
return ForgeConfig.INSTANCE.configData.<Integer>getOrElse("general.clumpingThreshold", 64);
|
||||
}
|
||||
public static boolean removeErroringEntities() {
|
||||
return ForgeConfig.INSTANCE.configData.<Boolean>getOrElse("general.removeErroringEntities", false);
|
||||
}
|
||||
public static boolean removeErroringTileEntities() {
|
||||
return ForgeConfig.INSTANCE.configData.<Boolean>getOrElse("general.removeErroringTileEntities", false);
|
||||
}
|
||||
}
|
||||
|
||||
//General
|
||||
//public static boolean disableVersionCheck = false;
|
||||
//public static boolean removeErroringEntities = false;
|
||||
//public static boolean removeErroringTileEntities = false;
|
||||
//public static boolean fullBoundingBoxLadders = false;
|
||||
//public static boolean logCascadingWorldGeneration = true; // see Chunk#logCascadingWorldGeneration()
|
||||
//public static boolean fixVanillaCascading = false;
|
||||
|
||||
@@ -43,8 +43,6 @@ public class MinecraftForge
|
||||
* EVENT_BUS for everything else
|
||||
*/
|
||||
public static final IEventBus EVENT_BUS = IEventBus.create();
|
||||
public static final IEventBus TERRAIN_GEN_BUS = IEventBus.create();
|
||||
public static final IEventBus ORE_GEN_BUS = IEventBus.create();
|
||||
|
||||
static final ForgeInternalHandler INTERNAL_HANDLER = new ForgeInternalHandler();
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@@ -22,9 +22,18 @@ package net.minecraftforge.common.extensions;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.audio.MusicTicker;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.dimension.Dimension;
|
||||
import net.minecraft.world.dimension.NetherDimension;
|
||||
import net.minecraft.world.storage.WorldInfo;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.IRenderHandler;
|
||||
@@ -105,12 +114,12 @@ public interface IForgeDimension
|
||||
|
||||
void resetRainAndThunder();
|
||||
|
||||
default boolean canDoLightning(net.minecraft.world.chunk.Chunk chunk)
|
||||
default boolean canDoLightning(Chunk chunk)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean canDoRainSnowIce(net.minecraft.world.chunk.Chunk chunk)
|
||||
default boolean canDoRainSnowIce(Chunk chunk)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -126,4 +135,152 @@ public interface IForgeDimension
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
default Biome getBiome(BlockPos pos)
|
||||
{
|
||||
return getDimension().getWorld().getBiomeBody(pos);
|
||||
}
|
||||
|
||||
default boolean isDaytime()
|
||||
{
|
||||
return getDimension().getWorld().getSkylightSubtracted() < 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* The current sun brightness factor for this dimension.
|
||||
* 0.0f means no light at all, and 1.0f means maximum sunlight.
|
||||
* This will be used for the "calculateSkylightSubtracted"
|
||||
* which is for Sky light value calculation.
|
||||
*
|
||||
* @return The current brightness factor
|
||||
**/
|
||||
default float getSunBrightnessFactor(float partialTicks)
|
||||
{
|
||||
return getDimension().getWorld().getSunBrightnessFactor(partialTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Sun Brightness for rendering sky.
|
||||
* */
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default float getSunBrightness(float partialTicks)
|
||||
{
|
||||
return getDimension().getWorld().getSunBrightnessBody(partialTicks);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default Vec3d getSkyColor(Entity cameraEntity, float partialTicks)
|
||||
{
|
||||
return getDimension().getWorld().getSkyColorBody(cameraEntity, partialTicks);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default Vec3d getCloudColor(float partialTicks)
|
||||
{
|
||||
return getDimension().getWorld().getCloudColorBody(partialTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the current moon phase factor.
|
||||
* This factor is effective for slimes.
|
||||
* (This method do not affect the moon rendering)
|
||||
* */
|
||||
default float getCurrentMoonPhaseFactor(long time)
|
||||
{
|
||||
return Dimension.MOON_PHASE_FACTORS[this.getDimension().getMoonPhase(time)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Star Brightness for rendering sky.
|
||||
* */
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
default float getStarBrightness(float partialTicks)
|
||||
{
|
||||
float f = getDimension().getWorld().getCelestialAngle(partialTicks);
|
||||
float f1 = 1.0F - (MathHelper.cos(f * ((float)Math.PI * 2F)) * 2.0F + 0.25F);
|
||||
f1 = MathHelper.clamp(f1, 0.0F, 1.0F);
|
||||
return f1 * f1 * 0.5F;
|
||||
}
|
||||
|
||||
default void setAllowedSpawnTypes(boolean allowHostile, boolean allowPeaceful) { }
|
||||
|
||||
default void calculateInitialWeather()
|
||||
{
|
||||
getDimension().getWorld().calculateInitialWeatherBody();
|
||||
}
|
||||
|
||||
default void updateWeather()
|
||||
{
|
||||
getDimension().getWorld().updateWeatherBody();
|
||||
}
|
||||
|
||||
default long getSeed()
|
||||
{
|
||||
return getDimension().getWorld().getWorldInfo().getSeed();
|
||||
}
|
||||
|
||||
default long getWorldTime()
|
||||
{
|
||||
return getDimension().getWorld().getWorldInfo().getDayTime();
|
||||
}
|
||||
|
||||
default void setWorldTime(long time)
|
||||
{
|
||||
getDimension().getWorld().getWorldInfo().setDayTime(time);
|
||||
}
|
||||
|
||||
default BlockPos getSpawnPoint()
|
||||
{
|
||||
WorldInfo info = getDimension().getWorld().getWorldInfo();
|
||||
return new BlockPos(info.getSpawnX(), info.getSpawnY(), info.getSpawnZ());
|
||||
}
|
||||
|
||||
default void setSpawnPoint(BlockPos pos)
|
||||
{
|
||||
getDimension().getWorld().getWorldInfo().setSpawn(pos);
|
||||
}
|
||||
|
||||
default boolean canMineBlock(EntityPlayer player, BlockPos pos)
|
||||
{
|
||||
return getDimension().getWorld().canMineBlockBody(player, pos);
|
||||
}
|
||||
|
||||
default boolean isHighHumidity(BlockPos pos)
|
||||
{
|
||||
return getDimension().getWorld().getBiome(pos).isHighHumidity();
|
||||
}
|
||||
|
||||
default int getHeight()
|
||||
{
|
||||
return 256;
|
||||
}
|
||||
|
||||
default int getActualHeight()
|
||||
{
|
||||
return getDimension().isNether() ? 128 : 256;
|
||||
}
|
||||
|
||||
default double getHorizon()
|
||||
{
|
||||
return getDimension().getWorld().getWorldInfo().getTerrainType().getHorizon(getDimension().getWorld());
|
||||
}
|
||||
|
||||
default String getSaveFolder()
|
||||
{
|
||||
return getId() == 0 ? null : "DIM" + getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the cursor on the map should 'spin' when rendered, like it does for the player in the nether.
|
||||
*
|
||||
* @param entity The entity holding the map, playername, or frame-ENTITYID
|
||||
* @param x X Position
|
||||
* @param z Z Position
|
||||
* @param rotation the regular rotation of the marker
|
||||
* @return True to 'spin' the cursor
|
||||
*/
|
||||
default boolean shouldMapSpin(String entity, double x, double z, double rotation)
|
||||
{
|
||||
return getId() < 0;
|
||||
}
|
||||
}
|
||||
@@ -71,4 +71,12 @@ public interface IForgeTileEntity extends ICapabilitySerializable<NBTTagCompound
|
||||
* @return A compound tag for custom data
|
||||
*/
|
||||
NBTTagCompound getTileData();
|
||||
|
||||
default void onChunkUnloaded(){}
|
||||
|
||||
/**
|
||||
* Called when this is first added to the world (by {@link World#addTileEntity(TileEntity)}).
|
||||
* Override instead of adding {@code if (firstTick)} stuff in update.
|
||||
*/
|
||||
default void onLoad(){}
|
||||
}
|
||||
@@ -19,9 +19,44 @@
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.ForgeChunkManager;
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
|
||||
public interface IForgeWorld extends ICapabilityProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Used in the getEntitiesWithinAABB functions to expand the search area for entities.
|
||||
* Modders should change this variable to a higher value if it is less then the radius
|
||||
* of one of there entities.
|
||||
*/
|
||||
public static double MAX_ENTITY_RADIUS = 2.0D;
|
||||
|
||||
default ImmutableSetMultimap<ChunkPos, ForgeChunkManager.Ticket> getPersistentChunks()
|
||||
{
|
||||
return ForgeChunkManager.getPersistentChunksFor((World)this);
|
||||
}
|
||||
|
||||
default Iterator<Chunk> getPersistentChunkIterable(Iterator<Chunk> chunkIterator)
|
||||
{
|
||||
@SuppressWarnings("resource")
|
||||
World world = (World)this;
|
||||
final ImmutableSetMultimap<ChunkPos, Ticket> persistentChunksFor = getPersistentChunks();
|
||||
final ImmutableSet.Builder<Chunk> builder = ImmutableSet.builder();
|
||||
world.profiler.startSection("forcedChunkLoading");
|
||||
builder.addAll(persistentChunksFor.keys().stream().filter(Objects::nonNull).map(input -> world.getChunk(input.x, input.z)).iterator());
|
||||
world.profiler.endStartSection("regularChunkLoading");
|
||||
builder.addAll(chunkIterator);
|
||||
world.profiler.endSection();
|
||||
return builder.build().iterator();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-2
@@ -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>
|
||||
@@ -18,8 +18,6 @@
|
||||
*/
|
||||
|
||||
package net.minecraftforge.fml.common;
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream;
|
||||
|
||||
|
||||
public class LoaderException extends EnhancedRuntimeException
|
||||
{
|
||||
|
||||
@@ -1,237 +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.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class VanillaDoubleChestItemHandler extends WeakReference<TileEntityChest> implements IItemHandlerModifiable
|
||||
{
|
||||
// Dummy cache value to signify that we have checked and definitely found no adjacent chests
|
||||
public static final VanillaDoubleChestItemHandler NO_ADJACENT_CHESTS_INSTANCE = new VanillaDoubleChestItemHandler(null, null, false);
|
||||
private final boolean mainChestIsUpper;
|
||||
private final TileEntityChest mainChest;
|
||||
private final int hashCode;
|
||||
|
||||
public VanillaDoubleChestItemHandler(@Nullable TileEntityChest mainChest, @Nullable TileEntityChest other, boolean mainChestIsUpper)
|
||||
{
|
||||
super(other);
|
||||
this.mainChest = mainChest;
|
||||
this.mainChestIsUpper = mainChestIsUpper;
|
||||
hashCode = Objects.hashCode(mainChestIsUpper ? mainChest : other) * 31 + Objects.hashCode(!mainChestIsUpper ? mainChest : other);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static VanillaDoubleChestItemHandler get(TileEntityChest chest)
|
||||
{
|
||||
World world = chest.getWorld();
|
||||
BlockPos pos = chest.getPos();
|
||||
if (world == null || pos == null || !world.isBlockLoaded(pos))
|
||||
return null; // Still loading
|
||||
|
||||
IBlockState state = chest.getBlockState();
|
||||
|
||||
EnumFacing[] horizontals = EnumFacing.BY_HORIZONTAL_INDEX;
|
||||
for (int i = horizontals.length - 1; i >= 0; i--) // Use reverse order so we can return early
|
||||
{
|
||||
EnumFacing enumfacing = horizontals[i];
|
||||
BlockPos blockpos = pos.offset(enumfacing);
|
||||
Block block = world.getBlockState(blockpos).getBlock();
|
||||
|
||||
if (block == state.getBlock())
|
||||
{
|
||||
TileEntity otherTE = world.getTileEntity(blockpos);
|
||||
|
||||
if (otherTE instanceof TileEntityChest)
|
||||
{
|
||||
TileEntityChest otherChest = (TileEntityChest) otherTE;
|
||||
return new VanillaDoubleChestItemHandler(chest, otherChest,
|
||||
enumfacing != net.minecraft.util.EnumFacing.WEST && enumfacing != net.minecraft.util.EnumFacing.NORTH);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return NO_ADJACENT_CHESTS_INSTANCE; //All alone
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TileEntityChest getChest(boolean accessingUpper)
|
||||
{
|
||||
if (accessingUpper == mainChestIsUpper)
|
||||
return mainChest;
|
||||
else
|
||||
{
|
||||
return getOtherChest();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private TileEntityChest getOtherChest()
|
||||
{
|
||||
TileEntityChest tileEntityChest = get();
|
||||
return tileEntityChest != null && !tileEntityChest.isRemoved() ? tileEntityChest : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
return 27 * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack getStackInSlot(int slot)
|
||||
{
|
||||
boolean accessingUpperChest = slot < 27;
|
||||
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
||||
TileEntityChest chest = getChest(accessingUpperChest);
|
||||
return chest != null ? chest.getStackInSlot(targetSlot) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStackInSlot(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
boolean accessingUpperChest = slot < 27;
|
||||
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
||||
TileEntityChest chest = getChest(accessingUpperChest);
|
||||
if (chest != null)
|
||||
{
|
||||
IItemHandler singleHandler = null; // TODO TileEntityChest patches chest.getSingleChestHandler();
|
||||
if (singleHandler instanceof IItemHandlerModifiable)
|
||||
{
|
||||
((IItemHandlerModifiable) singleHandler).setStackInSlot(targetSlot, stack);
|
||||
}
|
||||
}
|
||||
|
||||
chest = getChest(!accessingUpperChest);
|
||||
if (chest != null)
|
||||
chest.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate)
|
||||
{
|
||||
boolean accessingUpperChest = slot < 27;
|
||||
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
||||
TileEntityChest chest = getChest(accessingUpperChest);
|
||||
if (chest == null)
|
||||
return stack;
|
||||
|
||||
int starting = stack.getCount();
|
||||
ItemStack ret = ItemStack.EMPTY; // TODO TileEntityChest patches chest.getSingleChestHandler().insertItem(targetSlot, stack, simulate);
|
||||
if (ret.getCount() != starting && !simulate)
|
||||
{
|
||||
chest = getChest(!accessingUpperChest);
|
||||
if (chest != null)
|
||||
chest.markDirty();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate)
|
||||
{
|
||||
boolean accessingUpperChest = slot < 27;
|
||||
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
||||
TileEntityChest chest = getChest(accessingUpperChest);
|
||||
if (chest == null)
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
ItemStack ret = ItemStack.EMPTY; // TODO TileEntityChest patches chest.getSingleChestHandler().extractItem(targetSlot, amount, simulate);
|
||||
if (!ret.isEmpty() && !simulate)
|
||||
{
|
||||
chest = getChest(!accessingUpperChest);
|
||||
if (chest != null)
|
||||
chest.markDirty();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit(int slot)
|
||||
{
|
||||
boolean accessingUpperChest = slot < 27;
|
||||
return getChest(accessingUpperChest).getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
|
||||
{
|
||||
boolean accessingUpperChest = slot < 27;
|
||||
int targetSlot = accessingUpperChest ? slot : slot - 27;
|
||||
TileEntityChest chest = getChest(accessingUpperChest);
|
||||
if (chest != null)
|
||||
{
|
||||
return false; // TODO TileEntityChest patches chest.getSingleChestHandler().isItemValid(targetSlot, stack);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
VanillaDoubleChestItemHandler that = (VanillaDoubleChestItemHandler) o;
|
||||
|
||||
if (hashCode != that.hashCode)
|
||||
return false;
|
||||
|
||||
final TileEntityChest otherChest = getOtherChest();
|
||||
if (mainChestIsUpper == that.mainChestIsUpper)
|
||||
return Objects.equal(mainChest, that.mainChest) && Objects.equal(otherChest, that.getOtherChest());
|
||||
else
|
||||
return Objects.equal(mainChest, that.getOtherChest()) && Objects.equal(otherChest, that.mainChest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public boolean needsRefresh()
|
||||
{
|
||||
if (this == NO_ADJACENT_CHESTS_INSTANCE)
|
||||
return false;
|
||||
TileEntityChest tileEntityChest = get();
|
||||
return tileEntityChest == null || tileEntityChest.isRemoved();
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ public class SidedInvWrapper implements IItemHandlerModifiable
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected SidedInvWrapper(ISidedInventory inv, EnumFacing side)
|
||||
public SidedInvWrapper(ISidedInventory inv, EnumFacing side)
|
||||
{
|
||||
this.inv = inv;
|
||||
this.side = side;
|
||||
|
||||
Reference in new issue
Block a user