Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 2 additions & 31 deletions src/main/java/com/darkona/adventurebackpack/AdventureBackpack.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.darkona.adventurebackpack;

import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
Expand All @@ -29,9 +26,9 @@
import com.darkona.adventurebackpack.init.ModWorldGen;
import com.darkona.adventurebackpack.proxy.IProxy;
import com.darkona.adventurebackpack.reference.GeneralReference;
import com.darkona.adventurebackpack.reference.LoadedMods;
import com.darkona.adventurebackpack.reference.ModInfo;
import com.darkona.adventurebackpack.reference.WailaTileAdventureBackpack;
import com.darkona.adventurebackpack.util.LogHelper;

/**
* Created on 10/10/2014
Expand Down Expand Up @@ -88,37 +85,11 @@ public void init(FMLInitializationEvent event)
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event)
{
if ((Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"))
{
ConfigHandler.IS_DEVENV = true;
LogHelper.info("Dev environment detected. All hail the creator");
}

ConfigHandler.IS_BUILDCRAFT = registerMod("BuildCraft|Core");
ConfigHandler.IS_ENDERIO = registerMod("EnderIO");
ConfigHandler.IS_GREGTECH = registerMod("gregtech");
ConfigHandler.IS_TCONSTRUCT = registerMod("TConstruct");
ConfigHandler.IS_THAUMCRAFT = registerMod("Thaumcraft");

LoadedMods.init();
GeneralReference.init();

//ConditionalFluidEffect.init();
//ModItems.conditionalInit();
//ModRecipes.conditionalInit();
}

private static boolean registerMod(String modID)
{
if (!Loader.isModLoaded(modID))
return false;

String modName = modID;
for (ModContainer mod : Loader.instance().getModList())
{
if (mod.getModId().equals(modID))
modName = mod.getName();
}
LogHelper.info(modName + " is present. Acting accordingly");
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public boolean deploySleepingBag(EntityPlayer player, World world, int meta, int
sby = cY;
sbz = cZ;
sbdir = meta;
world.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
return sleepingBagDeployed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.darkona.adventurebackpack.inventory.InventoryBackpack;
import com.darkona.adventurebackpack.network.PlayerActionPacket;
import com.darkona.adventurebackpack.network.SleepingBagPacket;
import com.darkona.adventurebackpack.reference.LoadedMods;
import com.darkona.adventurebackpack.util.Resources;
import com.darkona.adventurebackpack.util.TinkersUtils;

Expand All @@ -33,7 +34,6 @@
public class GuiAdvBackpack extends GuiWithTanks
{
private static final ResourceLocation TEXTURE = Resources.guiTextures("guiBackpackNew");
private static final ResourceLocation TINKERS_ICONS = TinkersUtils.getTinkersIcons();
private static final int TINKERS_SLOT = 38; //ContainerBackpack.CRAFT_MATRIX_EMULATION[4]

private static GuiImageButtonNormal bedButton = new GuiImageButtonNormal(5, 91, 18, 18);
Expand Down Expand Up @@ -110,11 +110,11 @@ else if (source == Source.HOLDING)
drawHoveringText(tankRight.getTankTooltip(), mouseX, mouseY, fontRendererObj);
}

if (ConfigHandler.IS_TCONSTRUCT && ConfigHandler.tinkerToolsMaintenance)
if (LoadedMods.TCONSTRUCT && ConfigHandler.tinkerToolsMaintenance)
{
if (inventory.getStackInSlot(TINKERS_SLOT) == null)
{
this.mc.getTextureManager().bindTexture(TINKERS_ICONS);
this.mc.getTextureManager().bindTexture(TinkersUtils.GUI_ICONS);
this.drawTexturedModalRect(this.guiLeft + 169, this.guiTop + 77, 0, 233, 18, 18);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.darkona.adventurebackpack.config.ConfigHandler;
import com.darkona.adventurebackpack.inventory.IInventoryTanks;
import com.darkona.adventurebackpack.item.ItemHose;
import com.darkona.adventurebackpack.reference.LoadedMods;
import com.darkona.adventurebackpack.reference.ModInfo;
import com.darkona.adventurebackpack.reference.ToolHandler;
import com.darkona.adventurebackpack.util.GregtechUtils;
Expand Down Expand Up @@ -81,6 +82,7 @@ public void onRenderExperienceBar(RenderGameOverlayEvent.Post event)
if (event.type != RenderGameOverlayEvent.ElementType.EXPERIENCE)
return;

EntityPlayer player = mc.thePlayer;
ScaledResolution resolution = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight);
screenWidth = resolution.getScaledWidth();
screenHeight = resolution.getScaledHeight();
Expand All @@ -107,6 +109,14 @@ public void onRenderExperienceBar(RenderGameOverlayEvent.Post event)
? ConfigHandler.statusOverlayIndentV
: screenHeight - BUFF_ICON_SIZE - ConfigHandler.statusOverlayIndentV;

if (LoadedMods.THAUMCRAFT
&& ConfigHandler.statusOverlayThaumcraft && ConfigHandler.statusOverlayLeft
&& ConfigHandler.statusOverlayTop == !ThaumcraftUtils.DIAL_BOTTOM
&& ThaumcraftUtils.isTool(player.inventory.getCurrentItem()))
{
xPos += 50; // do not overlap thaumcraft GUI
}

Collection activePotionEffects = this.mc.thePlayer.getActivePotionEffects();
if (!activePotionEffects.isEmpty())
{
Expand All @@ -119,32 +129,23 @@ public void onRenderExperienceBar(RenderGameOverlayEvent.Post event)
PotionEffect potionEffect = (PotionEffect) activeEffect.next();
Potion potion = Potion.potionTypes[potionEffect.getPotionID()];

try
{
// yes potion should not be null here, but it sometimes does. let the vanilla crash itself, no need to report this to us
if (potion != null && potion.hasStatusIcon())
{
int iconIndex = potion.getStatusIconIndex();
this.drawTexturedModalRect(
xPos, yPos,
BUFF_ICON_BASE_U_OFFSET + iconIndex % BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE,
BUFF_ICON_BASE_V_OFFSET + iconIndex / BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE,
BUFF_ICON_SIZE, BUFF_ICON_SIZE);
}
}
catch (NullPointerException npe)
// yes potion should not be null here, but it sometimes does
// let the vanilla crash itself, no need to report this to us
if (potion != null && potion.hasStatusIcon())
{
String msg = "Weird NPE is caught: activePotionEffects: " + activePotionEffects
+ "; potionEffect: " + potionEffect + "; potion: " + potion;
throw new NullPointerException(msg);
int iconIndex = potion.getStatusIconIndex();
this.drawTexturedModalRect(
xPos, yPos,
BUFF_ICON_BASE_U_OFFSET + iconIndex % BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE,
BUFF_ICON_BASE_V_OFFSET + iconIndex / BUFF_ICONS_PER_ROW * BUFF_ICON_SIZE,
BUFF_ICON_SIZE, BUFF_ICON_SIZE);
}
}
}
}

if (ConfigHandler.tanksOverlay)
{
EntityPlayer player = mc.thePlayer;
if (Wearing.isWearingWearable(player))
{
IInventoryTanks inv = Wearing.getWearingWearableInv(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ public class ConfigHandler
{
public static Configuration config;

public static boolean IS_DEVENV = false;
public static boolean IS_BUILDCRAFT = false;
public static boolean IS_ENDERIO = false;
public static boolean IS_GREGTECH = false;
public static boolean IS_TCONSTRUCT = false;
public static boolean IS_THAUMCRAFT = false;

public static boolean allowSoulBound = true;
public static boolean backpackDeathPlace = true;
public static boolean backpackAbilities = true;
Expand All @@ -46,6 +39,7 @@ public class ConfigHandler
public static boolean statusOverlayTop = true;
public static int statusOverlayIndentH = 2;
public static int statusOverlayIndentV = 2;
public static boolean statusOverlayThaumcraft = true;

public static boolean tanksOverlay = true;
public static boolean tanksOverlayRight = true;
Expand Down Expand Up @@ -134,6 +128,7 @@ private static void loadConfiguration()
statusOverlayTop = config.getBoolean("Stick To Top", "graphics.status", true, "Stick to top?");
statusOverlayIndentH = config.getInt("Indent Horizontal", "graphics.status", 2, 0, 1000, "Horizontal indent from the window border");
statusOverlayIndentV = config.getInt("Indent Vertical", "graphics.status", 2, 0, 500, "Vertical indent from the window border");
statusOverlayThaumcraft = config.getBoolean("Respect Thaumcraft", "graphics.status", true, "Take into account Thaumcraft wands GUI and do not overlap it");

// Graphics.Tanks
tanksOverlay = config.getBoolean("Enable Overlay", "graphics.tanks", true, "Show the different wearable overlays on screen?");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.darkona.adventurebackpack.init;

import com.darkona.adventurebackpack.config.ConfigHandler;
import com.darkona.adventurebackpack.fluids.effects.FuelEffect;
import com.darkona.adventurebackpack.fluids.effects.OilEffect;
import com.darkona.adventurebackpack.reference.LoadedMods;
import adventurebackpack.api.FluidEffect;

/**
Expand All @@ -17,7 +17,7 @@ public class ConditionalFluidEffect

public static void init()
{
if (ConfigHandler.IS_BUILDCRAFT)
if (LoadedMods.BUILDCRAFT)
{
oilEffect = new OilEffect();
fuelEffect = new FuelEffect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public static void init()

/*public static void conditionalInit()
{
if (ConfigHandler.IS_BUILDCRAFT)
if (LoadedMods.BUILDCRAFT)
{
GameRegistry.registerItem(copterPack, "copterPack");
}

if (ConfigHandler.IS_RAILCRAFT)
if (LoadedMods.RAILCRAFT)
{
GameRegistry.registerItem(steamJetpack, "steamJetpack");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public static void init()

/*public static void conditionalInit()
{
if(ConfigHandler.IS_BUILDCRAFT)
if (LoadedMods.BUILDCRAFT)
{

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.darkona.adventurebackpack.inventory;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.fluids.FluidTank;
Expand Down Expand Up @@ -37,6 +39,7 @@ public class ContainerBackpack extends ContainerAdventureBackpack
private static final int BUCKET_LEFT = TOOL_END + 1;
private static final int BUCKET_RIGHT = BUCKET_LEFT + 2;
private static final int MATRIX_DIMENSION = 3;
private static final int CRAFT_RESULT = BUCKET_RIGHT + 2 + (MATRIX_DIMENSION * MATRIX_DIMENSION);
private static final int[] CRAFT_MATRIX_EMULATION = findCraftMatrixEmulationIDs();

private InventoryCraftingBackpack craftMatrix = new InventoryCraftingBackpack(this, MATRIX_DIMENSION, MATRIX_DIMENSION);
Expand Down Expand Up @@ -96,7 +99,7 @@ private void makeSlots(InventoryPlayer invPlayer)

startX = 215;
startY = -2500;
//startY = ConfigHandler.IS_DEVENV ? 125 : -2500;
//startY = LoadedMods.DEV_ENV ? 125 : -2500;
for (int row = 0; row < MATRIX_DIMENSION; row++) // craftMatrix, usually 9 slots, [90-98]
{
for (int col = 0; col < MATRIX_DIMENSION; col++)
Expand All @@ -110,6 +113,24 @@ private void makeSlots(InventoryPlayer invPlayer)
syncCraftMatrixToInventory();
}

@Override
public void detectAndSendChanges()
{
ItemStack stackA = ((Slot) inventorySlots.get(CRAFT_RESULT)).getStack();
ItemStack stackB = (ItemStack) inventoryItemStacks.get(CRAFT_RESULT);

if (!ItemStack.areItemStacksEqual(stackB, stackA))
{
stackB = stackA == null ? null : stackA.copy();
inventoryItemStacks.set(CRAFT_RESULT, stackB);

if (player instanceof EntityPlayerMP)
((EntityPlayerMP) player).sendContainerAndContentsToPlayer(this, this.getInventory());
}

super.detectAndSendChanges();
}

@Override
protected boolean detectChanges()
{
Expand Down Expand Up @@ -268,7 +289,7 @@ protected void dropContentOnClose()
@Override
public void onCraftMatrixChanged(IInventory inventory)
{
if (ConfigHandler.tinkerToolsMaintenance && TinkersUtils.isTool(craftMatrix.getStackInSlot(4)))
if (ConfigHandler.tinkerToolsMaintenance && TinkersUtils.isToolOrWeapon(craftMatrix.getStackInSlot(4)))
{
craftResult.setInventorySlotContents(0, TinkersUtils.getTinkersRecipe(craftMatrix));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public interface IAsynchronousInventory extends IInventory
{
void setInventorySlotContentsNoSave(int slot, ItemStack stack);
void setInventorySlotContentsNoSave(int slot, ItemStack stack); //TODO rework realisations, see InventoryBackpack

ItemStack decrStackSizeNoSave(int slot, int amount);
ItemStack decrStackSizeNoSave(int slot, int amount); //TODO whats the point and diff with decrStackSize?
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void setInventorySlotContentsNoSave(int slot, ItemStack stack)
if (stack.stackSize > this.getInventoryStackLimit())
stack.stackSize = this.getInventoryStackLimit();

if(stack.stackSize == 0)
if (stack.stackSize == 0)
stack = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public static boolean isValidTool(ItemStack stack)

// GregTech
if (GregtechUtils.isTool(itemName))
return !(stack.getItemDamage() == 0 || stack.getItemDamage() > 169); // 0 = sword, 170 = turbines
{
int meta = stack.getItemDamage();
return !(meta == 0 || meta == 24 || meta > 169); // 0 = sword, 24 = mortar, 170+ = turbines
}
if (itemName.startsWith("gt.metaitem")) return false; // charged baterries and such

// Tinkers Construct
Expand Down
Loading