mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 19:15:32 +00:00
Server starts
This commit is contained in:
1 parent
330db1a54d
commit
b50b768852
44 files changed
+449
-475
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package net.minecraftforge.fml;
|
||||
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class UnsafeHacks
|
||||
{
|
||||
private static final Unsafe UNSAFE;
|
||||
static {
|
||||
try
|
||||
{
|
||||
final Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
|
||||
theUnsafe.setAccessible(true);
|
||||
UNSAFE = (Unsafe)theUnsafe.get(null);
|
||||
}
|
||||
catch (IllegalAccessException | NoSuchFieldException e)
|
||||
{
|
||||
throw new RuntimeException("BARF!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getField(Field field, Object object) {
|
||||
final long l = UNSAFE.objectFieldOffset(field);
|
||||
return (T) UNSAFE.getObject(object, l);
|
||||
}
|
||||
|
||||
public static <T> T getField(Object object) {
|
||||
UNSAFE.staticFieldBase()
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user