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:
LexManos 2018-09-05 20:06:18 -07:00
parent ff6fa2cfaf
commit 2798080f60
35 changed files with 200 additions and 472 deletions

View File

@ -1,20 +0,0 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIEatGrass.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIEatGrass.java
@@ -78,7 +78,7 @@
if (field_179505_b.apply(this.field_151501_c.func_180495_p(blockpos)))
{
- if (this.field_151501_c.func_82736_K().func_82766_b("mobGriefing"))
+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_151501_c, this.field_151500_b))
{
this.field_151501_c.func_175655_b(blockpos, false);
}
@@ -91,7 +91,7 @@
if (this.field_151501_c.func_180495_p(blockpos1).func_177230_c() == Blocks.field_150349_c)
{
- if (this.field_151501_c.func_82736_K().func_82766_b("mobGriefing"))
+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_151501_c, this.field_151500_b))
{
this.field_151501_c.func_175718_b(2001, blockpos1, Block.func_149682_b(Blocks.field_150349_c));
this.field_151501_c.func_180501_a(blockpos1, Blocks.field_150346_d.func_176223_P(), 2);

View File

@ -1,24 +0,0 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIHarvestFarmland.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIHarvestFarmland.java
@@ -29,7 +29,7 @@
{
if (this.field_179496_a <= 0)
{
- if (!this.field_179504_c.field_70170_p.func_82736_K().func_82766_b("mobGriefing"))
+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_179504_c.field_70170_p, this.field_179504_c))
{
return false;
}
@@ -94,6 +94,12 @@
world.func_180501_a(blockpos, Blocks.field_185773_cZ.func_176223_P(), 3);
flag = true;
}
+ else if (itemstack.func_77973_b() instanceof net.minecraftforge.common.IPlantable) {
+ if(((net.minecraftforge.common.IPlantable)itemstack.func_77973_b()).getPlantType(world,blockpos) == net.minecraftforge.common.EnumPlantType.Crop) {
+ world.func_180501_a(blockpos, ((net.minecraftforge.common.IPlantable)itemstack.func_77973_b()).getPlant(world,blockpos),3);
+ flag = true;
+ }
+ }
}
if (flag)

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityCreeper.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityCreeper.java
@@ -265,7 +265,7 @@
{
if (!this.field_70170_p.field_72995_K)
{
- boolean flag = this.field_70170_p.func_82736_K().func_82766_b("mobGriefing");
+ boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this);
float f = this.func_70830_n() ? 2.0F : 1.0F;
this.field_70729_aU = true;
this.field_70170_p.func_72876_a(this, this.field_70165_t, this.field_70163_u, this.field_70161_v, (float)this.field_82226_g * f, flag);

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityEvoker.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityEvoker.java
@@ -369,7 +369,7 @@
{
return false;
}
- else if (!EntityEvoker.this.field_70170_p.func_82736_K().func_82766_b("mobGriefing"))
+ else if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(EntityEvoker.this.field_70170_p, EntityEvoker.this))
{
return false;
}

View File

@ -1,20 +0,0 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntitySilverfish.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntitySilverfish.java
@@ -184,7 +184,7 @@
{
Random random = this.field_75457_a.func_70681_au();
- if (this.field_75457_a.field_70170_p.func_82736_K().func_82766_b("mobGriefing") && random.nextInt(10) == 0)
+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_75457_a.field_70170_p, this.field_75457_a) && random.nextInt(10) == 0)
{
this.field_179483_b = EnumFacing.func_176741_a(random);
BlockPos blockpos = (new BlockPos(this.field_75457_a.field_70165_t, this.field_75457_a.field_70163_u + 0.5D, this.field_75457_a.field_70161_v)).func_177972_a(this.field_179483_b);
@@ -273,7 +273,7 @@
if (iblockstate.func_177230_c() == Blocks.field_150418_aU)
{
- if (world.func_82736_K().func_82766_b("mobGriefing"))
+ if (net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(world, this.field_179464_a))
{
world.func_175655_b(blockpos1, true);
}

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityRabbit.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityRabbit.java
@@ -551,7 +551,7 @@
{
if (this.field_179496_a <= 0)
{
- if (!this.field_179500_c.field_70170_p.func_82736_K().func_82766_b("mobGriefing"))
+ if (!net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_179500_c.field_70170_p, this.field_179500_c))
{
return false;
}

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityLargeFireball.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityLargeFireball.java
@@ -40,7 +40,7 @@
this.func_174815_a(this.field_70235_a, p_70227_1_.field_72308_g);
}
- boolean flag = this.field_70170_p.func_82736_K().func_82766_b("mobGriefing");
+ boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this.field_70235_a);
this.field_70170_p.func_72885_a((Entity)null, this.field_70165_t, this.field_70163_u, this.field_70161_v, (float)this.field_92057_e, flag, flag);
this.func_70106_y();
}

