mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 11:29:15 +00:00
More error cleanup, reinstanted IForgeReigstryEntry.
The abstract class will be used as the default, and to enable delegates but we should keep it api simple by keeping the interface. Removed some patches that didnt get removed in the rebase.
This commit is contained in:
1 parent
ff6fa2cfaf
commit
2798080f60
35 files changed
+200
-472
No files matched your search
@@ -22,7 +22,6 @@ package net.minecraftforge.event;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -30,12 +29,13 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
import net.minecraftforge.eventbus.api.GenericEvent;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
|
||||
|
||||
/**
|
||||
* RegistryEvent supertype.
|
||||
*/
|
||||
public class RegistryEvent<T extends ForgeRegistryEntry<T>> extends GenericEvent<T>
|
||||
public class RegistryEvent<T extends IForgeRegistryEntry<T>> extends GenericEvent<T>
|
||||
{
|
||||
RegistryEvent(Class<T> clazz) {
|
||||
super(clazz);
|
||||
@@ -58,7 +58,7 @@ public class RegistryEvent<T extends ForgeRegistryEntry<T>> extends GenericEvent
|
||||
* ObjectHolders will reload between Blocks and Items, and after all registries have been visited.
|
||||
* @param <T> The registry top level type
|
||||
*/
|
||||
public static class Register<T extends ForgeRegistryEntry<T>> extends RegistryEvent<T>
|
||||
public static class Register<T extends IForgeRegistryEntry<T>> extends RegistryEvent<T>
|
||||
{
|
||||
private final IForgeRegistry<T> registry;
|
||||
private final ResourceLocation name;
|
||||
@@ -82,7 +82,7 @@ public class RegistryEvent<T extends ForgeRegistryEntry<T>> extends GenericEvent
|
||||
|
||||
}
|
||||
|
||||
public static class MissingMappings<T extends ForgeRegistryEntry<T>> extends RegistryEvent<T>
|
||||
public static class MissingMappings<T extends IForgeRegistryEntry<T>> extends RegistryEvent<T>
|
||||
{
|
||||
private final IForgeRegistry<T> registry;
|
||||
private final ResourceLocation name;
|
||||
@@ -154,7 +154,7 @@ public class RegistryEvent<T extends ForgeRegistryEntry<T>> extends GenericEvent
|
||||
REMAP
|
||||
}
|
||||
|
||||
public static class Mapping<T extends ForgeRegistryEntry<T>>
|
||||
public static class Mapping<T extends IForgeRegistryEntry<T>>
|
||||
{
|
||||
public final IForgeRegistry<T> registry;
|
||||
private final IForgeRegistry<T> pool;
|
||||
|
||||
@@ -20,10 +20,8 @@
|
||||
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.block.state.IBlockState;
|
||||
import net.minecraft.world.biome.BiomeDecorator;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
/**
|
||||
@@ -48,48 +46,6 @@ public class BiomeEvent extends net.minecraftforge.eventbus.api.Event
|
||||
return biome;
|
||||
}
|
||||
|
||||
/**
|
||||
* CreateDecorator 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 #originalBiomeDecorator} contains the original BiomeDecorator that would be used in vanilla.
|
||||
* {@link #newBiomeDecorator} contains the new BiomeDecoration to be used by Minecraft.
|
||||
* <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 static class CreateDecorator extends BiomeEvent
|
||||
{
|
||||
private final BiomeDecorator originalBiomeDecorator;
|
||||
private BiomeDecorator newBiomeDecorator;
|
||||
|
||||
public CreateDecorator(Biome biome, BiomeDecorator original)
|
||||
{
|
||||
super(biome);
|
||||
originalBiomeDecorator = original;
|
||||
setNewBiomeDecorator(original);
|
||||
}
|
||||
|
||||
public BiomeDecorator getOriginalBiomeDecorator()
|
||||
{
|
||||
return originalBiomeDecorator;
|
||||
}
|
||||
|
||||
public BiomeDecorator getNewBiomeDecorator()
|
||||
{
|
||||
return newBiomeDecorator;
|
||||
}
|
||||
|
||||
public void setNewBiomeDecorator(BiomeDecorator newBiomeDecorator)
|
||||
{
|
||||
this.newBiomeDecorator = newBiomeDecorator;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -19,23 +19,23 @@
|
||||
|
||||
package net.minecraftforge.event.terraingen;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.ChunkPrimer;
|
||||
import net.minecraft.world.gen.IChunkGenSettings;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
|
||||
public class ChunkGeneratorEvent extends net.minecraftforge.eventbus.api.Event
|
||||
{
|
||||
private final IChunkGenerator gen;
|
||||
private final IChunkGenerator<? extends IChunkGenSettings> gen;
|
||||
|
||||
public ChunkGeneratorEvent(IChunkGenerator gen)
|
||||
public ChunkGeneratorEvent(IChunkGenerator<? extends IChunkGenSettings> gen)
|
||||
{
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
public IChunkGenerator getGenerator() { return this.getGen(); }
|
||||
public IChunkGenerator<? extends IChunkGenSettings> getGenerator() { return this.getGen(); }
|
||||
|
||||
public IChunkGenerator getGen()
|
||||
public IChunkGenerator<? extends IChunkGenSettings> getGen()
|
||||
{
|
||||
return gen;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class ChunkGeneratorEvent extends net.minecraftforge.eventbus.api.Event
|
||||
private final ChunkPrimer primer;
|
||||
private final World world; // CAN BE NULL
|
||||
|
||||
public ReplaceBiomeBlocks(IChunkGenerator chunkProvider, int x, int z, ChunkPrimer primer, World world)
|
||||
public ReplaceBiomeBlocks(IChunkGenerator<? extends IChunkGenSettings> chunkProvider, int x, int z, ChunkPrimer primer, World world)
|
||||
{
|
||||
super(chunkProvider);
|
||||
this.x = x;
|
||||
@@ -85,7 +85,7 @@ public class ChunkGeneratorEvent extends net.minecraftforge.eventbus.api.Event
|
||||
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)
|
||||
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);
|
||||
|
||||
@@ -28,11 +28,8 @@ 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.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;
|
||||
|
||||
/**
|
||||
* DecorateBiomeEvent is fired when a BiomeDecorator is created.
|
||||
|
||||
@@ -1,65 +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.minecraft.world.biome.BiomeDecorator;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class DeferredBiomeDecorator extends BiomeDecorator {
|
||||
private BiomeDecorator wrapped;
|
||||
|
||||
public DeferredBiomeDecorator(BiomeDecorator wrappedOriginal)
|
||||
{
|
||||
this.wrapped = wrappedOriginal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorate(World par1World, Random par2Random, Biome biome, BlockPos pos)
|
||||
{
|
||||
fireCreateEventAndReplace(biome);
|
||||
// On first call to decorate, we fire and substitute ourselves, if we haven't already done so
|
||||
biome.decorator.decorate(par1World, par2Random, biome, pos);
|
||||
}
|
||||
public void fireCreateEventAndReplace(Biome biome)
|
||||
{
|
||||
// Copy any configuration from us to the real instance.
|
||||
wrapped.bigMushroomsPerChunk = bigMushroomsPerChunk;
|
||||
wrapped.cactiPerChunk = cactiPerChunk;
|
||||
wrapped.clayPerChunk = clayPerChunk;
|
||||
wrapped.deadBushPerChunk = deadBushPerChunk;
|
||||
wrapped.flowersPerChunk = flowersPerChunk;
|
||||
wrapped.generateFalls = generateFalls;
|
||||
wrapped.grassPerChunk = grassPerChunk;
|
||||
wrapped.mushroomsPerChunk = mushroomsPerChunk;
|
||||
wrapped.reedsPerChunk = reedsPerChunk;
|
||||
wrapped.gravelPatchesPerChunk = gravelPatchesPerChunk;
|
||||
wrapped.sandPatchesPerChunk = sandPatchesPerChunk;
|
||||
wrapped.treesPerChunk = treesPerChunk;
|
||||
wrapped.waterlilyPerChunk = waterlilyPerChunk;
|
||||
|
||||
BiomeEvent.CreateDecorator event = new BiomeEvent.CreateDecorator(biome, wrapped);
|
||||
MinecraftForge.TERRAIN_GEN_BUS.post(event);
|
||||
biome.decorator = event.getNewBiomeDecorator();
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@
|
||||
package net.minecraftforge.event.terraingen;
|
||||
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraft.world.gen.MapGenBase;
|
||||
|
||||
public class InitMapGenEvent extends Event
|
||||
{
|
||||
@@ -28,6 +27,7 @@ public class InitMapGenEvent extends Event
|
||||
*/
|
||||
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;
|
||||
@@ -42,4 +42,5 @@ public class InitMapGenEvent extends Event
|
||||
public MapGenBase getOriginalGen() { return originalGen; }
|
||||
public MapGenBase getNewGen() { return newGen; }
|
||||
public void setNewGen(MapGenBase newGen) { this.newGen = newGen; }
|
||||
*/
|
||||
}
|
||||
Reference in new issue
Block a user