Fix #61
This commit is contained in:
parent
d056ce8753
commit
556a501f75
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tamablefoxes_v1_14_R1</artifactId>
|
<artifactId>tamablefoxes_v1_14_R1</artifactId>
|
||||||
|
@ -41,15 +41,5 @@
|
||||||
<artifactId>anvilgui</artifactId>
|
<artifactId>anvilgui</artifactId>
|
||||||
<version>1.5.1-SNAPSHOT</version>
|
<version>1.5.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm-tree</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -4,45 +4,24 @@ import net.minecraft.server.v1_14_R1.EntityFox;
|
||||||
import net.minecraft.server.v1_14_R1.EntityTypes;
|
import net.minecraft.server.v1_14_R1.EntityTypes;
|
||||||
import net.seanomik.tamablefoxes.util.FieldHelper;
|
import net.seanomik.tamablefoxes.util.FieldHelper;
|
||||||
import net.seanomik.tamablefoxes.util.NMSInterface;
|
import net.seanomik.tamablefoxes.util.NMSInterface;
|
||||||
import net.seanomik.tamablefoxes.util.Utils;
|
import net.seanomik.tamablefoxes.util.io.Config;
|
||||||
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||||
|
|
||||||
// In IntelliJ, these show up as an error, but it compiles fine.
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class NMSInterface_1_14_R1 implements NMSInterface {
|
public class NMSInterface_1_14_R1 implements NMSInterface {
|
||||||
@Override
|
@Override
|
||||||
public void registerCustomFoxEntity() {
|
public void registerCustomFoxEntity() {
|
||||||
Class<?> clazz = null;
|
|
||||||
try {
|
|
||||||
// This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox`
|
|
||||||
ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class"));
|
|
||||||
ClassNode node = new ClassNode();
|
|
||||||
cr.accept(node, 0);
|
|
||||||
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
|
||||||
node.accept(cw);
|
|
||||||
clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try { // Replace the fox entity
|
try { // Replace the fox entity
|
||||||
Field field = EntityTypes.FOX.getClass().getDeclaredField("aZ"); // aZ = factory
|
Field field = EntityTypes.FOX.getClass().getDeclaredField("aZ"); // aZ = factory
|
||||||
Class<?> finalClazz = clazz;
|
|
||||||
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tamablefoxes_v1_15_R1</artifactId>
|
<artifactId>tamablefoxes_v1_15_R1</artifactId>
|
||||||
|
@ -41,15 +41,5 @@
|
||||||
<artifactId>anvilgui</artifactId>
|
<artifactId>anvilgui</artifactId>
|
||||||
<version>1.5.1-SNAPSHOT</version>
|
<version>1.5.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm-tree</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -4,45 +4,24 @@ import net.minecraft.server.v1_15_R1.EntityFox;
|
||||||
import net.minecraft.server.v1_15_R1.EntityTypes;
|
import net.minecraft.server.v1_15_R1.EntityTypes;
|
||||||
import net.seanomik.tamablefoxes.util.FieldHelper;
|
import net.seanomik.tamablefoxes.util.FieldHelper;
|
||||||
import net.seanomik.tamablefoxes.util.NMSInterface;
|
import net.seanomik.tamablefoxes.util.NMSInterface;
|
||||||
import net.seanomik.tamablefoxes.util.Utils;
|
import net.seanomik.tamablefoxes.util.io.Config;
|
||||||
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||||
|
|
||||||
// In IntelliJ, these show up as an error, but it compiles fine.
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class NMSInterface_1_15_R1 implements NMSInterface {
|
public class NMSInterface_1_15_R1 implements NMSInterface {
|
||||||
@Override
|
@Override
|
||||||
public void registerCustomFoxEntity() {
|
public void registerCustomFoxEntity() {
|
||||||
Class<?> clazz = null;
|
|
||||||
try {
|
|
||||||
// This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox`
|
|
||||||
ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class"));
|
|
||||||
ClassNode node = new ClassNode();
|
|
||||||
cr.accept(node, 0);
|
|
||||||
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
|
||||||
node.accept(cw);
|
|
||||||
clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try { // Replace the fox entity
|
try { // Replace the fox entity
|
||||||
Field field = EntityTypes.FOX.getClass().getDeclaredField("ba"); // ba = factory
|
Field field = EntityTypes.FOX.getClass().getDeclaredField("ba"); // ba = factory
|
||||||
Class<?> finalClazz = clazz;
|
|
||||||
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tamablefoxes_v1_16_R1</artifactId>
|
<artifactId>tamablefoxes_v1_16_R1</artifactId>
|
||||||
|
@ -41,15 +41,5 @@
|
||||||
<artifactId>anvilgui</artifactId>
|
<artifactId>anvilgui</artifactId>
|
||||||
<version>1.5.1-SNAPSHOT</version>
|
<version>1.5.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm-tree</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -4,45 +4,24 @@ import net.minecraft.server.v1_16_R1.EntityFox;
|
||||||
import net.minecraft.server.v1_16_R1.EntityTypes;
|
import net.minecraft.server.v1_16_R1.EntityTypes;
|
||||||
import net.seanomik.tamablefoxes.util.FieldHelper;
|
import net.seanomik.tamablefoxes.util.FieldHelper;
|
||||||
import net.seanomik.tamablefoxes.util.NMSInterface;
|
import net.seanomik.tamablefoxes.util.NMSInterface;
|
||||||
import net.seanomik.tamablefoxes.util.Utils;
|
import net.seanomik.tamablefoxes.util.io.Config;
|
||||||
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_16_R1.entity.CraftEntity;
|
||||||
|
|
||||||
// In IntelliJ, these show up as an error, but it compiles fine.
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class NMSInterface_1_16_R1 implements NMSInterface {
|
public class NMSInterface_1_16_R1 implements NMSInterface {
|
||||||
@Override
|
@Override
|
||||||
public void registerCustomFoxEntity() {
|
public void registerCustomFoxEntity() {
|
||||||
Class<?> clazz = null;
|
|
||||||
try {
|
|
||||||
// This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox`
|
|
||||||
ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class"));
|
|
||||||
ClassNode node = new ClassNode();
|
|
||||||
cr.accept(node, 0);
|
|
||||||
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
|
||||||
node.accept(cw);
|
|
||||||
clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try { // Replace the fox entity
|
try { // Replace the fox entity
|
||||||
Field field = EntityTypes.FOX.getClass().getDeclaredField("be"); // be = factory
|
Field field = EntityTypes.FOX.getClass().getDeclaredField("be"); // be = factory
|
||||||
Class<?> finalClazz = clazz;
|
|
||||||
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tamablefoxes_v1_16_R2</artifactId>
|
<artifactId>tamablefoxes_v1_16_R2</artifactId>
|
||||||
|
@ -41,15 +41,5 @@
|
||||||
<artifactId>anvilgui</artifactId>
|
<artifactId>anvilgui</artifactId>
|
||||||
<version>1.5.1-SNAPSHOT</version>
|
<version>1.5.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm-tree</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -4,45 +4,24 @@ import net.minecraft.server.v1_16_R2.EntityFox;
|
||||||
import net.minecraft.server.v1_16_R2.EntityTypes;
|
import net.minecraft.server.v1_16_R2.EntityTypes;
|
||||||
import net.seanomik.tamablefoxes.util.FieldHelper;
|
import net.seanomik.tamablefoxes.util.FieldHelper;
|
||||||
import net.seanomik.tamablefoxes.util.NMSInterface;
|
import net.seanomik.tamablefoxes.util.NMSInterface;
|
||||||
import net.seanomik.tamablefoxes.util.Utils;
|
import net.seanomik.tamablefoxes.util.io.Config;
|
||||||
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_16_R2.entity.CraftEntity;
|
||||||
|
|
||||||
// In IntelliJ, these show up as an error, but it compiles fine.
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class NMSInterface_1_16_R2 implements NMSInterface {
|
public class NMSInterface_1_16_R2 implements NMSInterface {
|
||||||
@Override
|
@Override
|
||||||
public void registerCustomFoxEntity() {
|
public void registerCustomFoxEntity() {
|
||||||
Class<?> clazz = null;
|
|
||||||
try {
|
|
||||||
// This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox`
|
|
||||||
ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class"));
|
|
||||||
ClassNode node = new ClassNode();
|
|
||||||
cr.accept(node, 0);
|
|
||||||
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
|
||||||
node.accept(cw);
|
|
||||||
clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try { // Replace the fox entity
|
try { // Replace the fox entity
|
||||||
Field field = EntityTypes.FOX.getClass().getDeclaredField("bf"); // bm = factory
|
Field field = EntityTypes.FOX.getClass().getDeclaredField("bf"); // bf = factory
|
||||||
Class<?> finalClazz = clazz;
|
|
||||||
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tamablefoxes_v1_16_R3</artifactId>
|
<artifactId>tamablefoxes_v1_16_R3</artifactId>
|
||||||
|
@ -41,15 +41,5 @@
|
||||||
<artifactId>anvilgui</artifactId>
|
<artifactId>anvilgui</artifactId>
|
||||||
<version>1.5.1-SNAPSHOT</version>
|
<version>1.5.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm-tree</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -4,45 +4,24 @@ import net.minecraft.server.v1_16_R3.EntityFox;
|
||||||
import net.minecraft.server.v1_16_R3.EntityTypes;
|
import net.minecraft.server.v1_16_R3.EntityTypes;
|
||||||
import net.seanomik.tamablefoxes.util.FieldHelper;
|
import net.seanomik.tamablefoxes.util.FieldHelper;
|
||||||
import net.seanomik.tamablefoxes.util.NMSInterface;
|
import net.seanomik.tamablefoxes.util.NMSInterface;
|
||||||
import net.seanomik.tamablefoxes.util.Utils;
|
import net.seanomik.tamablefoxes.util.io.Config;
|
||||||
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity;
|
||||||
|
|
||||||
// In IntelliJ, these show up as an error, but it compiles fine.
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class NMSInterface_1_16_R3 implements NMSInterface {
|
public class NMSInterface_1_16_R3 implements NMSInterface {
|
||||||
@Override
|
@Override
|
||||||
public void registerCustomFoxEntity() {
|
public void registerCustomFoxEntity() {
|
||||||
Class<?> clazz = null;
|
|
||||||
try {
|
|
||||||
// This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox`
|
|
||||||
ClassReader cr = new ClassReader(EntityFox.class.getResourceAsStream("EntityFox.class"));
|
|
||||||
ClassNode node = new ClassNode();
|
|
||||||
cr.accept(node, 0);
|
|
||||||
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
|
||||||
node.accept(cw);
|
|
||||||
clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try { // Replace the fox entity
|
try { // Replace the fox entity
|
||||||
Field field = EntityTypes.FOX.getClass().getDeclaredField("bf"); // bm = factory
|
Field field = EntityTypes.FOX.getClass().getDeclaredField("bf"); // bf = factory
|
||||||
Class<?> finalClazz = clazz;
|
|
||||||
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
FieldHelper.setFieldUsingUnsafe(field, EntityTypes.FOX, (EntityTypes.b<EntityFox>) EntityTamableFox::new);
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -80,15 +80,5 @@
|
||||||
<artifactId>anvilgui</artifactId>
|
<artifactId>anvilgui</artifactId>
|
||||||
<version>1.5.1-SNAPSHOT</version>
|
<version>1.5.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm-tree</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -4,45 +4,24 @@ import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.animal.Fox;
|
import net.minecraft.world.entity.animal.Fox;
|
||||||
import net.seanomik.tamablefoxes.util.FieldHelper;
|
import net.seanomik.tamablefoxes.util.FieldHelper;
|
||||||
import net.seanomik.tamablefoxes.util.NMSInterface;
|
import net.seanomik.tamablefoxes.util.NMSInterface;
|
||||||
import net.seanomik.tamablefoxes.util.Utils;
|
import net.seanomik.tamablefoxes.util.io.Config;
|
||||||
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
|
||||||
|
|
||||||
// In IntelliJ, these show up as an error, but it compiles fine.
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class NMSInterface_1_17_1_R1 implements NMSInterface {
|
public class NMSInterface_1_17_1_R1 implements NMSInterface {
|
||||||
@Override
|
@Override
|
||||||
public void registerCustomFoxEntity() {
|
public void registerCustomFoxEntity() {
|
||||||
Class<?> clazz = null;
|
|
||||||
try {
|
|
||||||
// This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox`
|
|
||||||
ClassReader cr = new ClassReader(Fox.class.getResourceAsStream("EntityFox.class"));
|
|
||||||
ClassNode node = new ClassNode();
|
|
||||||
cr.accept(node, 0);
|
|
||||||
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
|
||||||
node.accept(cw);
|
|
||||||
clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try { // Replace the fox entity
|
try { // Replace the fox entity
|
||||||
Field field = EntityType.FOX.getClass().getDeclaredField("bm"); // bm = factory
|
Field field = EntityType.FOX.getClass().getDeclaredField("bm"); // bm = factory
|
||||||
Class<?> finalClazz = clazz;
|
|
||||||
FieldHelper.setFieldUsingUnsafe(field, EntityType.FOX, (EntityType.EntityFactory<Fox>) EntityTamableFox::new);
|
FieldHelper.setFieldUsingUnsafe(field, EntityType.FOX, (EntityType.EntityFactory<Fox>) EntityTamableFox::new);
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -80,15 +80,5 @@
|
||||||
<artifactId>anvilgui</artifactId>
|
<artifactId>anvilgui</artifactId>
|
||||||
<version>1.5.1-SNAPSHOT</version>
|
<version>1.5.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ow2.asm</groupId>
|
|
||||||
<artifactId>asm-tree</artifactId>
|
|
||||||
<version>9.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -4,45 +4,24 @@ import net.minecraft.world.entity.EntityType;
|
||||||
import net.minecraft.world.entity.animal.Fox;
|
import net.minecraft.world.entity.animal.Fox;
|
||||||
import net.seanomik.tamablefoxes.util.FieldHelper;
|
import net.seanomik.tamablefoxes.util.FieldHelper;
|
||||||
import net.seanomik.tamablefoxes.util.NMSInterface;
|
import net.seanomik.tamablefoxes.util.NMSInterface;
|
||||||
import net.seanomik.tamablefoxes.util.Utils;
|
import net.seanomik.tamablefoxes.util.io.Config;
|
||||||
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
import net.seanomik.tamablefoxes.util.io.LanguageConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
|
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
|
||||||
|
|
||||||
// In IntelliJ, these show up as an error, but it compiles fine.
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.tree.ClassNode;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class NMSInterface_1_17_R1 implements NMSInterface {
|
public class NMSInterface_1_17_R1 implements NMSInterface {
|
||||||
@Override
|
@Override
|
||||||
public void registerCustomFoxEntity() {
|
public void registerCustomFoxEntity() {
|
||||||
Class<?> clazz = null;
|
|
||||||
try {
|
|
||||||
// This must be `EntityFox` since after being compiled, the class goes back to `EntityFox` instead of `Fox`
|
|
||||||
ClassReader cr = new ClassReader(Fox.class.getResourceAsStream("EntityFox.class"));
|
|
||||||
ClassNode node = new ClassNode();
|
|
||||||
cr.accept(node, 0);
|
|
||||||
|
|
||||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
|
||||||
node.accept(cw);
|
|
||||||
clazz = new ClassDefiner(ClassLoader.getSystemClassLoader()).get(node.name.replace("/", "."), cw.toByteArray());
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
try { // Replace the fox entity
|
try { // Replace the fox entity
|
||||||
Field field = EntityType.FOX.getClass().getDeclaredField("bm"); // bm = factory
|
Field field = EntityType.FOX.getClass().getDeclaredField("bm"); // bm = factory
|
||||||
Class<?> finalClazz = clazz;
|
|
||||||
FieldHelper.setFieldUsingUnsafe(field, EntityType.FOX, (EntityType.EntityFactory<Fox>) EntityTamableFox::new);
|
FieldHelper.setFieldUsingUnsafe(field, EntityType.FOX, (EntityType.EntityFactory<Fox>) EntityTamableFox::new);
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.GREEN + LanguageConfig.getSuccessReplaced());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Bukkit.getServer().getConsoleSender().sendMessage(Utils.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
Bukkit.getServer().getConsoleSender().sendMessage(Config.getPrefix() + ChatColor.RED + LanguageConfig.getFailureReplace());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tamablefoxes</artifactId>
|
<artifactId>tamablefoxes</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>tamablefoxes-util</artifactId>
|
<artifactId>tamablefoxes-util</artifactId>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>net.seanomik</groupId>
|
<groupId>net.seanomik</groupId>
|
||||||
<artifactId>tamablefoxes-parent</artifactId>
|
<artifactId>tamablefoxes-parent</artifactId>
|
||||||
<version>2.1.4-SNAPSHOT</version>
|
<version>2.1.5-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
|
Loading…
Reference in New Issue