View File

@ -1,11 +0,0 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntitySmallFireball.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntitySmallFireball.java
@@ -57,7 +57,7 @@
if (this.field_70235_a != null && this.field_70235_a instanceof EntityLiving)
{
- flag1 = this.field_70170_p.func_82736_K().func_82766_b("mobGriefing");
+ flag1 = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this.field_70235_a);
}
if (flag1)

View File

@ -0,0 +1,21 @@
--- a/net/minecraft/item/crafting/IRecipe.java
+++ b/net/minecraft/item/crafting/IRecipe.java
@@ -9,7 +9,7 @@
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
-public interface IRecipe {
+public interface IRecipe extends net.minecraftforge.registries.IForgeRegistryEntry<IRecipe> {
boolean matches(IInventory inv, World worldIn);
ItemStack getCraftingResult(IInventory inv);
@@ -48,4 +48,9 @@
ResourceLocation func_199560_c();
IRecipeSerializer<?> func_199559_b();
+
+ @Override
+ default Class<IRecipe> getRegistryType() {
+ return IRecipe.class;
}
+}

View File

@ -119,7 +119,7 @@ public class GuiIngameForge extends GuiIngame
if (pre(ALL)) return;
fontrenderer = mc.fontRenderer;
mc.entityRenderer.setupOverlayRendering();
//mc.entityRenderer.setupOverlayRendering();
GlStateManager.enableBlend();
if (renderVignette && Minecraft.isFancyGraphicsEnabled())

View File

@ -42,11 +42,12 @@ import net.minecraft.util.math.Vec3i;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.ForgeHooksClient;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Triple;
import com.google.common.base.MoreObjects;
import java.util.Optional;
import com.google.common.collect.Maps;
/*
@ -118,7 +119,7 @@ public final class TRSRTransformation implements IModelState, ITransformation
return getRotation(facing).getMatrix();
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static ModelRotation getRotation(EnumFacing facing)
{
switch (facing)
@ -537,7 +538,7 @@ public final class TRSRTransformation implements IModelState, ITransformation
@OnlyIn(Dist.CLIENT)
public net.minecraft.client.renderer.block.model.ItemTransformVec3f toItemTransform()
{
return new ItemTransformVec3f(toLwjgl(toXYZDegrees(getLeftRot())), toLwjgl(getTranslation()), toLwjgl(getScale()));
return new ItemTransformVec3f(toMojang(toXYZDegrees(getLeftRot())), toMojang(getTranslation()), toMojang(getScale()));
}
public boolean isIdentity()
@ -689,59 +690,53 @@ public final class TRSRTransformation implements IModelState, ITransformation
}
@OnlyIn(Dist.CLIENT)
public static Vector3f toVecmath(org.lwjgl.util.vector.Vector3f vec)
public static Vector3f toVecmath(net.minecraft.client.renderer.Vector3f vec)
{
return new Vector3f(vec.x, vec.y, vec.z);
return new Vector3f(vec.func_195899_a(), vec.func_195900_b(), vec.func_195902_c());
}
@OnlyIn(Dist.CLIENT)
public static Vector4f toVecmath(org.lwjgl.util.vector.Vector4f vec)
public static Vector4f toVecmath(net.minecraft.client.renderer.Vector4f vec)
{
return new Vector4f(vec.x, vec.y, vec.z, vec.w);
return new Vector4f(vec.func_195910_a(), vec.func_195913_b(), vec.func_195914_c(), vec.func_195915_d());
}
@OnlyIn(Dist.CLIENT)
public static Matrix4f toVecmath(org.lwjgl.util.vector.Matrix4f m)
public static Matrix4f toVecmath(net.minecraft.client.renderer.Matrix4f m)
{
return new Matrix4f(
m.m00, m.m10, m.m20, m.m30,
m.m01, m.m11, m.m21, m.m31,
m.m02, m.m12, m.m22, m.m32,
m.m03, m.m13, m.m23, m.m33);
m.func_195885_a(0, 0), m.func_195885_a(1, 0), m.func_195885_a(2, 0), m.func_195885_a(3, 0),
m.func_195885_a(0, 1), m.func_195885_a(1, 1), m.func_195885_a(2, 1), m.func_195885_a(3, 1),
m.func_195885_a(0, 2), m.func_195885_a(1, 2), m.func_195885_a(2, 2), m.func_195885_a(3, 2),
m.func_195885_a(0, 3), m.func_195885_a(1, 3), m.func_195885_a(2, 3), m.func_195885_a(3, 3));
}
@OnlyIn(Dist.CLIENT)
public static net.minecraft.client.renderer.Vector3f toMojang(Vector3f vec)
{
return new net.minecraft.client.renderer.Vector3f(vec.x, vec.y, vec.z);
}
@OnlyIn(Dist.CLIENT)
public static org.lwjgl.util.vector.Vector3f toLwjgl(Vector3f vec)
public static net.minecraft.client.renderer.Vector4f toMojang(Vector4f vec)
{
return new org.lwjgl.util.vector.Vector3f(vec.x, vec.y, vec.z);
return new net.minecraft.client.renderer.Vector4f(vec.x, vec.y, vec.z, vec.w);
}
@OnlyIn(Dist.CLIENT)
public static org.lwjgl.util.vector.Vector4f toLwjgl(Vector4f vec)
public static net.minecraft.client.renderer.Matrix4f toMojang(Matrix4f m)
{
return new org.lwjgl.util.vector.Vector4f(vec.x, vec.y, vec.z, vec.w);
}
@OnlyIn(Dist.CLIENT)
public static org.lwjgl.util.vector.Matrix4f toLwjgl(Matrix4f m)
{
org.lwjgl.util.vector.Matrix4f r = new org.lwjgl.util.vector.Matrix4f();
r.m00 = m.m00;
r.m01 = m.m10;
r.m02 = m.m20;
r.m03 = m.m30;
r.m10 = m.m01;
r.m11 = m.m11;
r.m12 = m.m21;
r.m13 = m.m31;
r.m20 = m.m02;
r.m21 = m.m12;
r.m22 = m.m22;
r.m23 = m.m32;
r.m30 = m.m03;
r.m31 = m.m13;
r.m32 = m.m23;
r.m33 = m.m33;
net.minecraft.client.renderer.Matrix4f r = new net.minecraft.client.renderer.Matrix4f();
float[] row = new float[4];
for (int x = 0; x < 4; x++)
{
m.getRow(x, row);
for (int y = 0; y < 4; y++)
{
r.func_195878_a(x, y, row[y]);
}
}
return r;
}

View File

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

View File

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

View File

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

View File

@ -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.

View File

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

View File

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

View File

@ -23,7 +23,6 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.client.FMLClientHandler;
public class GuiAccessDenied extends GuiScreen
{
@ -38,17 +37,15 @@ public class GuiAccessDenied extends GuiScreen
@Override
public void initGui()
{
this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))
{
public void func_194829_a(double p_194829_1_, double p_194829_3_)
{
GuiAccessDenied.this.mc.displayGuiScreen(parent);
}
});
}
@Override
protected void actionPerformed(GuiButton p_73875_1_)
{
if (p_73875_1_.enabled && p_73875_1_.id == 1)
{
FMLClientHandler.instance().showGuiScreen(parent);
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{

View File

@ -19,11 +19,11 @@
package net.minecraftforge.fml.client.gui;
import java.awt.Desktop;
import java.io.File;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.client.FMLClientHandler;
public class GuiBackupFailed extends GuiScreen
{
@ -38,17 +38,15 @@ public class GuiBackupFailed extends GuiScreen
@Override
public void initGui()
{
this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))
{
public void func_194829_a(double p_194829_1_, double p_194829_3_)
{
GuiBackupFailed.this.mc.displayGuiScreen(parent);
}
});
}
@Override
protected void actionPerformed(GuiButton p_73875_1_)
{
if (p_73875_1_.enabled && p_73875_1_.id == 1)
{
FMLClientHandler.instance().showGuiScreen(parent);
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{

View File

@ -18,11 +18,8 @@
*/
package net.minecraftforge.fml.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiOptionButton;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.StartupQuery;
public class GuiConfirmation extends GuiNotification
@ -35,18 +32,23 @@ public class GuiConfirmation extends GuiNotification
@Override
public void initGui()
{
this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height - 38, I18n.format("gui.yes")));
this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height - 38, I18n.format("gui.no")));
}
@Override
protected void actionPerformed(GuiButton button)
{
if (button.enabled && (button.id == 0 || button.id == 1))
this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height - 38, I18n.format("gui.yes"))
{
FMLClientHandler.instance().showGuiScreen(null);
query.setResult(button.id == 0);
query.finish();
}
public void func_194829_a(double p_194829_1_, double p_194829_3_)
{
GuiConfirmation.this.mc.displayGuiScreen(null);
query.setResult(true);
query.finish();
}
});
this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height - 38, I18n.format("gui.no"))
{
public void func_194829_a(double p_194829_1_, double p_194829_3_)
{
GuiConfirmation.this.mc.displayGuiScreen(null);
query.setResult(false);
query.finish();
}
});
}
}

