diff options
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/ob')
-rw-r--r-- | src/Java/gtPlusPlus/xmod/ob/GliderHandler.java | 127 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/ob/HANDLER_OpenBlocks.java | 38 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/xmod/ob/SprinklerHandler.java | 66 |
3 files changed, 0 insertions, 231 deletions
diff --git a/src/Java/gtPlusPlus/xmod/ob/GliderHandler.java b/src/Java/gtPlusPlus/xmod/ob/GliderHandler.java deleted file mode 100644 index a190511b02..0000000000 --- a/src/Java/gtPlusPlus/xmod/ob/GliderHandler.java +++ /dev/null @@ -1,127 +0,0 @@ -package gtPlusPlus.xmod.ob; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; - -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -import net.minecraftforge.event.entity.player.PlayerInteractEvent; -import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; - -public class GliderHandler { - - private static final AutoMap<Integer> mDimensionalBlacklist = new AutoMap<Integer>(); - - @SubscribeEvent - public void onItemUsageEx(final PlayerInteractEvent event) { - if (event != null && event.entityPlayer != null) { - - if (event.action != Action.RIGHT_CLICK_BLOCK && event.action != Action.RIGHT_CLICK_AIR) { - Logger.WARNING("[OpenBlocks] Wrong type of PlayerInteractEvent, skipping."); - } - if (event.entityPlayer.worldObj.isRemote) { - return; - } - - ItemStack aItem = PlayerUtils.getItemStackInPlayersHand(event.entityPlayer); - if (ItemUtils.checkForInvalidItems(aItem)) { - Class aItemGliderClass = ReflectionUtils.getClass("openblocks.common.item.ItemHangGlider"); - if (aItemGliderClass.isInstance(aItem.getItem())) { - if (!canPlayerGlideInThisDimension(event.entityPlayer)){ - event.setCanceled(true); - PlayerUtils.messagePlayer(event.entityPlayer, "Glider is blacklisted in this dimension."); - Logger.WARNING("[OpenBlocks] "+event.entityPlayer.getCommandSenderName()+" tried to use glider in dimension "+event.entityPlayer.getEntityWorld().provider.dimensionId+"."); - } - else { - Logger.WARNING("[OpenBlocks] "+event.entityPlayer.getCommandSenderName()+" used glider in dimension "+event.entityPlayer.getEntityWorld().provider.dimensionId+"."); - } - } - else { - Logger.WARNING("[OpenBlocks] Item was not a glider."); - } - } - else { - Logger.WARNING("[OpenBlocks] Bad Item in player hand."); - } - } - else { - Logger.WARNING("[OpenBlocks] Bad event or player."); - } - - - } - - private static final boolean canPlayerGlideInThisDimension(EntityPlayer aPlayer) { - World aWorld = aPlayer.worldObj; - if (aWorld == null) { - return false; - } - else { - if (aWorld.provider == null) { - return false; - } - else { - int aDimID = aWorld.provider.dimensionId; - for (int i : mDimensionalBlacklist) { - if (i == aDimID) { - return false; - } - } - } - } - return true; - } - - static final void populateBlacklist() { - if (!mDimensionalBlacklist.isEmpty()) { - return; - } - File aBlacklist = gtPlusPlus.core.util.data.FileUtils.getFile("config/GTplusplus/", "GliderBlacklist", "cfg"); - List<String> lines = new ArrayList<String>(); - try { - lines = org.apache.commons.io.FileUtils.readLines(aBlacklist, "utf-8"); - } catch (IOException e) { - e.printStackTrace(); - } - if (lines.isEmpty()) { - FileWriter fw; - try { - String aInfoTip = "# Add one dimension ID per line. Lines with a # are comments and are ignored."; - fw = new FileWriter(aBlacklist); - fw.write(aInfoTip); - fw.close(); - lines.add(aInfoTip); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (!lines.isEmpty()) { - for (String s : lines) { - if (s != null && !s.equals("") && !s.contains("#")) { - s = StringUtils.remove(s, " "); - s = StringUtils.trim(s); - s = StringUtils.remove(s, ","); - Integer g = Integer.decode(s); - if (g != null) { - mDimensionalBlacklist.add(g); - Logger.INFO("[OpenBlocks] Added Dimension with ID '"+g+"' to Blacklist for Glider."); - } - } - } - } - } - - -} diff --git a/src/Java/gtPlusPlus/xmod/ob/HANDLER_OpenBlocks.java b/src/Java/gtPlusPlus/xmod/ob/HANDLER_OpenBlocks.java deleted file mode 100644 index c1b678f5ee..0000000000 --- a/src/Java/gtPlusPlus/xmod/ob/HANDLER_OpenBlocks.java +++ /dev/null @@ -1,38 +0,0 @@ -package gtPlusPlus.xmod.ob; - -import static gtPlusPlus.core.creative.AddToCreativeTab.tabMisc; - -import gtPlusPlus.core.item.ModItems; -import gtPlusPlus.core.item.base.BaseItemBurnable; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import gtPlusPlus.xmod.railcraft.utils.RailcraftUtils; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -public class HANDLER_OpenBlocks { - - public static void preInit() { - if (LoadedMods.OpenBlocks) { - - } - } - - public static void init() { - if (LoadedMods.OpenBlocks) { - GliderHandler.populateBlacklist(); - } - } - - public static void postInit() { - if (LoadedMods.OpenBlocks) { - Utils.registerEvent(new GliderHandler()); - } - } - -} diff --git a/src/Java/gtPlusPlus/xmod/ob/SprinklerHandler.java b/src/Java/gtPlusPlus/xmod/ob/SprinklerHandler.java deleted file mode 100644 index 85f8ded290..0000000000 --- a/src/Java/gtPlusPlus/xmod/ob/SprinklerHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -package gtPlusPlus.xmod.ob; - -import java.util.HashMap; - -import com.google.common.base.Objects; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.minecraft.ItemUtils; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -/** - * Wrapper Class to assist in handling the OB Sprinkler. - * @author Alkalus - * - */ -public class SprinklerHandler { - - - private static final HashMap<Integer, ItemStack> mValidFerts = new HashMap<Integer, ItemStack>(); - - /** - * @return - A valid {@link Map} of all Fertilizers for the OB Sprinkler. - */ - public static HashMap<Integer, ItemStack> getValidFerts() { - return mValidFerts; - } - - /** - * @param aFert - An {@link ItemStack} which is to be registered for OB Sprinklers. - */ - public static void registerSprinklerFertilizer(ItemStack aFert) { - int aHash = Objects.hashCode(aFert.getItem(), aFert.getItemDamage()); - if (!mValidFerts.containsKey(aHash)) { - Logger.INFO("Registering "+aFert.getDisplayName()+" as OB Sprinkler Fertilizer."); - mValidFerts.put(aHash, aFert.copy()); - } - } - - public static void registerModFerts() { - ItemStack f; - - f = new ItemStack(Items.dye, 1, 15); - SprinklerHandler.registerSprinklerFertilizer(f); - - if (LoadedMods.Forestry) { - f = ItemUtils.getCorrectStacktype("Forestry:fertilizerBio", 1); - if (f != null) { - registerSprinklerFertilizer(f); - } - f = ItemUtils.getCorrectStacktype("Forestry:fertilizerCompound", 1); - if (f != null) { - registerSprinklerFertilizer(f); - } - } - if (LoadedMods.IndustrialCraft2) { - f = ItemUtils.getCorrectStacktype("IC2:itemFertilizer", 1); - if (f != null) { - registerSprinklerFertilizer(f); - } - - } - } - -} |