Skip to content

Commit

Permalink
Try to fix registering new entities
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperDeborah committed Oct 10, 2023
1 parent 1cef0aa commit fb82cbb
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/no/runsafe/framework/tools/nms/EntityRegister.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.server.v1_12_R1.Entity;
import net.minecraft.server.v1_12_R1.EntityTypes;
import net.minecraft.server.v1_12_R1.MinecraftKey;

import java.io.DataOutput;
import java.lang.reflect.Field;
Expand All @@ -16,16 +17,9 @@ private EntityRegister()

public static <E extends Entity> void registerEntity(Class<E> customClass, String name, int id)
{
try
{
Method method = EntityTypes.class.getDeclaredMethod("a", int.class, String.class, Class.class, String.class );
method.setAccessible(true);
method.invoke(EntityTypes.class, id, name, customClass, name);
}
catch (Exception e)
{
// no custom entities for you
}
MinecraftKey key = new MinecraftKey(name);
EntityTypes.b.a(id, key, customClass);
EntityTypes.d.add(key);
}

public static <E extends Entity> void registerOverrideEntity(Class<E> customClass, String name, int id)
Expand Down

0 comments on commit fb82cbb

Please sign in to comment.