View File

@ -22,14 +22,16 @@ package net.minecraftforge.fml.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Loader;
import java.awt.*;
import java.io.File;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class GuiErrorBase extends GuiErrorScreen
{
private static final Logger LOGGER = LogManager.getLogger();
static final File minecraftDir = new File(Loader.instance().getConfigDir().getParent());
static final File logFile = new File(minecraftDir, "logs/latest.log");
public GuiErrorBase()
@ -47,45 +49,44 @@ public class GuiErrorBase extends GuiErrorScreen
{
super.initGui();
this.buttonList.clear();
this.buttonList.add(new GuiButton(10, 50, this.height - 38, this.width / 2 - 55, 20, translateOrDefault("fml.button.open.mods.folder", "Open Mods Folder")));
this.buttonList.add(new GuiButton(10, 50, this.height - 38, this.width / 2 - 55, 20, translateOrDefault("fml.button.open.mods.folder", "Open Mods Folder"))
{
public void func_194829_a(double p_194829_1_, double p_194829_3_)
{
try
{
File modsDir = new File(minecraftDir, "mods");
Desktop.getDesktop().open(modsDir);
}
catch (Exception e)
{
LOGGER.error("Problem opening mods folder", e);
}
}
});
String openFileText = translateOrDefault("fml.button.open.file", "Open %s", logFile.getName());
this.buttonList.add(new GuiButton(11, this.width / 2 + 5, this.height - 38, this.width / 2 - 55, 20, openFileText));
}
@Override
protected void actionPerformed(GuiButton button)
{
if (button.id == 10)
this.buttonList.add(new GuiButton(11, this.width / 2 + 5, this.height - 38, this.width / 2 - 55, 20, openFileText)
{
try
public void func_194829_a(double p_194829_1_, double p_194829_3_)
{
File modsDir = new File(minecraftDir, "mods");
Desktop.getDesktop().open(modsDir);
try
{
Desktop.getDesktop().open(logFile);
}
catch (Exception e)
{
LOGGER.error("Problem opening log file {}", logFile, e);
}
}
catch (Exception e)
{
FMLLog.log.error("Problem opening mods folder", e);
}
}
else if (button.id == 11)
{
try
{
Desktop.getDesktop().open(logFile);
}
catch (Exception e)
{
FMLLog.log.error("Problem opening log file {}", logFile, e);
}
}
});
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
for(GuiButton button : buttonList)
for (GuiButton button : buttonList)
{
button.drawButton(this.mc, mouseX, mouseY, partialTicks);
button.func_194828_a(mouseX, mouseY, partialTicks);
}
}
}

