From 6d542dec5a299bee12aaffe12e5e1beb7a5388e5 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Sat, 30 Jul 2016 14:06:07 -0500 Subject: [PATCH] Clean up methodhandles --- .../core/handler/ClientMethodHandles.java | 38 +------------------ .../common/core/handler/MethodHandles.java | 8 +--- .../vazkii/botania/common/lib/LibMisc.java | 2 +- .../botania/common/lib/LibObfuscation.java | 16 -------- .../common/world/SkyblockWorldEvents.java | 5 +-- 5 files changed, 5 insertions(+), 64 deletions(-) diff --git a/src/main/java/vazkii/botania/client/core/handler/ClientMethodHandles.java b/src/main/java/vazkii/botania/client/core/handler/ClientMethodHandles.java index 8f4ccd30d..d63e62c2a 100644 --- a/src/main/java/vazkii/botania/client/core/handler/ClientMethodHandles.java +++ b/src/main/java/vazkii/botania/client/core/handler/ClientMethodHandles.java @@ -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(); diff --git a/src/main/java/vazkii/botania/common/core/handler/MethodHandles.java b/src/main/java/vazkii/botania/common/core/handler/MethodHandles.java index 6f4753591..fec57d0b4 100644 --- a/src/main/java/vazkii/botania/common/core/handler/MethodHandles.java +++ b/src/main/java/vazkii/botania/common/core/handler/MethodHandles.java @@ -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); diff --git a/src/main/java/vazkii/botania/common/lib/LibMisc.java b/src/main/java/vazkii/botania/common/lib/LibMisc.java index cdc826a11..5022e29bf 100644 --- a/src/main/java/vazkii/botania/common/lib/LibMisc.java +++ b/src/main/java/vazkii/botania/common/lib/LibMisc.java @@ -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"; diff --git a/src/main/java/vazkii/botania/common/lib/LibObfuscation.java b/src/main/java/vazkii/botania/common/lib/LibObfuscation.java index cb154c568..25516be05 100644 --- a/src/main/java/vazkii/botania/common/lib/LibObfuscation.java +++ b/src/main/java/vazkii/botania/common/lib/LibObfuscation.java @@ -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" }; - } diff --git a/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java b/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java index 57452544e..b1eb6d825 100644 --- a/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java +++ b/src/main/java/vazkii/botania/common/world/SkyblockWorldEvents.java @@ -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);