diff options
| author | Alexdoru <57050655+Alexdoru@users.noreply.github.com> | 2024-09-28 13:25:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-28 11:25:01 +0000 |
| commit | 86f1765b171f4cc6f163b8027d1330f4e5094e2d (patch) | |
| tree | b6e293bd3c976558fc4e4b7190e4d342c2ddc555 /src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java | |
| parent | 6b1f145f5028f1bc92cf478e5963224e7d94b5cd (diff) | |
| download | GT5-Unofficial-86f1765b171f4cc6f163b8027d1330f4e5094e2d.tar.gz GT5-Unofficial-86f1765b171f4cc6f163b8027d1330f4e5094e2d.tar.bz2 GT5-Unofficial-86f1765b171f4cc6f163b8027d1330f4e5094e2d.zip | |
Remove more reflection + reorganize mixin accessors packages (#3260)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: boubou19 <miisterunknown@gmail.com>
Diffstat (limited to 'src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java')
| -rw-r--r-- | src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java index 8395f7b3f7..0d1151abaa 100644 --- a/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java +++ b/src/main/java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java @@ -10,39 +10,31 @@ import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.asm.GTCorePlugin; -import gtPlusPlus.api.interfaces.IPlugin; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import gtPlusPlus.plugin.fixes.interfaces.IBugFix; // TODO move this as a mixin in hodgepodge -public class VanillaBedHeightFix implements IBugFix { +public class VanillaBedHeightFix { private final Method mSleepInBedAt; - private final IPlugin mParent; - public VanillaBedHeightFix(IPlugin minstance) { - mParent = minstance; - Method m = ReflectionUtils.getMethod( - EntityPlayer.class, - GTCorePlugin.isDevEnv() ? "sleepInBedAt" : "func_71018_a", - int.class, - int.class, - int.class); + public VanillaBedHeightFix() { + Method m = null; + try { + m = EntityPlayer.class.getDeclaredMethod( + GTCorePlugin.isDevEnv() ? "sleepInBedAt" : "func_71018_a", + int.class, + int.class, + int.class); + } catch (NoSuchMethodException ignored) {} if (m != null) { mSleepInBedAt = m; - mParent.log("Registering Bed Height Fix."); + Logger.INFO("Registering Bed Height Fix."); MinecraftForge.EVENT_BUS.register(this); } else { mSleepInBedAt = null; } } - @Override - public boolean isFixValid() { - return mSleepInBedAt != null; - } - /** * Fix created by deNULL - * https://github.com/deNULL/BugPatch/blob/master/src/main/java/ru/denull/BugPatch/mod/ClientEvents.java#L45 @@ -52,7 +44,7 @@ public class VanillaBedHeightFix implements IBugFix { @SubscribeEvent(priority = EventPriority.HIGHEST) public void playerSleepInBed(PlayerSleepInBedEvent evt) { Logger.WARNING("Sleep Event Detected. Player is sleeping at Y: " + evt.y); - if (evt.y <= 0 && isFixValid()) { + if (evt.y <= 0) { int correctY = 256 + evt.y; if (correctY <= 0) { Logger.WARNING( @@ -73,9 +65,6 @@ public class VanillaBedHeightFix implements IBugFix { Logger.WARNING("Encountered an error trying to sleep."); } } - } else if (!isFixValid()) { - Logger.WARNING( - "Method sleepInBedAt was not found in EntityPlayer (wrong MC and/or Forge version?), unable to fix"); } } } |