View File

@ -24,8 +24,6 @@ import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.MissingModsException;
import net.minecraftforge.fml.common.versioning.ArtifactVersion;
public class GuiModsMissingForServer extends GuiScreen
@ -40,17 +38,15 @@ public class GuiModsMissingForServer extends GuiScreen
@Override
public void initGui()
{
this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done")));
this.buttonList.add(new GuiButton(1, this.width / 2 - 75, this.height - 38, I18n.format("gui.done"))
{
public void func_194829_a(double p_194829_1_, double p_194829_3_)
{
GuiModsMissingForServer.this.mc.displayGuiScreen(null);
}
});
}
@Override
protected void actionPerformed(GuiButton p_73875_1_)
{
if (p_73875_1_.enabled && p_73875_1_.id == 1)
{
FMLClientHandler.instance().showGuiScreen(null);
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{

View File

@ -22,7 +22,6 @@ package net.minecraftforge.fml.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.StartupQuery;
public class GuiNotification extends GuiScreen
@ -35,17 +34,14 @@ public class GuiNotification extends GuiScreen
@Override
public void initGui()
{
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height - 38, I18n.format("gui.done")));
}
@Override
protected void actionPerformed(GuiButton button)
{
if (button.enabled && button.id == 0)
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height - 38, I18n.format("gui.done"))
{
FMLClientHandler.instance().showGuiScreen(null);
query.finish();
}
public void func_194829_a(double p_194829_1_, double p_194829_3_)
{
GuiNotification.this.mc.displayGuiScreen(null);
query.finish();
}
});
}
@Override

View File

@ -51,7 +51,7 @@ public class ForgeRegistries
public static final IForgeRegistry<PotionType> POTION_TYPES = RegistryManager.ACTIVE.getRegistry(PotionType.class);
public static final IForgeRegistry<Enchantment> ENCHANTMENTS = RegistryManager.ACTIVE.getRegistry(Enchantment.class);
public static final IForgeRegistry<VillagerProfession> VILLAGER_PROFESSIONS = RegistryManager.ACTIVE.getRegistry(VillagerProfession.class);
public static final IForgeRegistry<Entity> ENTITIES = RegistryManager.ACTIVE.getRegistry(Entity.class);
public static final IForgeRegistry<EntityEntry> ENTITIES = RegistryManager.ACTIVE.getRegistry(EntityEntry.class);
public static final IForgeRegistry<IRecipe> RECIPES = RegistryManager.ACTIVE.getRegistry(IRecipe.class);

