Port most of the world patches (#5294)

This commit is contained in:
tterrag authored and LexManos committed 2018-12-22 10:31:18 -08:00
1 parent 4879b0611a
commit 8a11e3bac4
34 files changed
+1203 -855

No files matched your search

@@ -28,11 +28,11 @@ 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.dimension.OverworldDimension;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -44,6 +44,8 @@ public interface IForgeDimension
{
return (Dimension) this;
}
World getWorld();
/**
* Called from {@link World#initCapabilities()}, to gather capabilities for this
@@ -79,6 +81,22 @@ public interface IForgeDimension
}
return 1.0;
}
/**
* If this method returns true, then chunks received by the client will
* have {@link net.minecraft.world.chunk.Chunk#resetRelightChecks} called
* on them, queuing lighting checks for all air blocks in the chunk (and
* any adjacent light-emitting blocks).
*
* Returning true here is recommended if the chunk generator used also
* does this for newly generated chunks.
*
* @return true if lighting checks should be performed
*/
default boolean shouldClientCheckLighting()
{
return !(this instanceof OverworldDimension);
}
/**
* Sets the providers current dimension ID, used in default getSaveFolder()
@@ -149,15 +167,34 @@ public interface IForgeDimension
{
return null;
}
/**
* Determines if the player can sleep in this world (or if the bed should explode for example).
*
* @param player The player that is attempting to sleep
* @param pos The location where the player tries to sleep at (the position of the clicked on bed for example)
* @return the result of a player trying to sleep at the given location
*/
default SleepResult canSleepAt(net.minecraft.entity.player.EntityPlayer player, BlockPos pos)
{
return (getDimension().canRespawnHere() && getWorld().getBiome(pos) != net.minecraft.init.Biomes.NETHER) ? SleepResult.ALLOW : SleepResult.BED_EXPLODES;
}
enum SleepResult
{
ALLOW,
DENY,
BED_EXPLODES;
}
default Biome getBiome(BlockPos pos)
{
return getDimension().getWorld().getBiomeBody(pos);
return getWorld().getBiomeBody(pos);
}
default boolean isDaytime()
{
return getDimension().getWorld().getSkylightSubtracted() < 4;
return getWorld().getSkylightSubtracted() < 4;
}
/**
@@ -170,7 +207,7 @@ public interface IForgeDimension
**/
default float getSunBrightnessFactor(float partialTicks)
{
return getDimension().getWorld().getSunBrightnessFactor(partialTicks);
return getWorld().getSunBrightnessFactor(partialTicks);
}
/**
@@ -179,19 +216,19 @@ public interface IForgeDimension
@OnlyIn(Dist.CLIENT)
default float getSunBrightness(float partialTicks)
{
return getDimension().getWorld().getSunBrightnessBody(partialTicks);
return getWorld().getSunBrightnessBody(partialTicks);
}
@OnlyIn(Dist.CLIENT)
default Vec3d getSkyColor(Entity cameraEntity, float partialTicks)
{
return getDimension().getWorld().getSkyColorBody(cameraEntity, partialTicks);
return getWorld().getSkyColorBody(cameraEntity, partialTicks);
}
@OnlyIn(Dist.CLIENT)
default Vec3d getCloudColor(float partialTicks)
{
return getDimension().getWorld().getCloudColorBody(partialTicks);
return getWorld().getCloudColorBody(partialTicks);
}
/**
@@ -210,7 +247,7 @@ public interface IForgeDimension
@OnlyIn(Dist.CLIENT)
default float getStarBrightness(float partialTicks)
{
float f = getDimension().getWorld().getCelestialAngle(partialTicks);
float f = 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;
@@ -220,48 +257,48 @@ public interface IForgeDimension
default void calculateInitialWeather()
{
getDimension().getWorld().calculateInitialWeatherBody();
getWorld().calculateInitialWeatherBody();
}
default void updateWeather()
{
getDimension().getWorld().updateWeatherBody();
getWorld().updateWeatherBody();
}
default long getSeed()
{
return getDimension().getWorld().getWorldInfo().getSeed();
return getWorld().getWorldInfo().getSeed();
}
default long getWorldTime()
{
return getDimension().getWorld().getWorldInfo().getDayTime();
return getWorld().getWorldInfo().getDayTime();
}
default void setWorldTime(long time)
{
getDimension().getWorld().getWorldInfo().setDayTime(time);
getWorld().getWorldInfo().setDayTime(time);
}
default BlockPos getSpawnPoint()
{
WorldInfo info = getDimension().getWorld().getWorldInfo();
WorldInfo info = getWorld().getWorldInfo();
return new BlockPos(info.getSpawnX(), info.getSpawnY(), info.getSpawnZ());
}
default void setSpawnPoint(BlockPos pos)
{
getDimension().getWorld().getWorldInfo().setSpawn(pos);
getWorld().getWorldInfo().setSpawn(pos);
}
default boolean canMineBlock(EntityPlayer player, BlockPos pos)
{
return getDimension().getWorld().canMineBlockBody(player, pos);
return getWorld().canMineBlockBody(player, pos);
}
default boolean isHighHumidity(BlockPos pos)
{
return getDimension().getWorld().getBiome(pos).isHighHumidity();
return getWorld().getBiome(pos).isHighHumidity();
}
default int getHeight()
@@ -276,7 +313,7 @@ public interface IForgeDimension
default double getHorizon()
{
return getDimension().getWorld().getWorldInfo().getTerrainType().getHorizon(getDimension().getWorld());
return getWorld().getWorldInfo().getTerrainType().getHorizon(getWorld());
}
default String getSaveFolder()
@@ -297,4 +334,15 @@ public interface IForgeDimension
{
return getId() < 0;
}
/**
* Determines the dimension the player will be respawned in, typically this brings them back to the overworld.
*
* @param player The player that is respawning
* @return The dimension to respawn the player in
*/
default int getRespawnDimension(net.minecraft.entity.player.EntityPlayerMP player)
{
return player.getSpawnDimension();
}
}
@@ -0,0 +1,104 @@
package net.minecraftforge.common.extensions;
import java.util.function.LongFunction;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiCreateBuffetWorld;
import net.minecraft.client.gui.GuiCreateFlatWorld;
import net.minecraft.client.gui.GuiCreateWorld;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.IContextExtended;
import net.minecraft.world.gen.OverworldGenSettings;
import net.minecraft.world.gen.area.IArea;
import net.minecraft.world.gen.area.IAreaFactory;
import net.minecraft.world.gen.layer.GenLayerBiome;
import net.minecraft.world.gen.layer.GenLayerBiomeEdge;
import net.minecraft.world.gen.layer.GenLayerZoom;
import net.minecraft.world.gen.layer.LayerUtil;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface IForgeWorldType
{
default WorldType getWorldType()
{
return (WorldType) this;
}
/**
* Called when 'Create New World' button is pressed before starting game
*/
default void onGUICreateWorldPress()
{
}
/**
* Called when the 'Customize' button is pressed on world creation GUI
*
* @param mc The Minecraft instance
* @param gui the createworld GUI
*/
@OnlyIn(Dist.CLIENT)
default void onCustomizeButton(Minecraft mc, GuiCreateWorld gui)
{
if (this == WorldType.FLAT)
mc.displayGuiScreen(new GuiCreateFlatWorld(gui, gui.chunkProviderSettingsJson));
else if (this == WorldType.CUSTOMIZED)
mc.displayGuiScreen(new GuiCreateBuffetWorld(gui, gui.chunkProviderSettingsJson));
}
default boolean handleSlimeSpawnReduction(java.util.Random random, World world)
{
return this == WorldType.FLAT ? random.nextInt(4) != 1 : false;
}
default double getHorizon(World world)
{
return this == WorldType.FLAT ? 0.0D : 63.0D;
}
default double voidFadeMagnitude()
{
return this == WorldType.FLAT ? 1.0D : 0.03125D;
}
/**
* Get the height to render the clouds for this world type
*
* @return The height to render clouds at
*/
default float getCloudHeight()
{
return 128.0F;
}
@SuppressWarnings("deprecation")
default IChunkGenerator<?> createChunkGenerator(World world)
{
return world.dimension.createChunkGenerator();
}
/**
* Creates the GenLayerBiome used for generating the world with the specified
* ChunkProviderSettings JSON String *IF AND ONLY IF* this WorldType ==
* WorldType.CUSTOMIZED.
*
*
* @param worldSeed The world seed
* @param parentLayer The parent layer to feed into any layer you return
* @param chunkSettings The ChunkGeneratorSettings constructed from the custom
* JSON
* @return A GenLayer that will return ints representing the Biomes to be
* generated, see GenLayerBiome
*/
default <T extends IArea, C extends IContextExtended<T>> IAreaFactory<T> getBiomeLayer(IAreaFactory<T> parentLayer,
OverworldGenSettings chunkSettings, LongFunction<C> contextFactory)
{
parentLayer = (new GenLayerBiome(getWorldType(), chunkSettings)).apply((IContextExtended) contextFactory.apply(200L), parentLayer);
parentLayer = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, parentLayer, 2, contextFactory);
parentLayer = GenLayerBiomeEdge.INSTANCE.apply((IContextExtended) contextFactory.apply(1000L), parentLayer);
return parentLayer;
}
}
@@ -25,8 +25,10 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Random;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.block.BlockPortal;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
@@ -43,11 +45,9 @@ import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityFireball;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.tileentity.MobSpawnerBaseLogic;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumActionResult;
@@ -62,15 +62,13 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.village.Village;
import net.minecraft.world.Explosion;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.storage.IPlayerFileData;
import net.minecraft.world.storage.SaveHandler;
@@ -119,6 +117,7 @@ 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.world.BlockEvent;
import net.minecraftforge.event.world.BlockEvent.CreateFluidSourceEvent;
import net.minecraftforge.event.world.BlockEvent.MultiPlaceEvent;
@@ -130,10 +129,6 @@ 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;
import net.minecraftforge.fml.common.registry.GameRegistry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class ForgeEventFactory
{
@@ -639,6 +634,13 @@ public class ForgeEventFactory
{
return MinecraftForge.EVENT_BUS.post(new ProjectileImpactEvent.Throwable(throwable, ray));
}
public static boolean onReplaceBiomeBlocks(IChunkGenerator<?> gen, IChunk chunk, IWorld world)
{
ChunkGeneratorEvent.ReplaceBiomeBlocks event = new ChunkGeneratorEvent.ReplaceBiomeBlocks(gen, chunk, world);
MinecraftForge.EVENT_BUS.post(event);
return event.getResult() != Event.Result.DENY;
}
public static LootTable loadLootTable(ResourceLocation name, LootTable table, LootTableManager lootTableManager)
{
@@ -0,0 +1,150 @@
/*
* 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.block.state.IBlockState;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Event;
/**
* 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 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 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);
}
}
}
@@ -0,0 +1,104 @@
/*
* 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.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.eventbus.api.Event;
public class ChunkGeneratorEvent extends Event
{
private final IChunkGenerator<?> gen;
public ChunkGeneratorEvent(IChunkGenerator<?> gen)
{
this.gen = gen;
}
public IChunkGenerator<?> getGenerator() { return this.getGen(); }
public IChunkGenerator<?> 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 IChunk chunk;
private final IWorld world; // CAN BE NULL
public ReplaceBiomeBlocks(IChunkGenerator<?> chunkProvider, IChunk chunk, IWorld world)
{
super(chunkProvider);
this.chunk = chunk;
this.world = world;
}
public IChunk getChunk() { return chunk; }
public IWorld 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<?> 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; }
}
}
@@ -0,0 +1,126 @@
/*
* 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.IWorld;
import net.minecraft.world.gen.NoiseGeneratorOctaves;
import net.minecraft.world.gen.NoiseGeneratorPerlin;
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(IWorld 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;
public ContextOverworld(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin,
NoiseGeneratorPerlin height, NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth)
{
super(lperlin1, lperlin2, perlin, scale, depth);
this.height = height;
}
@Override
public ContextOverworld clone() { return new ContextOverworld(getLPerlin1(), getLPerlin2(), getPerlin(), height, getScale(), getDepth()); }
public NoiseGeneratorPerlin getHeight() { return height; }
public void getHeight (NoiseGeneratorPerlin value) { this.height = value; }
}
public static class ContextEnd extends Context
{
private NoiseGeneratorPerlin island;
public ContextEnd(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin,
NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth, NoiseGeneratorPerlin field_205478_l)
{
super(lperlin1, lperlin2, perlin, scale, depth);
this.island = field_205478_l;
}
@Override
public ContextEnd clone() { return new ContextEnd(getLPerlin1(), getLPerlin2(), getPerlin(), getScale(), getDepth(), island); }
public NoiseGeneratorPerlin getIsland() { return island; }
public void getIsland (NoiseGeneratorPerlin value) { this.island = value; }
}
public static class ContextHell extends Context
{
private NoiseGeneratorOctaves perlin2;
public ContextHell(NoiseGeneratorOctaves lperlin1, NoiseGeneratorOctaves lperlin2, NoiseGeneratorOctaves perlin,
NoiseGeneratorOctaves perlin2, NoiseGeneratorOctaves scale, NoiseGeneratorOctaves depth)
{
super(lperlin1, lperlin2, perlin, scale, depth);
this.perlin2 = perlin2;
}
@Override
public ContextHell clone() { return new ContextHell(getLPerlin1(), getLPerlin2(), getPerlin(), perlin2, getScale(), getDepth()); }
public NoiseGeneratorOctaves getPerlin2() { return perlin2; }
public void getPerlin2 (NoiseGeneratorOctaves value) { this.perlin2 = value; }
}
}
@@ -0,0 +1,35 @@
/*
* 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.IWorld;
import net.minecraftforge.common.MinecraftForge;
public abstract class TerrainGen
{
public static <T extends InitNoiseGensEvent.Context> T getModdedNoiseGenerators(IWorld world, Random rand, T original)
{
InitNoiseGensEvent<T> event = new InitNoiseGensEvent<>(world, rand, original);
MinecraftForge.EVENT_BUS.post(event);
return event.getNewValues();
}
}
@@ -0,0 +1,146 @@
/*
* 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.WorldType;
import net.minecraft.world.biome.provider.BiomeProvider;
import net.minecraft.world.gen.layer.GenLayer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.Event.HasResult;
/**
* 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;
}
}
}
@@ -23,22 +23,28 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Random;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.entity.monster.EntityZombieVillager;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.ForgeRegistryEntry;
import javax.annotation.Nullable;
import org.apache.commons.lang3.Validate;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.entity.monster.EntityZombieVillager;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityVillager.ITradeList;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraft.world.gen.feature.structure.StructurePiece;
import net.minecraft.world.gen.feature.structure.VillagePieces;
import net.minecraft.world.gen.feature.structure.VillagePieces.PieceWeight;
import net.minecraft.world.gen.feature.structure.VillagePieces.Village;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.ForgeRegistryEntry;
import net.minecraftforge.registries.GameData;
import javax.annotation.Nullable;
/**
* Registry for villager trading control
*/
@@ -47,43 +53,36 @@ public class VillagerRegistry
public static final RegistryObject<VillagerProfession> FARMER = RegistryObject.of("minecraft:farmer", ()->VillagerProfession.class);
private static final VillagerRegistry INSTANCE = new VillagerRegistry();
/* TODO village creation
private Map<Class<?>, IVillageCreationHandler> villageCreationHandlers = Maps.newHashMap();
*/
private VillagerRegistry()
{
init();
}
/**
/**
* Allow access to the {@link net.minecraft.world.gen.structure.StructureVillagePieces} array controlling new village
* creation so you can insert your own new village pieces
*
* @author cpw
*//*
*/
public interface IVillageCreationHandler
{
*/
/**
/**
* Called when {@link net.minecraft.world.gen.structure.MapGenVillage} is creating a new village
*
* @param random
* @param i
*//*
*/
VillagePieces.PieceWeight getVillagePieceWeight(Random random, int i);
StructureVillagePieces.PieceWeight getVillagePieceWeight(Random random, int i);
*/
/**
/**
* The class of the root structure component to add to the village
*//*
*/
Class<?> getComponentClass();
*/
/**
/**
* Build an instance of the village component {@link net.minecraft.world.gen.structure.StructureVillagePieces}
*
* @param villagePiece
@@ -95,23 +94,21 @@ public class VillagerRegistry
* @param p3
* @param facing
* @param p5
*//*
Village buildComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random, int p1,
*/
Village buildComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.Start startPiece, List<StructurePiece> pieces, Random random, int p1,
int p2, int p3, EnumFacing facing, int p5);
}
*/
public static VillagerRegistry instance()
{
return INSTANCE;
}
/**
/**
* Register a new village creation handler
*
* @param handler
*//*
*/
public void registerVillageCreationHandler(IVillageCreationHandler handler)
{
villageCreationHandlers.put(handler.getComponentClass(), handler);
@@ -119,19 +116,19 @@ public class VillagerRegistry
public static void addExtraVillageComponents(List<PieceWeight> list, Random random, int i)
{
List<StructureVillagePieces.PieceWeight> parts = list;
List<VillagePieces.PieceWeight> parts = list;
for (IVillageCreationHandler handler : instance().villageCreationHandlers.values())
{
parts.add(handler.getVillagePieceWeight(random, i));
}
}
public static Village getVillageComponent(StructureVillagePieces.PieceWeight villagePiece, StructureVillagePieces.Start startPiece, List<StructureComponent> pieces, Random random,
public static Village getVillageComponent(VillagePieces.PieceWeight villagePiece, VillagePieces.Start startPiece, List<StructurePiece> pieces, Random random,
int p1, int p2, int p3, EnumFacing facing, int p5)
{
return instance().villageCreationHandlers.get(villagePiece.villagePieceClass).buildComponent(villagePiece, startPiece, pieces, random, p1, p2, p3, facing, p5);
}
*/
RegistryNamespaced<ResourceLocation, VillagerProfession> REGISTRY = GameData.getWrapper(VillagerProfession.class);
private void register(VillagerProfession prof, int id)