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

@@ -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;
}
}
}