aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Java/gtPlusPlus/core/handler/OldCircuitHandler.java48
-rw-r--r--src/Java/gtPlusPlus/plugin/fixes/interfaces/IBugFix.java7
-rw-r--r--src/Java/gtPlusPlus/plugin/fixes/vanilla/Core_VanillaFixes.java2
-rw-r--r--src/Java/gtPlusPlus/plugin/fixes/vanilla/VanillaBedHeightFix.java59
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java54
5 files changed, 97 insertions, 73 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/OldCircuitHandler.java b/src/Java/gtPlusPlus/core/handler/OldCircuitHandler.java
index e5cd4a9bb9..e20e13a337 100644
--- a/src/Java/gtPlusPlus/core/handler/OldCircuitHandler.java
+++ b/src/Java/gtPlusPlus/core/handler/OldCircuitHandler.java
@@ -25,34 +25,42 @@ public class OldCircuitHandler {
removeCircuitRecipeMap(); //Bye shitty recipes.
}
}
-
+
public static void init(){
-
+
}
-
+
public static void postInit(){
- RECIPES_Old_Circuits.handleCircuits();
- new RECIPES_Old_Circuits();
+ if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){
+ RECIPES_Old_Circuits.handleCircuits();
+ new RECIPES_Old_Circuits();
+ }
}
-
+
public static boolean addCircuitItems() {
- return MetaGeneratedGregtechItems.INSTANCE.registerOldCircuits();
+ if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){
+ return MetaGeneratedGregtechItems.INSTANCE.registerOldCircuits();
+ }
+ return false;
}
private static boolean removeCircuitRecipeMap(){
- try {
- Logger.INFO("[Old Feature - Circuits] Trying to override the Circuit Assembler Recipe map, so that no recipes for new circuits get added.");
- ReflectionUtils.setFinalStatic(GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes"), new EmptyRecipeMap(new HashSet<GT_Recipe>(0), "gt.recipe.removed", "Removed", null, GT_Values.RES_PATH_GUI + "basicmachines/Default", 0, 0, 0, 0, 0, GT_Values.E, 0, GT_Values.E, true, false));
- Field jaffar = GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes");
- FieldUtils.removeFinalModifier(jaffar, true);
- jaffar.set(null, new EmptyRecipeMap(new HashSet<GT_Recipe>(0), "gt.recipe.removed", "Removed", null, GT_Values.RES_PATH_GUI + "basicmachines/Default", 0, 0, 0, 0, 0, GT_Values.E, 0, GT_Values.E, true, false));
- Logger.INFO("[Old Feature - Circuits] Successfully replaced circuit assembler recipe map with one that cannot hold recipes.");
- }
- catch (Exception e) {
- Logger.INFO("[Old Feature - Circuits] Failed removing circuit assembler recipe map.");
- return false;
+ if (enableOldGTcircuits && CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && !CORE.GTNH){
+ try {
+ Logger.INFO("[Old Feature - Circuits] Trying to override the Circuit Assembler Recipe map, so that no recipes for new circuits get added.");
+ ReflectionUtils.setFinalStatic(GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes"), new EmptyRecipeMap(new HashSet<GT_Recipe>(0), "gt.recipe.removed", "Removed", null, GT_Values.RES_PATH_GUI + "basicmachines/Default", 0, 0, 0, 0, 0, GT_Values.E, 0, GT_Values.E, true, false));
+ Field jaffar = GT_Recipe_Map.class.getDeclaredField("sCircuitAssemblerRecipes");
+ FieldUtils.removeFinalModifier(jaffar, true);
+ jaffar.set(null, new EmptyRecipeMap(new HashSet<GT_Recipe>(0), "gt.recipe.removed", "Removed", null, GT_Values.RES_PATH_GUI + "basicmachines/Default", 0, 0, 0, 0, 0, GT_Values.E, 0, GT_Values.E, true, false));
+ Logger.INFO("[Old Feature - Circuits] Successfully replaced circuit assembler recipe map with one that cannot hold recipes.");
+ }
+ catch (Exception e) {
+ Logger.INFO("[Old Feature - Circuits] Failed removing circuit assembler recipe map.");
+ return false;
+ }
+ return true;
}
- return true;
+ return false;
}
-
+
}
diff --git a/src/Java/gtPlusPlus/plugin/fixes/interfaces/IBugFix.java b/src/Java/gtPlusPlus/plugin/fixes/interfaces/IBugFix.java
new file mode 100644
index 0000000000..d67ff24d7b
--- /dev/null
+++ b/src/Java/gtPlusPlus/plugin/fixes/interfaces/IBugFix.java
@@ -0,0 +1,7 @@
+package gtPlusPlus.plugin.fixes.interfaces;
+
+public interface IBugFix {
+
+ public boolean isFixValid();
+
+}
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");
}
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java
index 00511d4c8b..1b86a975e6 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java
@@ -43,8 +43,9 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 {
public void generateMetaItems() {
int tLastID = 0;
+ registerCustomCircuits();
OldCircuitHandler.addCircuitItems();
-
+
if (!CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){
Logger.INFO("Gregtech 5.09 not found, using fallback components. (I like how I have to add compat to something I added first and had stolen.)");
GregtechItemList.Electric_Pump_LuV.set(this.addItem(tLastID = 0, "Electric Pump (LuV)", "163920 L/sec (as Cover)", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 1L), getTcAspectStack(TC_Aspects.MACHINA, 1L), getTcAspectStack(TC_Aspects.ITER, 1L), getTcAspectStack(TC_Aspects.AQUA, 1L)}));
@@ -144,36 +145,13 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 {
registerComponents_MAX();
}
- if (!CORE.GTNH){
- GregtechItemList.Circuit_IV.set(this.addItem(tLastID = 704, "Symbiotic Circuit (IV)", "A Symbiotic Data Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Symbiotic)}));
- GregtechItemList.Circuit_LuV.set(this.addItem(tLastID = 705, "Neutronic Circuit (LuV)", "A Neutron Particle Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Neutronic)}));
- GregtechItemList.Circuit_ZPM.set(this.addItem(tLastID = 706, "Quantum Circuit (ZPM)", "A Singlularity Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Quantum)}));
- GregtechItemList.Circuit_Board_IV.set(this.addItem(tLastID = 710, "IV Circuit Board", "An IV Voltage Rated Circuit Board", new Object[0]));
- GregtechItemList.Circuit_Board_LuV.set(this.addItem(tLastID = 711, "LuV Circuit Board", "An LuV Voltage Rated Circuit Board", new Object[0]));
- GregtechItemList.Circuit_Board_ZPM.set(this.addItem(tLastID = 712, "ZPM Processor Board", "A ZPM Voltage Rated Processor Board", new Object[0]));
- GregtechItemList.Circuit_Parts_Crystal_Chip_IV.set(this.addItem(tLastID = 713, "(IV) Energized Crystal Chip", "Needed for Circuits", new Object[0]));
- GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.set(this.addItem(tLastID = 714, "(LuV) Neutron based Microchip", "Needed for Circuits", new Object[0]));
- GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.set(this.addItem(tLastID = 715, "(ZPM) Quantum Chip", "Needed for Circuits", new Object[0]));
- GregtechItemList.Circuit_Parts_IV.set(this.addItem(tLastID = 716, "(IV) Energized Circuit Parts", "Circuit Parts", new Object[0]));
- GregtechItemList.Circuit_Parts_LuV.set(this.addItem(tLastID = 717, "(LuV) Neutron-based Circuit Parts", "Circuit Parts", new Object[0]));
- GregtechItemList.Circuit_Parts_ZPM.set(this.addItem(tLastID = 718, "(ZPM) Quantum Circuit Parts", "Circuit Parts", new Object[0]));
- GregtechItemList.Circuit_Parts_Wiring_IV.set(this.addItem(tLastID = 719, "Etched IV Voltage Wiring", "Part of Circuit Boards", new Object[0]));
- GregtechItemList.Circuit_Parts_Wiring_LuV.set(this.addItem(tLastID = 720, "Etched LuV Voltage Wiring", "Part of Circuit Boards", new Object[0]));
- GregtechItemList.Circuit_Parts_Wiring_ZPM.set(this.addItem(tLastID = 721, "Etched ZPM Voltage Wiring", "Part of Circuit Boards", new Object[0]));
-
- if (CORE.ConfigSwitches.enableCustomCircuits){
- ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_IV.get(1), "circuitSuperconductor");
- ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_LuV.get(1), "circuitInfinite");
- }
- }
-
//Extruder Shape
GregtechItemList.Shape_Extruder_WindmillShaft.set(this.addItem(tLastID = 40, "Extruder Shape (Shaft)", "Extruder Shape for making Windmill Shafts", new Object[0]));
//GTNH Already adds this.
- if (!CORE.GTNH)
+ if (!CORE.GTNH) {
GregtechItemList.Shape_Extruder_SmallGear.set(this.addItem(221, "Extruder Shape (Small Gear)", "Extruder Shape for making small gears", new Object[0]));
-
+ }
//Batteries
GregtechItemList.Battery_RE_EV_Sodium.set(this.addItem(tLastID = 50, "Quad Cell Sodium Battery", "Reusable", new Object[]{getTcAspectStack(TC_Aspects.ELECTRUM, 2L), getTcAspectStack(TC_Aspects.METALLUM, 2L), getTcAspectStack(TC_Aspects.POTENTIA, 2L)}));
@@ -355,4 +333,28 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 {
return true;
}
+
+ public boolean registerCustomCircuits() {
+ if (CORE.ConfigSwitches.enableCustomCircuits){
+ GregtechItemList.Circuit_IV.set(this.addItem(704, "Symbiotic Circuit (IV)", "A Symbiotic Data Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Symbiotic)}));
+ GregtechItemList.Circuit_LuV.set(this.addItem(705, "Neutronic Circuit (LuV)", "A Neutron Particle Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Neutronic)}));
+ GregtechItemList.Circuit_ZPM.set(this.addItem(706, "Quantum Circuit (ZPM)", "A Singlularity Processor", new Object[]{GregtechOrePrefixes.circuit.get(GT_Materials.Quantum)}));
+ GregtechItemList.Circuit_Board_IV.set(this.addItem(710, "IV Circuit Board", "An IV Voltage Rated Circuit Board", new Object[0]));
+ GregtechItemList.Circuit_Board_LuV.set(this.addItem(711, "LuV Circuit Board", "An LuV Voltage Rated Circuit Board", new Object[0]));
+ GregtechItemList.Circuit_Board_ZPM.set(this.addItem(712, "ZPM Processor Board", "A ZPM Voltage Rated Processor Board", new Object[0]));
+ GregtechItemList.Circuit_Parts_Crystal_Chip_IV.set(this.addItem(713, "(IV) Energized Crystal Chip", "Needed for Circuits", new Object[0]));
+ GregtechItemList.Circuit_Parts_Crystal_Chip_LuV.set(this.addItem(714, "(LuV) Neutron based Microchip", "Needed for Circuits", new Object[0]));
+ GregtechItemList.Circuit_Parts_Crystal_Chip_ZPM.set(this.addItem(715, "(ZPM) Quantum Chip", "Needed for Circuits", new Object[0]));
+ GregtechItemList.Circuit_Parts_IV.set(this.addItem(716, "(IV) Energized Circuit Parts", "Circuit Parts", new Object[0]));
+ GregtechItemList.Circuit_Parts_LuV.set(this.addItem(717, "(LuV) Neutron-based Circuit Parts", "Circuit Parts", new Object[0]));
+ GregtechItemList.Circuit_Parts_ZPM.set(this.addItem(718, "(ZPM) Quantum Circuit Parts", "Circuit Parts", new Object[0]));
+ GregtechItemList.Circuit_Parts_Wiring_IV.set(this.addItem(719, "Etched IV Voltage Wiring", "Part of Circuit Boards", new Object[0]));
+ GregtechItemList.Circuit_Parts_Wiring_LuV.set(this.addItem(720, "Etched LuV Voltage Wiring", "Part of Circuit Boards", new Object[0]));
+ GregtechItemList.Circuit_Parts_Wiring_ZPM.set(this.addItem(721, "Etched ZPM Voltage Wiring", "Part of Circuit Boards", new Object[0]));
+ ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_IV.get(1), "circuitSuperconductor");
+ ItemUtils.addItemToOreDictionary(GregtechItemList.Circuit_LuV.get(1), "circuitInfinite");
+ return true;
+ }
+ return false;
+ }
}