View File

@ -29,12 +29,14 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import net.minecraftforge.fml.common.FMLLog;
/**
* This is different from the standard maven snapshot metadata.
* Because none of that data is exposed to us as a user of gradle/maven/whatever.
@ -52,6 +54,7 @@ import net.minecraftforge.fml.common.FMLLog;
*/
public class SnapshotJson implements Comparable<SnapshotJson>
{
private static final Logger LOGGER = LogManager.getLogger();
public static final DateFormat TIMESTAMP = new SimpleDateFormat("yyyyMMdd.hhmmss");
public static final String META_JSON_FILE = "maven-metadata.json";
private static final Gson GSON = new GsonBuilder().create();
@ -71,11 +74,11 @@ public class SnapshotJson implements Comparable<SnapshotJson>
}
catch (JsonSyntaxException jse)
{
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Failed to parse snapshot json file {}.", target), jse);
LOGGER.info("Failed to parse snapshot json file " + target + ".", jse);
}
catch (IOException ioe)
{
FMLLog.log.info(FMLLog.log.getMessageFactory().newMessage("Failed to read snapshot json file {}.", target), ioe);
LOGGER.info("Failed to read snapshot json file " + target + ".", ioe);
}
return new SnapshotJson();

View File

@ -56,7 +56,7 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
public class ForgeRegistry<V extends ForgeRegistryEntry<V>> implements IForgeRegistryInternal<V>, IForgeRegistryModifiable<V>
public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRegistryInternal<V>, IForgeRegistryModifiable<V>
{
public static Marker REGISTRIES = MarkerManager.getMarker("REGISTRIES");
private static Logger LOGGER = LogManager.getLogger();

View File

@ -22,14 +22,17 @@ package net.minecraftforge.registries;
import com.google.common.reflect.TypeToken;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.ModThreadContext;
import org.apache.logging.log4j.LogManager;
import javax.annotation.Nullable;
/**
* Default implementation of IForgeRegistryEntry, this is necessary to reduce redundant code.
* This also enables the registrie's ability to manage delegates. Which are automatically updated
* if another entry overrides existing ones in the registry.
*/
@SuppressWarnings("unchecked")
public abstract class ForgeRegistryEntry<V extends ForgeRegistryEntry<V>>
public abstract class ForgeRegistryEntry<V extends ForgeRegistryEntry<V>> implements IForgeRegistryEntry<V>
{
@SuppressWarnings("serial")
private final TypeToken<V> token = new TypeToken<V>(getClass()){};
public final IRegistryDelegate<V> delegate = new RegistryDelegate<>((V)this, (Class<V>)token.getRawType());
private ResourceLocation registryName = null;
@ -39,16 +42,7 @@ public abstract class ForgeRegistryEntry<V extends ForgeRegistryEntry<V>>
if (getRegistryName() != null)
throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName());
int index = name.lastIndexOf(':');
String oldPrefix = index == -1 ? "" : name.substring(0, index).toLowerCase();
name = index == -1 ? name : name.substring(index + 1);
String prefix = ModThreadContext.get().getActiveContainer().getPrefix();
if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
{
LogManager.getLogger().info("Potentially Dangerous alternative prefix `{}` for name `{}`, expected `{}`. This could be a intended override, but in most cases indicates a broken mod.", oldPrefix, name, prefix);
prefix = oldPrefix;
}
this.registryName = new ResourceLocation(prefix, name);
this.registryName = GameData.checkPrefix(name);
return (V)this;
}
@ -65,4 +59,4 @@ public abstract class ForgeRegistryEntry<V extends ForgeRegistryEntry<V>>
}
public final Class<V> getRegistryType() { return (Class<V>)token.getRawType(); }
}
}

View File

