aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/plugin/fixes/vanilla
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2018-08-22 21:59:55 +1000
committerAlkalus <3060479+draknyte1@users.noreply.github.com>2018-08-22 21:59:55 +1000
commit60db2be3440ebb05a38052d3a5b556ed6834897f (patch)
tree73dcea7ccd3cd80a3347311cac8e13636a2efaec /src/Java/gtPlusPlus/plugin/fixes/vanilla
parent4152f23cb366a69a0966c973108fec3d7de86f7f (diff)
downloadGT5-Unofficial-60db2be3440ebb05a38052d3a5b556ed6834897f.tar.gz
GT5-Unofficial-60db2be3440ebb05a38052d3a5b556ed6834897f.tar.bz2
GT5-Unofficial-60db2be3440ebb05a38052d3a5b556ed6834897f.zip
$ Fixed an issue where old style circuits would constantly load up, ignoring all configuration settings.
$ Tweaked Vanilla Sleeping at heights fix. + Added an interface for bug fixes, for future flexibility.
Diffstat (limited to 'src/Java/gtPlusPlus/plugin/fixes/vanilla')
-rw-r--r--src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java2
-rw-r--r--src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java59
2 files changed, 34 insertions, 27 deletions
diff --git a/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java b/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java
index 49cdc26c38..8e7b73ccdf 100644
--- a/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java
+++ b/src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java
@@ -6,9 +6,11 @@ import gtPlusPlus.plugin.manager.Core_Manager;
public class Core_VanillaFixes implements IPlugin {
final static Core_VanillaFixes mInstance;
+ final static VanillaBedHeightFix mBedFixInstance;
static {
mInstance = new Core_VanillaFixes();
+ mBedFixInstance = new VanillaBedHeightFix();
mInstance.log("Preparing "+mInstance.getPluginName()+" for use.");
}
diff --git a/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java b/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java
index a6811b5a15..d0ef4587df 100644
--- a/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java
+++ b/src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java
@@ -5,62 +5,67 @@ import java.lang.reflect.Method;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-import cpw.mods.fml.relauncher.ReflectionHelper;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.plugin.fixes.interfaces.IBugFix;
import gtPlusPlus.preloader.DevHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
-public class VanillaBedHeightFix {
+public class VanillaBedHeightFix implements IBugFix {
- private static final VanillaBedHeightFix mInstance;
private final Method mSleepInBedAt;
- static {
- mInstance = new VanillaBedHeightFix();
- }
-
public VanillaBedHeightFix() {
if (DevHelper.isValidHelperObject()) {
- Method m = DevHelper.getInstance().getForgeMethod(EntityPlayer.class, "sleepInBedAt", int.class, int.class, int.class);
+ Method m = DevHelper.getInstance().getForgeMethod(EntityPlayer.class, "sleepInBedAt", int.class, int.class,
+ int.class);
if (m != null) {
mSleepInBedAt = m;
- Utils.registerEvent(this);
- }
- else {
+ Utils.registerEvent(this);
+ } else {
mSleepInBedAt = null;
}
+ } else {
+ mSleepInBedAt = null;
}
- else {
- mSleepInBedAt = null;
- }
+ }
+
+ 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
- * @param evt - The event where a player sleeps
+ * Fix created by deNULL -
+ * https://github.com/deNULL/BugPatch/blob/master/src/main/java/ru/denull/BugPatch/mod/ClientEvents.java#L45
+ *
+ * @param evt
+ * - The event where a player sleeps
*/
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void playerSleepInBed(PlayerSleepInBedEvent evt) {
- if (evt.y <= 0) {
+ Logger.WARNING("Sleep Event Detected. Player is sleeping at Y: " + evt.y);
+ if (evt.y <= 0 && isFixValid()) {
int correctY = 256 + evt.y;
if (correctY <= 0) {
- Logger.INFO("You're trying to sleep at y=" + evt.y + ", which is impossibly low. However, fixed y value is " + correctY + ", which is still below 0. Falling back to default behavior.");
+ Logger.WARNING(
+ "You're trying to sleep at y=" + evt.y + ", which is impossibly low. However, fixed y value is "
+ + correctY + ", which is still below 0. Falling back to default behavior.");
} else {
- Logger.INFO("You're trying to sleep at y=" + evt.y + ". This is probably caused by overflow, stopping original event; retrying with y=" + correctY + ".");
+ Logger.WARNING("You're trying to sleep at y=" + evt.y
+ + ". This is probably caused by overflow, stopping original event; retrying with y=" + correctY
+ + ".");
evt.result = EntityPlayer.EnumStatus.OTHER_PROBLEM;
- if (mSleepInBedAt != null) {
- try {
- mSleepInBedAt.invoke(evt.entityPlayer, evt.x, correctY, evt.z);
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- Logger.INFO("Encountered an error trying to sleep.");
- }
- } else {
- Logger.INFO("Method sleepInBedAt was not found in EntityPlayer (wrong MC and/or Forge version?), unable to fix");
+ try {
+ mSleepInBedAt.invoke(evt.entityPlayer, evt.x, correctY, evt.z);
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ 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");
}
}