aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/handler
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-09-07 16:36:25 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-09-07 16:36:25 +1000
commit221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch)
treed6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/core/handler
parent5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff)
downloadGT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz
GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2
GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/core/handler')
-rw-r--r--src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java155
-rw-r--r--src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java41
-rw-r--r--src/Java/gtPlusPlus/core/handler/CraftingManager.java17
-rw-r--r--src/Java/gtPlusPlus/core/handler/GuiHandler.java128
-rw-r--r--src/Java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java28
-rw-r--r--src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java32
-rw-r--r--src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java84
-rw-r--r--src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java71
-rw-r--r--src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java138
9 files changed, 694 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
new file mode 100644
index 0000000000..92003cbcad
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java
@@ -0,0 +1,155 @@
+package gtPlusPlus.core.handler;
+
+import static gtPlusPlus.core.lib.LoadedMods.Gregtech;
+import gregtech.api.util.GT_OreDictUnificator;
+import gtPlusPlus.core.common.compat.COMPAT_BigReactors;
+import gtPlusPlus.core.common.compat.COMPAT_CompactWindmills;
+import gtPlusPlus.core.common.compat.COMPAT_EnderIO;
+import gtPlusPlus.core.common.compat.COMPAT_ExtraUtils;
+import gtPlusPlus.core.common.compat.COMPAT_IC2;
+import gtPlusPlus.core.common.compat.COMPAT_MorePlanets;
+import gtPlusPlus.core.common.compat.COMPAT_PneumaticCraft;
+import gtPlusPlus.core.common.compat.COMPAT_RFTools;
+import gtPlusPlus.core.common.compat.COMPAT_SimplyJetpacks;
+import gtPlusPlus.core.common.compat.COMPAT_Thaumcraft;
+import gtPlusPlus.core.handler.Recipes.LateRegistrationHandler;
+import gtPlusPlus.core.handler.Recipes.RegistrationHandler;
+import gtPlusPlus.core.item.ModItems;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.lib.LoadedMods;
+import gtPlusPlus.core.recipe.RECIPES_GREGTECH;
+import gtPlusPlus.core.recipe.RECIPES_LaserEngraver;
+import gtPlusPlus.core.recipe.ShapedRecipeObject;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.item.UtilsItems;
+import gtPlusPlus.core.util.recipe.UtilsRecipe;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechDehydrator;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechEnergyBuffer;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialCentrifuge;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialCokeOven;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialElectrolyzer;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMacerator;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialMassFabricator;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialPlatePress;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIndustrialWiremill;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechIronBlastFurnace;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechPowerSubStation;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechRocketFuelGenerator;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSafeBlock;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSolarGenerators;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSteamCondenser;
+import gtPlusPlus.xmod.gregtech.registration.gregtech.GregtechSuperConductionPoint;
+
+import java.util.LinkedList;
+import java.util.Queue;
+
+import net.minecraft.item.ItemStack;
+
+public class COMPAT_HANDLER {
+
+ public static Queue<Object> RemoveRecipeQueue = new LinkedList<Object>();
+ public static Queue<ShapedRecipeObject> AddRecipeQueue = new LinkedList<ShapedRecipeObject>();
+ public static Boolean areInitItemsLoaded = false;
+
+
+ public static void registerMyModsOreDictEntries(){
+
+ Utils.LOG_INFO("Registering Materials with OreDict.");
+ //In-house
+
+ //tools
+ GT_OreDictUnificator.registerOre("craftingToolSandHammer", new ItemStack(ModItems.itemSandstoneHammer));
+ GT_OreDictUnificator.registerOre("ingotBloodSteel", new ItemStack(ModItems.itemIngotBloodSteel));
+ GT_OreDictUnificator.registerOre("ingotStaballoy", new ItemStack(ModItems.itemIngotStaballoy));
+
+ //Plates
+ GT_OreDictUnificator.registerOre("plateBloodSteel", new ItemStack(ModItems.itemPlateBloodSteel));
+ GT_OreDictUnificator.registerOre("plateStaballoy", new ItemStack(ModItems.itemPlateStaballoy));
+
+ //Blocks
+ //GT_OreDictUnificator.registerOre("blockStaballoy", new ItemStack(Item.getItemFromBlock(ModBlocks.blockStaballoy)));
+ //OreDictionary.registerOre("blockBloodSteel", new ItemStack(ModBlocks.blockBloodSteel));
+
+
+ for(int i=1; i<=10; i++){
+ GT_OreDictUnificator.registerOre("bufferCore_"+CORE.VOLTAGES[i-1], new ItemStack(UtilsItems.getItem("miscutils:item.itemBufferCore"+i)));
+ }
+ }
+
+ public static void registerGregtechMachines() {
+ if (Gregtech) {
+ new RECIPES_LaserEngraver();
+ GregtechEnergyBuffer.run();
+ GregtechSteamCondenser.run();
+ GregtechSafeBlock.run();
+ GregtechSuperConductionPoint.run();
+ GregtechIronBlastFurnace.run();
+ GregtechIndustrialCentrifuge.run();
+ GregtechIndustrialCokeOven.run();
+ GregtechIndustrialPlatePress.run();
+ GregtechRocketFuelGenerator.run();
+ GregtechIndustrialElectrolyzer.run();
+ GregtechIndustrialMacerator.run();
+ GregtechIndustrialWiremill.run();
+ GregtechIndustrialMassFabricator.run();
+ //GregtechIndustrialSinter.run();
+ GregtechSolarGenerators.run();
+ GregtechPowerSubStation.run();
+ GregtechDehydrator.run();
+ }
+
+ }
+
+ //InterMod
+ public static void intermodOreDictionarySupport(){
+
+ if (LoadedMods.Big_Reactors){
+ COMPAT_BigReactors.OreDict();
+ }
+ if (LoadedMods.EnderIO){
+ COMPAT_EnderIO.OreDict();
+ }
+ if (LoadedMods.MorePlanets){
+ COMPAT_MorePlanets.OreDict();
+ }
+ if (LoadedMods.Simply_Jetpacks){
+ COMPAT_SimplyJetpacks.OreDict();
+ }
+ if (LoadedMods.RFTools){
+ COMPAT_RFTools.OreDict();
+ }
+ if (LoadedMods.Thaumcraft){
+ COMPAT_Thaumcraft.OreDict();
+ }
+ if (LoadedMods.Extra_Utils){
+ COMPAT_ExtraUtils.OreDict();
+ }
+ if (LoadedMods.PneumaticCraft){
+ COMPAT_PneumaticCraft.OreDict();
+ }
+ if (LoadedMods.CompactWindmills){
+ COMPAT_CompactWindmills.OreDict();
+ }
+ if (LoadedMods.IndustrialCraft2){
+ COMPAT_IC2.OreDict();
+ }
+ }
+
+ public static void RemoveRecipesFromOtherMods(){
+ //Removal of Recipes
+ for(Object item : RemoveRecipeQueue){
+ UtilsRecipe.removeCraftingRecipe(item);
+ }
+ }
+
+ public static void InitialiseHandlerThenAddRecipes(){
+ RegistrationHandler.run();
+ }
+ public static void InitialiseLateHandlerThenAddRecipes(){
+ LateRegistrationHandler.run();
+ }
+
+ public static void startLoadingGregAPIBasedRecipes(){
+ RECIPES_GREGTECH.run();
+ }
+}
diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java
new file mode 100644
index 0000000000..97b7369134
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/COMPAT_IntermodStaging.java
@@ -0,0 +1,41 @@
+package gtPlusPlus.core.handler;
+
+import gtPlusPlus.xmod.forestry.HANDLER_FR;
+import gtPlusPlus.xmod.gregtech.HANDLER_GT;
+import gtPlusPlus.xmod.growthcraft.HANDLER_GC;
+import gtPlusPlus.xmod.ic2.HANDLER_IC2;
+import gtPlusPlus.xmod.psychedelicraft.HANDLER_Psych;
+import gtPlusPlus.xmod.thermalfoundation.HANDLER_TF;
+
+public class COMPAT_IntermodStaging {
+
+ public static void preInit(){
+ HANDLER_GT.preInit();
+ HANDLER_GC.preInit();
+ HANDLER_TF.preInit();
+ HANDLER_FR.preInit();
+ HANDLER_Psych.preInit();
+ HANDLER_IC2.preInit();
+
+ }
+
+ public static void init(){
+ HANDLER_GT.init();
+ HANDLER_GC.init();
+ HANDLER_TF.init();
+ HANDLER_FR.Init();
+ HANDLER_Psych.init();
+ HANDLER_IC2.init();
+ }
+
+ public static void postInit(){
+ HANDLER_GT.postInit();
+ HANDLER_GC.postInit();
+ HANDLER_TF.postInit();
+ HANDLER_FR.postInit();
+ HANDLER_Psych.postInit();
+ HANDLER_IC2.postInit();
+ }
+
+
+}
diff --git a/src/Java/gtPlusPlus/core/handler/CraftingManager.java b/src/Java/gtPlusPlus/core/handler/CraftingManager.java
new file mode 100644
index 0000000000..bd0f114b1a
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/CraftingManager.java
@@ -0,0 +1,17 @@
+package gtPlusPlus.core.handler;
+
+public class CraftingManager {
+
+ public static void mainRegistry() {
+ addCraftingRecipies();
+ addSmeltingRecipies();
+ }
+
+ public static void addCraftingRecipies() {
+
+ }
+
+ public static void addSmeltingRecipies() {
+
+ }
+}
diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java
new file mode 100644
index 0000000000..7c9c7a7625
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java
@@ -0,0 +1,128 @@
+package gtPlusPlus.core.handler;
+
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.core.container.Container_BackpackBase;
+import gtPlusPlus.core.gui.beta.Gui_ID_Registry;
+import gtPlusPlus.core.gui.beta.MU_GuiId;
+import gtPlusPlus.core.gui.item.GuiBaseBackpack;
+import gtPlusPlus.core.interfaces.IGuiManager;
+import gtPlusPlus.core.inventories.BaseInventoryBackpack;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.xmod.forestry.bees.alveary.TileAlvearyFrameHousing;
+import gtPlusPlus.xmod.forestry.bees.alveary.gui.CONTAINER_FrameHousing;
+import gtPlusPlus.xmod.forestry.bees.alveary.gui.GUI_FrameHousing;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.world.World;
+import cpw.mods.fml.common.network.IGuiHandler;
+import cpw.mods.fml.common.network.NetworkRegistry;
+
+public class GuiHandler implements IGuiHandler {
+
+ public static final int GUI1 = 0; //Frame Alveary
+ public static final int GUI2 = 1; //RTG
+ public static final int GUI3 = 2; //BackpackHandler
+ public static final int GUI4 = 3; //
+ public static final int GUI5 = 4; //
+ public static final int GUI6 = 5; //
+ public static final int GUI7 = 6; //
+ public static final int GUI8 = 7; //
+
+
+
+ public static void init(){
+
+ Utils.LOG_INFO("Registering GUIs.");
+ NetworkRegistry.INSTANCE.registerGuiHandler(GTplusplus.instance, new GuiHandler());
+ //Register GuiHandler
+ //NetworkRegistry.INSTANCE.registerGuiHandler(GTplusplus.instance, new GuiHandler());
+ }
+
+
+ @Override //ContainerModTileEntity
+ public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
+ TileEntity te = world.getTileEntity(x, y, z);
+
+ if (te != null){
+ if (ID == GUI1){
+ if (CORE.configSwitches.enableCustomAlvearyBlocks){
+ return new CONTAINER_FrameHousing((TileAlvearyFrameHousing)te, player);
+ }
+ }
+ else if (ID == GUI2){
+ //return new CONTAINER_RTG(player, (TileEntityRTG)te);
+ }
+
+
+ }
+
+ if (ID == GUI3)
+ {
+ // Use the player's held item to create the inventory
+ return new Container_BackpackBase(player, player.inventory, new BaseInventoryBackpack(player.getHeldItem()));
+ }
+ return null;
+ }
+
+ @Override //GuiModTileEntity
+ public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
+ Utils.LOG_WARNING("getClientGuiElement Called by: "+player+", in world: "+player.dimension+" at x:"+x+", y:"+y+", z:"+z+".");
+ TileEntity te = world.getTileEntity(x, y, z);
+ if (te != null){
+ if (ID == GUI1){
+ if (CORE.configSwitches.enableCustomAlvearyBlocks){
+ Utils.LOG_WARNING("Opening Gui with Id: "+ID+" Alveary Frame Housing");
+ return new GUI_FrameHousing((TileAlvearyFrameHousing) te, player);
+ }
+ }
+ else if (ID == GUI2){
+ Utils.LOG_WARNING("Opening Gui with Id: "+ID+" RTG");
+ //return new GUI_RTG((TileEntityRTG) te.);
+ }
+ }
+
+ if (ID == GUI3)
+ {
+ // We have to cast the new container as our custom class
+ // and pass in currently held item for the inventory
+ return new GuiBaseBackpack((Container_BackpackBase) new Container_BackpackBase(player, player.inventory, new BaseInventoryBackpack(player.getHeldItem())));
+ }
+
+ return null;
+ }
+
+
+
+ //New Methods
+ public static void openGui(EntityPlayer entityplayer, IGuiManager guiHandler)
+ {
+ openGui(entityplayer, guiHandler, (short)0);
+ }
+
+ public static void openGui(EntityPlayer entityplayer, IGuiManager guiHandler, short data)
+ {
+ int guiData = encodeGuiData(guiHandler, data);
+ ChunkCoordinates coordinates = guiHandler.getCoordinates();
+ entityplayer.openGui(GTplusplus.instance, guiData, entityplayer.worldObj, coordinates.posX, coordinates.posY, coordinates.posZ);
+ }
+
+ private static int encodeGuiData(IGuiManager guiHandler, short data)
+ {
+ MU_GuiId guiId = Gui_ID_Registry.getGuiIdForGuiHandler(guiHandler);
+ return data << 16 | guiId.getId();
+ }
+
+ private static MU_GuiId decodeGuiID(int guiData)
+ {
+ int guiId = guiData & 0xFF;
+ return Gui_ID_Registry.getGuiId(guiId);
+ }
+
+ private static short decodeGuiData(int guiId)
+ {
+ return (short)(guiId >> 16);
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java b/src/Java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java
new file mode 100644
index 0000000000..7d739bdca3
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/Recipes/LateRegistrationHandler.java
@@ -0,0 +1,28 @@
+package gtPlusPlus.core.handler.Recipes;
+
+import gtPlusPlus.core.handler.COMPAT_HANDLER;
+import gtPlusPlus.core.recipe.ShapedRecipeObject;
+import gtPlusPlus.core.util.Utils;
+
+public class LateRegistrationHandler {
+
+ public static int recipesSuccess = 0;
+ public static int recipesFailed = 0;
+
+ public static void run(){
+ init();
+ }
+
+ private final static void init(){
+ for(ShapedRecipeObject item : COMPAT_HANDLER.AddRecipeQueue){
+ item.buildRecipe();
+ }
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ Utils.LOG_INFO(e.toString());
+ }
+ Utils.LOG_INFO("Late Recipes Loaded: "+recipesSuccess+" Failed: "+recipesFailed);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java b/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java
new file mode 100644
index 0000000000..affb56566d
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/Recipes/RegistrationHandler.java
@@ -0,0 +1,32 @@
+package gtPlusPlus.core.handler.Recipes;
+
+import gtPlusPlus.core.handler.COMPAT_HANDLER;
+import gtPlusPlus.core.recipe.RECIPES_MachineComponents;
+import gtPlusPlus.core.recipe.RECIPES_Machines;
+import gtPlusPlus.core.recipe.RECIPES_Shapeless;
+import gtPlusPlus.core.recipe.RECIPES_Tools;
+import gtPlusPlus.core.recipe.RECIPE_Batteries;
+import gtPlusPlus.core.util.Utils;
+
+public class RegistrationHandler {
+
+ public static int recipesSuccess = 0;
+ public static int recipesFailed = 0;
+
+ public static void run(){
+ init();
+ }
+
+ private final static void init(){
+ RECIPES_Tools.RECIPES_LOAD();
+ RECIPES_Machines.RECIPES_LOAD();
+ RECIPES_Shapeless.RECIPES_LOAD();
+ RECIPES_MachineComponents.RECIPES_LOAD();
+ RECIPE_Batteries.RECIPES_LOAD();
+ //RECIPES_MTWRAPPER.run();
+ Utils.LOG_INFO("Loaded: "+recipesSuccess+" Failed: "+recipesFailed);
+ COMPAT_HANDLER.areInitItemsLoaded = true;
+ //Utils.LOG_INFO("MT Loaded: "+RECIPES_MTWRAPPER.MT_RECIPES_LOADED+" MT Failed: "+RECIPES_MTWRAPPER.MT_RECIPES_FAILED);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java
new file mode 100644
index 0000000000..9cf0cb8bb7
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java
@@ -0,0 +1,84 @@
+package gtPlusPlus.core.handler.events;
+
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.player.PlayerCache;
+
+import java.util.UUID;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.entity.player.EntityPlayerMP;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.common.gameevent.PlayerEvent;
+
+public class LoginEventHandler {
+
+ public String localPlayersName;
+ public UUID localPlayersUUID;
+ private EntityPlayer localPlayerRef;
+
+ @SubscribeEvent
+ public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) {
+
+ this.localPlayerRef = event.player;
+ this.localPlayersName = event.player.getDisplayName();
+ this.localPlayersUUID = event.player.getUniqueID();
+
+ try {
+
+
+ if (localPlayerRef instanceof EntityPlayerMP && localPlayerRef != null){
+
+ //Populates player cache
+ if (!localPlayerRef.worldObj.isRemote){
+ PlayerCache.appendParamChanges(localPlayersName, localPlayersUUID.toString());
+ }
+
+
+ /*if (localPlayerRef.getCommandSenderName().toLowerCase().equalsIgnoreCase("ImQ009") || localPlayerRef.getCommandSenderName().toLowerCase().contains("player")){
+ Utils.LOG_INFO("Spawning a new Santa Thread.");
+ Thread t = new Thread() {
+ UUID threadHandlerIDthing = localPlayersUUID;
+ @Override
+ public void run() {
+ while(true && Minecraft.getMinecraft().getIntegratedServer() != null) {
+ try {
+ if(localPlayerRef == null){
+ localPlayerRef = Utils.getPlayerOnServerFromUUID(threadHandlerIDthing);
+ }
+
+
+ //ImQ009 is a legend.
+ if (localPlayerRef.getCommandSenderName().toLowerCase().equalsIgnoreCase("ImQ009")){
+ Utils.messagePlayer(localPlayerRef, "Enjoy some complimentary Raisin Bread.");
+ localPlayerRef.inventory.addItemStackToInventory(UtilsItems.getSimpleStack(ModItems.itemIngotRaisinBread, MathUtils.randInt(1, 5)));
+ }
+
+
+ if (localPlayerRef.getCommandSenderName().toLowerCase().contains("player")){
+ Utils.messagePlayer(localPlayerRef, "Enjoy some complimentary Raisin Bread.");
+ localPlayerRef.inventory.addItemStackToInventory(UtilsItems.getSimpleStack(ModItems.itemIngotRaisinBread, MathUtils.randInt(1, 5)));
+ }
+ Thread.sleep(1000*60*MathUtils.randInt(15, 90));
+ } catch (InterruptedException ie) {
+ Utils.LOG_INFO("Santa Mode Disabled.");
+ }
+ }
+
+ Utils.LOG_INFO("Thread Stopped. Handler Closed.");
+
+ }
+ };
+ //t.start();
+
+
+ }*/
+
+
+ }
+ } catch (Throwable errr){
+ Utils.LOG_INFO("Login Handler encountered an error.");
+
+ }
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java
new file mode 100644
index 0000000000..a7c689a79a
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java
@@ -0,0 +1,71 @@
+package gtPlusPlus.core.handler.events;
+
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.metatileentity.BaseMetaPipeEntity;
+import gregtech.api.metatileentity.BaseMetaTileEntity;
+import gregtech.api.metatileentity.BaseTileEntity;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase;
+
+import java.util.UUID;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraftforge.event.entity.player.PlayerInteractEvent;
+import net.minecraftforge.event.world.BlockEvent.BreakEvent;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+
+public class PickaxeBlockBreakEventHandler {
+ @SubscribeEvent
+ public void onBreakBlock(BreakEvent event) {
+ try{
+ TileEntity entity = event.world.getTileEntity(event.x, event.y, event.z);
+ if (entity != null && !entity.equals(null)){
+ EntityPlayer playerInternal = event.getPlayer();
+ Utils.LOG_WARNING(entity.getClass().getSimpleName());
+ if (entity.getClass().getSimpleName().equals("")){
+
+ }
+ if (entity instanceof BaseTileEntity && !(entity instanceof BaseMetaPipeEntity)){
+ IMetaTileEntity X = ((BaseMetaTileEntity)entity).getMetaTileEntity();
+ Block ThisBlock = X.getBaseMetaTileEntity().getBlock(event.x, event.y, event.z);
+ if (X instanceof GregtechMetaSafeBlockBase){
+
+ UUID ownerUUID = ((GregtechMetaSafeBlockBase)X).ownerUUID;
+ UUID accessorUUID = playerInternal.getUniqueID();
+ Utils.LOG_WARNING("Owner UUID: "+ownerUUID);
+ Utils.LOG_WARNING("Accessor UUID: "+accessorUUID);
+
+ if (((GregtechMetaSafeBlockBase)X).bUnbreakable){
+
+ Utils.LOG_INFO("UUID info. Accessor: "+accessorUUID + " | Owner: "+ownerUUID);
+
+ if (accessorUUID == ownerUUID){
+ Utils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed.");
+ event.setCanceled(false);
+ }
+ else {
+ event.setCanceled(true);
+ Utils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed.");
+ }
+ //
+ }
+ }
+ }
+ }
+
+ }
+ catch (NullPointerException e) {
+ System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "+e.getCause());
+ }
+ }
+
+
+ @SubscribeEvent
+ public void onPlayerInteraction(PlayerInteractEvent aEvent) {
+ if (aEvent.entityPlayer != null && aEvent.entityPlayer.worldObj != null && aEvent.action != null && aEvent.world.provider != null && !aEvent.entityPlayer.worldObj.isRemote && aEvent.action != null && aEvent.action != PlayerInteractEvent.Action.RIGHT_CLICK_AIR) {
+ //Utils.LOG_ERROR("Test");
+ }
+ }
+}
diff --git a/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java b/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java
new file mode 100644
index 0000000000..3e126d4463
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java
@@ -0,0 +1,138 @@
+package gtPlusPlus.core.handler.events;
+
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.metatileentity.BaseMetaPipeEntity;
+import gregtech.api.metatileentity.BaseMetaTileEntity;
+import gregtech.api.metatileentity.BaseTileEntity;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GregtechMetaSafeBlock;
+import net.minecraft.block.Block;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+
+public class UnbreakableBlockManager{
+
+ private static boolean hasRun = false;
+
+ public final BaseMetaTileEntity getmTileEntity() {
+ return mTileEntity;
+ }
+
+
+ public final void setmTileEntity(BaseMetaTileEntity mTileEntity/*, EntityPlayer aPlayer*/) {
+ UnbreakableBlockManager.mTileEntity = mTileEntity;
+ if (!hasRun){
+ hasRun = true;
+ makeIndestructible(/*aPlayer*/);
+ }
+ else {
+ Utils.LOG_WARNING("Why do you run twice?");
+ }
+ }
+
+
+ //BaseMetaTileEntity
+ //GregtechMetaSafeBlock
+ private static BaseMetaTileEntity mTileEntity = null;
+
+
+ private void makeIndestructible(/*EntityPlayer aPlayer*/){
+
+
+ Utils.LOG_WARNING("Initializing the code to set this TE to -1 hardness and make it indestructible.");
+ int X = ((BaseMetaTileEntity)mTileEntity).xCoord; //(GregtechMetaSafeBlock) this.mTileEntity.getXCoord();
+ int Y = ((BaseMetaTileEntity)mTileEntity).yCoord;
+ int Z = ((BaseMetaTileEntity)mTileEntity).zCoord;
+ Utils.LOG_WARNING("Grabbing TileEntity @ [x,y,z] |"+X+"|"+Y+"|"+Z+"|");
+
+
+
+ try{
+ GregtechMetaSafeBlock MetaSafeBlock = ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity());
+ TileEntity BaseMetaTileEntity = ((BaseMetaTileEntity)mTileEntity).getTileEntity(X, Y, Z);
+ //MetaSafeBlockBase.
+ World TE_WORLD = MetaSafeBlock.getBaseMetaTileEntity().getWorld();
+ Utils.LOG_WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+ TileEntity entity = BaseMetaTileEntity;
+ innerInvincible(MetaSafeBlock, entity, TE_WORLD, /*aPlayer,*/ X, Y, Z);
+ }
+ catch (NullPointerException e) {
+ System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: ");
+ e.printStackTrace();
+ }
+ }
+
+
+ private static void innerInvincible(GregtechMetaSafeBlock MetaSafeBlock, TileEntity entity, World TE_WORLD, /*EntityPlayer aPlayer,*/ int X, int Y, int Z){
+ if (entity != null && !entity.equals(null)){
+ Utils.LOG_WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+ Utils.LOG_WARNING("Grabbed TE: "+entity.toString());
+
+
+
+
+ if (entity instanceof BaseTileEntity && !(entity instanceof BaseMetaPipeEntity)){
+ IMetaTileEntity I = ((BaseMetaTileEntity)entity).getMetaTileEntity();
+ Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+ Utils.LOG_WARNING("I Details: "+I.getMetaName()+" | "+I.getTileEntityBaseType()+" | "+I.toString());
+
+
+
+
+
+ if (I instanceof GregtechMetaSafeBlock){
+ Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+
+ Block ThisBlock = I.getBaseMetaTileEntity().getBlock(X, Y, Z);
+ Utils.LOG_WARNING("Block Details: "+ThisBlock.toString());
+
+
+ if (((GregtechMetaSafeBlock)I).bUnbreakable){
+ ThisBlock.setHardness(Integer.MAX_VALUE);
+ //ThisBlock.setResistance(18000000.0F);
+ ThisBlock.setResistance(-1);
+ ThisBlock.setBlockUnbreakable();
+ Utils.LOG_WARNING("Changing State of Flag. Old Value="+MetaSafeBlock.bUnbreakable+" Expected Value=true");
+ MetaSafeBlock.bUnbreakable = true;
+ //entity.markDirty();
+ Utils.LOG_WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+ Utils.LOG_ERROR("New Indestructible Flag enabled.");
+ //GT_Utility.sendChatToPlayer(aPlayer, "Block is now unbreakable.");
+ }
+
+
+
+
+ else {
+ ThisBlock.setHardness(1);
+ ThisBlock.setResistance(1.0F);
+ Utils.LOG_WARNING("Changing State of Flag. Old Value="+MetaSafeBlock.bUnbreakable+" Expected Value=false");
+ MetaSafeBlock.bUnbreakable = false;
+ //entity.markDirty();
+ Utils.LOG_WARNING("Checking new State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+ Utils.LOG_ERROR("New Indestructible Flag disabled.");
+ //GT_Utility.sendChatToPlayer(aPlayer, "Block is now breakable.");
+ }
+
+ //entity.markDirty();
+
+ Utils.LOG_WARNING("Block Hardness: "+ThisBlock.getBlockHardness(TE_WORLD, X, Y, Z));
+ Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+ hasRun = false;
+
+ }
+ else {
+ Utils.LOG_WARNING("I is not an instanceof MetaSafeBlockBase");
+ Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+ }
+ } else {
+ Utils.LOG_WARNING("TE is not an instanceof BaseTileEntity or may be a pipe.");
+ Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+ }
+ }else {
+ Utils.LOG_WARNING("Did not grab a TE instance to make a block instance from.");
+ Utils.LOG_WARNING("Checking State of Flag[nUnbreakable]. Value="+MetaSafeBlock.bUnbreakable);
+ }
+ }
+
+}