@ -25,17 +25,11 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import net.minecraft.block.Block;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockObserver;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionType;
import net.minecraft.util.ObjectIntIdentityMap;
@ -43,12 +37,12 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.registry.RegistryNamespaced;
import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.RegistryEvent.MissingMappings;
import net.minecraftforge.fml.common.EnhancedRuntimeException;
import net.minecraftforge.fml.ModThreadContext;
import net.minecraftforge.fml.StartupQuery;
import com.google.common.collect.ArrayListMultimap;
@ -196,7 +190,7 @@ public class GameData
public static void vanillaSnapshot()
{
LOGGER.debug("Creating vanilla freeze snapshot");
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends ForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
{
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
loadRegistry(r.getKey(), RegistryManager.ACTIVE, RegistryManager.VANILLA, clazz, true);
@ -244,7 +238,7 @@ public class GameData
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.resetDelegates());
LOGGER.debug(GD, "Reverting to frozen data state.");
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends ForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
{
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
loadRegistry(r.getKey(), RegistryManager.FROZEN, RegistryManager.ACTIVE, clazz, true);
@ -680,11 +674,12 @@ public class GameData
STAGING.registries.forEach((name, reg) -> reg.validateContent(name));
// Load the STAGING registry into the ACTIVE registry
for (Map.Entry<ResourceLocation, IForgeRegistry<? extends ForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
//for (Map.Entry<ResourceLocation, IForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
RegistryManager.ACTIVE.registries.forEach((key, value) ->
{
final Class<? extends IForgeRegistryEntry> registrySuperType = RegistryManager.ACTIVE.getSuperType(r.getKey());
loadRegistry(r.getKey(), STAGING, RegistryManager.ACTIVE, registrySuperType, true);
}
final Class<? extends IForgeRegistryEntry> registrySuperType = RegistryManager.ACTIVE.getSuperType(key);
loadRegistry(key, STAGING, RegistryManager.ACTIVE, registrySuperType, true);
});
// Dump the active registry
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.dump(name));
@ -700,7 +695,7 @@ public class GameData
}
//Has to be split because of generics, Yay!
private static <T extends ForgeRegistryEntry<T>> void loadPersistentDataToStagingRegistry(RegistryManager pool, RegistryManager to, Map<ResourceLocation, Integer[]> remaps, Map<ResourceLocation, Integer> missing, ResourceLocation name, ForgeRegistry.Snapshot snap, Class<T> regType)
private static <T extends IForgeRegistryEntry<T>> void loadPersistentDataToStagingRegistry(RegistryManager pool, RegistryManager to, Map<ResourceLocation, Integer[]> remaps, Map<ResourceLocation, Integer> missing, ResourceLocation name, ForgeRegistry.Snapshot snap, Class<T> regType)
{
ForgeRegistry<T> active = pool.getRegistry(name);
if (active == null)
@ -715,7 +710,7 @@ public class GameData
//Another bouncer for generic reasons
@SuppressWarnings("unchecked")
private static <T extends ForgeRegistryEntry<T>> void processMissing(Class<T> clazz, ResourceLocation name, RegistryManager STAGING, MissingMappings<?> e, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, Integer[]> remaps, Collection<ResourceLocation> defaulted, Collection<ResourceLocation> failed, boolean injectNetworkDummies)
private static <T extends IForgeRegistryEntry<T>> void processMissing(Class<T> clazz, ResourceLocation name, RegistryManager STAGING, MissingMappings<?> e, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, Integer[]> remaps, Collection<ResourceLocation> defaulted, Collection<ResourceLocation> failed, boolean injectNetworkDummies)
{
List<MissingMappings.Mapping<T>> mappings = ((MissingMappings<T>)e).getAllMappings();
ForgeRegistry<T> active = RegistryManager.ACTIVE.getRegistry(name);
@ -723,7 +718,7 @@ public class GameData
staging.processMissingEvent(name, active, mappings, missing, remaps, defaulted, failed, injectNetworkDummies);
}
private static <T extends ForgeRegistryEntry<T>> void loadFrozenDataToStagingRegistry(RegistryManager STAGING, ResourceLocation name, Map<ResourceLocation, Integer[]> remaps, Class<T> clazz)
private static <T extends IForgeRegistryEntry<T>> void loadFrozenDataToStagingRegistry(RegistryManager STAGING, ResourceLocation name, Map<ResourceLocation, Integer[]> remaps, Class<T> clazz)
{
ForgeRegistry<T> frozen = RegistryManager.FROZEN.getRegistry(name);
ForgeRegistry<T> newRegistry = STAGING.getRegistry(name, RegistryManager.FROZEN);
@ -781,11 +776,10 @@ public class GameData
int index = name.lastIndexOf(':');
String oldPrefix = index == -1 ? "" : name.substring(0, index).toLowerCase(Locale.ROOT);
name = index == -1 ? name : name.substring(index + 1);
ModContainer mc = Loader.instance().activeModContainer();
String prefix = mc == null || (mc instanceof InjectedModContainer && ((InjectedModContainer)mc).wrappedContainer instanceof FMLContainer) ? "minecraft" : mc.getModId().toLowerCase(Locale.ROOT);
String prefix = ModThreadContext.get().getActiveContainer().getPrefix();
if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
{
FMLLog.log.warn("Potentially Dangerous alternative prefix `{}` for name `{}`, expected `{}`. This could be a intended override, but in most cases indicates a broken mod.", oldPrefix, name, prefix);
LogManager.getLogger().info("Potentially Dangerous alternative prefix `{}` for name `{}`, expected `{}`. This could be a intended override, but in most cases indicates a broken mod.", oldPrefix, name, prefix);
prefix = oldPrefix;
}
return new ResourceLocation(prefix, name);
@ -798,7 +792,7 @@ public class GameData
{
try
{
regName = IForgeRegistryEntry.Impl.class.getDeclaredField("registryName");
regName = ForgeRegistryEntry.class.getDeclaredField("registryName");
regName.setAccessible(true);
}
catch (NoSuchFieldException | SecurityException e)

View File

@ -20,7 +20,6 @@
package net.minecraftforge.registries;
import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
@ -34,7 +33,7 @@ import javax.annotation.Nullable;
*
* @param <V> The top level type for the registry
*/
public interface IForgeRegistry<V extends ForgeRegistryEntry<V>> extends Iterable<V>
public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterable<V>
{
Class<V> getRegistrySuperType();
@ -49,13 +48,7 @@ public interface IForgeRegistry<V extends ForgeRegistryEntry<V>> extends Iterabl
@Nullable ResourceLocation getKey(V value);
@Nonnull Set<ResourceLocation> getKeys();
/** @deprecated use {@link #getValuesCollection} */
@Deprecated // TODO: remove in 1.13
@Nonnull List<V> getValues();
@Nonnull
default Collection<V> getValuesCollection() { // TODO rename this to getValues in 1.13
return getValues();
}
@Nonnull Collection<V> getValues();
@Nonnull Set<Entry<ResourceLocation, V>> getEntries();
/**
@ -72,7 +65,7 @@ public interface IForgeRegistry<V extends ForgeRegistryEntry<V>> extends Iterabl
* Callback fired when objects are added to the registry. This will fire when the registry is rebuilt
* on the client side from a server side synchronization, or when a world is loaded.
*/
interface AddCallback<V extends ForgeRegistryEntry<V>>
interface AddCallback<V extends IForgeRegistryEntry<V>>
{
void onAdd(IForgeRegistryInternal<V> owner, RegistryManager stage, int id, V obj, @Nullable V oldObj);
}
@ -81,7 +74,7 @@ public interface IForgeRegistry<V extends ForgeRegistryEntry<V>> extends Iterabl
* Callback fired when the registry is cleared. This is done before a registry is reloaded from client
* or server.
*/
interface ClearCallback<V extends ForgeRegistryEntry<V>>
interface ClearCallback<V extends IForgeRegistryEntry<V>>
{
void onClear(IForgeRegistryInternal<V> owner, RegistryManager stage);
}
@ -89,7 +82,7 @@ public interface IForgeRegistry<V extends ForgeRegistryEntry<V>> extends Iterabl
/**
* Callback fired when a registry instance is created. Populate slave maps here.
*/
interface CreateCallback<V extends ForgeRegistryEntry<V>>
interface CreateCallback<V extends IForgeRegistryEntry<V>>
{
void onCreate(IForgeRegistryInternal<V> owner, RegistryManager stage);
}
@ -105,7 +98,7 @@ public interface IForgeRegistry<V extends ForgeRegistryEntry<V>> extends Iterabl
/**
* Factory for creating dummy entries, allowing worlds to be loaded and keep the missing block references.
*/
interface DummyFactory<V extends ForgeRegistryEntry<V>>
interface DummyFactory<V extends IForgeRegistryEntry<V>>
{
V createDummy(ResourceLocation key);
}
@ -113,7 +106,7 @@ public interface IForgeRegistry<V extends ForgeRegistryEntry<V>> extends Iterabl
/**
*
*/
interface MissingFactory<V extends ForgeRegistryEntry<V>>
interface MissingFactory<V extends IForgeRegistryEntry<V>>
{
V createMissing(ResourceLocation key, boolean isNetwork);
}

View File

@ -18,9 +18,6 @@
*/
package net.minecraftforge.registries;
import com.google.common.reflect.TypeToken;
import net.minecraft.util.ResourceLocation;
import javax.annotation.Nullable;
@ -41,7 +38,7 @@ public interface IForgeRegistryEntry<V>
*
* @param name Unique registry name
* @return This instance
* /
*/
V setRegistryName(ResourceLocation name);
/**
@ -50,44 +47,15 @@ public interface IForgeRegistryEntry<V>
* If neither are valid null is returned.
*
* @return Unique identifier or null.
* /
*/
@Nullable
ResourceLocation getRegistryName();
/**
* Determines the type for this entry, used to look up the correct registry in the global registries list as there can only be one
* registry per concrete class.
*
* @return Root registry type.
*/
Class<V> getRegistryType();
// Default implementation, modders who make extra items SHOULD extend this instead of Object.
// So, all fields in interfaces are forced static, so even with Java8 people must still extend this.
@SuppressWarnings({ "serial", "unchecked" })
public static class Impl<T extends IForgeRegistryEntry<T>> implements IForgeRegistryEntry<T>
{
private TypeToken<T> token = new TypeToken<T>(getClass()){};
public final IRegistryDelegate<T> delegate = new RegistryDelegate<T>((T)this, (Class<T>)token.getRawType());
private ResourceLocation registryName = null;
public final T setRegistryName(String name)
{
if (getRegistryName() != null)
throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName());
this.registryName = GameData.checkPrefix(name);
return (T)this;
}
//Helper functions
@Override
public final T setRegistryName(ResourceLocation name){ return setRegistryName(name.toString()); }
public final T setRegistryName(String modID, String name){ return setRegistryName(modID + ":" + name); }
@Override
@Nullable
public final ResourceLocation getRegistryName()
{
if (delegate.name() != null) return delegate.name();
return registryName != null ? registryName : null;
}
@Override
public final Class<T> getRegistryType() { return (Class<T>) token.getRawType(); };
}
*/
}

View File

@ -21,7 +21,7 @@ package net.minecraftforge.registries;
import net.minecraft.util.ResourceLocation;
public interface IForgeRegistryInternal<V extends ForgeRegistryEntry<V>> extends IForgeRegistry<V>
public interface IForgeRegistryInternal<V extends IForgeRegistryEntry<V>> extends IForgeRegistry<V>
{
void setSlaveMap(ResourceLocation name, Object obj);
}

View File

@ -33,7 +33,7 @@ import net.minecraft.util.registry.RegistryNamespacedDefaultedByKey;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
class NamespacedDefaultedWrapper<V extends ForgeRegistryEntry<V>> extends RegistryNamespacedDefaultedByKey<ResourceLocation, V> implements ILockableRegistry
class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespacedDefaultedByKey<ResourceLocation, V> implements ILockableRegistry
{
private static final Logger LOGGER = LogManager.getLogger();
private boolean locked = false;
@ -130,7 +130,7 @@ class NamespacedDefaultedWrapper<V extends ForgeRegistryEntry<V>> extends Regist
@Override
public void lock(){ this.locked = true; }
public static class Factory<V extends ForgeRegistryEntry<V>> implements IForgeRegistry.CreateCallback<V>
public static class Factory<V extends IForgeRegistryEntry<V>> implements IForgeRegistry.CreateCallback<V>
{
public static final ResourceLocation ID = new ResourceLocation("forge", "registry_defaulted_wrapper");
@Override

View File

@ -33,7 +33,7 @@ import net.minecraft.util.registry.RegistryNamespaced;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
class NamespacedWrapper<V extends ForgeRegistryEntry<V>> extends RegistryNamespaced<ResourceLocation, V> implements ILockableRegistry
class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamespaced<ResourceLocation, V> implements ILockableRegistry
{
private static final Logger LOGGER = LogManager.getLogger();
private boolean locked = false;
@ -125,7 +125,7 @@ class NamespacedWrapper<V extends ForgeRegistryEntry<V>> extends RegistryNamespa
@Override
public void lock(){ this.locked = true; }
public static class Factory<V extends ForgeRegistryEntry<V>> implements IForgeRegistry.CreateCallback<V>
public static class Factory<V extends IForgeRegistryEntry<V>> implements IForgeRegistry.CreateCallback<V>
{
public static final ResourceLocation ID = new ResourceLocation("forge", "registry_defaulted_wrapper");
@Override

View File

@ -28,7 +28,7 @@ import net.minecraftforge.registries.IForgeRegistry.*;
import javax.annotation.Nullable;
public class RegistryBuilder<T extends ForgeRegistryEntry<T>>
public class RegistryBuilder<T extends IForgeRegistryEntry<T>>
{
private ResourceLocation registryName;
private Class<T> registryType;

View File

@ -44,7 +44,7 @@ public class RegistryManager
public static final RegistryManager FROZEN = new RegistryManager("FROZEN");
BiMap<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> registries = HashBiMap.create();
private BiMap<Class<? extends ForgeRegistryEntry<?>>, ResourceLocation> superTypes = HashBiMap.create();
private BiMap<Class<? extends IForgeRegistryEntry<?>>, ResourceLocation> superTypes = HashBiMap.create();
private Set<ResourceLocation> persisted = Sets.newHashSet();
private final String name;