Clean up methodhandles

This commit is contained in:
Vincent Lee committed 2016-07-30 14:06:07 -05:00
1 parent 4552a451ae
commit 6d542dec5a
5 files changed
+5 -64

No files matched your search

@@ -15,11 +15,7 @@ import java.lang.reflect.Method;
public final class ClientMethodHandles {
public static final MethodHandle
renderPosX_getter, renderPosY_getter, renderPosZ_getter, // RenderManager
farPlaneDistance_getter,
hurtCameraEffect, setupViewBobbing, getFOVModifier,
enableLightmap, disableLightmap; // EntityRenderer
//prevEquippedProgress_getter, equippedProgress_getter; // ItemRenderer
renderPosX_getter, renderPosY_getter, renderPosZ_getter; // RenderManager
static {
try {
@@ -34,38 +30,6 @@ public final class ClientMethodHandles {
f = ReflectionHelper.findField(RenderManager.class, LibObfuscation.RENDERPOSZ);
f.setAccessible(true);
renderPosZ_getter = MethodHandles.publicLookup().unreflectGetter(f);
f = ReflectionHelper.findField(EntityRenderer.class, LibObfuscation.FAR_PLANE_DISTANCE);
f.setAccessible(true);
farPlaneDistance_getter = MethodHandles.publicLookup().unreflectGetter(f);
Method m = ReflectionHelper.findMethod(EntityRenderer.class, null, LibObfuscation.HURT_CAMERA_EFFECT, float.class);
m.setAccessible(true);
hurtCameraEffect = MethodHandles.publicLookup().unreflect(m);
m = ReflectionHelper.findMethod(EntityRenderer.class, null, LibObfuscation.SETUP_VIEW_BOBBING, float.class);
m.setAccessible(true);
setupViewBobbing = MethodHandles.publicLookup().unreflect(m);
m = ReflectionHelper.findMethod(EntityRenderer.class, null, LibObfuscation.ENABLE_LIGHTMAP);
m.setAccessible(true);
enableLightmap = MethodHandles.publicLookup().unreflect(m);
m = ReflectionHelper.findMethod(EntityRenderer.class, null, LibObfuscation.DISABLE_LIGHTMAP);
m.setAccessible(true);
disableLightmap = MethodHandles.publicLookup().unreflect(m);
m = ReflectionHelper.findMethod(EntityRenderer.class, null, LibObfuscation.GET_FOV_MODIFIER, float.class, boolean.class);
m.setAccessible(true);
getFOVModifier = MethodHandles.publicLookup().unreflect(m);
// f = ReflectionHelper.findField(ItemRenderer.class, LibObfuscation.PREV_EQUIPPED_PROGRESS);
// f.setAccessible(true);
// prevEquippedProgress_getter = MethodHandles.publicLookup().unreflectGetter(f);
//
// f = ReflectionHelper.findField(ItemRenderer.class, LibObfuscation.EQUIPPED_PROGRESS);
// f.setAccessible(true);
// equippedProgress_getter = MethodHandles.publicLookup().unreflectGetter(f);
} catch (IllegalAccessException e) {
Botania.LOGGER.fatal("Couldn't initialize client methodhandles! Things will be broken!");
e.printStackTrace();
@@ -23,8 +23,8 @@ public final class MethodHandles {
spawnRange_getter, spawnCount_getter, maxNearbyEntities_getter,
maxSpawnDelay_getter, minSpawnDelay_getter,
spawnDelay_getter, spawnDelay_setter, prevMobRotation_setter, mobRotation_setter, potentialSpawns_getter,
randomEntity_getter, isActivated, // MobSpawnerBaseLogic
breakSound_getter; // SoundType
randomEntity_getter, isActivated; // MobSpawnerBaseLogic
static {
try {
@@ -81,10 +81,6 @@ public final class MethodHandles {
f.setAccessible(true);
randomEntity_getter = publicLookup().unreflectGetter(f);
f = ReflectionHelper.findField(SoundType.class, LibObfuscation.BREAK_SOUND);
f.setAccessible(true);
breakSound_getter = publicLookup().unreflectGetter(f);
Method m = ReflectionHelper.findMethod(MobSpawnerBaseLogic.class, null, LibObfuscation.IS_ACTIVATED);
m.setAccessible(true);
isActivated = publicLookup().unreflect(m);
@@ -17,7 +17,7 @@ public final class LibMisc {
public static final String MOD_NAME = MOD_ID;
public static final String BUILD = "GRADLE:BUILD";
public static final String VERSION = "GRADLE:VERSION-" + BUILD;
public static final String DEPENDENCIES = "required-after:Forge@[12.18.1.2024,];required-after:Baubles;after:Thaumcraft";
public static final String DEPENDENCIES = "required-after:Forge@[12.18.1.2034,];required-after:Baubles;after:Thaumcraft";
public static final String MC_VERSIONS = "[1.10.2]";
public static final String UPDATE_JSON = "https://raw.githubusercontent.com/williewillus/Botania/HEAD/version/update.json";
@@ -54,7 +54,6 @@ public final class LibObfuscation {
// PlayerControllerMP
public static final String[] NET_CLIENT_HANDLER = new String[] { "netClientHandler", "field_78774_b", "b" };
public static final String[] CURRENT_GAME_TYPE = new String[] { "currentGameType", "field_78779_k", "i" };
// MobSpawnerBaseLogic
public static final String[] IS_ACTIVATED = new String[] { "isActivated" ,"func_98279_f", "h" };
@@ -90,19 +89,4 @@ public final class LibObfuscation {
public static final String[] GL_SKY_LIST = new String[] { "glSkyList", "field_72771_w", "q" };
public static final String[] GL_SKY_LIST2 = new String[] { "glSkyList2", "field_72781_x", "r" };
// EntityRenderer
public static final String[] FAR_PLANE_DISTANCE = { "farPlaneDistance", "field_78530_s", "k" };
public static final String[] HURT_CAMERA_EFFECT = { "hurtCameraEffect", "func_78482_e", "d" };
public static final String[] SETUP_VIEW_BOBBING = { "setupViewBobbing", "func_78475_f", "e" };
public static final String[] ENABLE_LIGHTMAP = { "enableLightmap", "func_180436_i", "i" };
public static final String[] DISABLE_LIGHTMAP = { "disableLightmap", "func_175072_h", "h" };
public static final String[] GET_FOV_MODIFIER = { "getFOVModifier", "func_78481_a", "a" };
// ItemRenderer todo 1.9 dual wielding
public static final String[] PREV_EQUIPPED_PROGRESS = { "prevEquippedProgress", "field_78451_d", "f" };
public static final String[] EQUIPPED_PROGRESS = { "equippedProgress", "field_78454_c", "e" };
// SoundType
public static final String[] BREAK_SOUND = { "breakSound", "field_185862_o", "o" };
}
@@ -78,10 +78,7 @@ public final class SkyblockWorldEvents {
if(event.getWorld().isRemote)
event.getEntityPlayer().swingArm(event.getHand());
else {
try {
SoundEvent breakSound = (SoundEvent) MethodHandles.breakSound_getter.invokeExact(block.getSoundType());
event.getWorld().playSound(null, event.getPos(), breakSound, SoundCategory.BLOCKS, block.getSoundType().getVolume() * 0.4F, block.getSoundType().getPitch() + (float) (Math.random() * 0.2 - 0.1));
} catch (Throwable ignore) {}
event.getWorld().playSound(null, event.getPos(), block.getSoundType().getBreakSound(), SoundCategory.BLOCKS, block.getSoundType().getVolume() * 0.4F, block.getSoundType().getPitch() + (float) (Math.random() * 0.2 - 0.1));
if(Math.random() < 0.8)
event.getEntityPlayer().dropItem(new ItemStack(ModItems.manaResource, 1, 21), false);