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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import com.darkona.adventurebackpack.config.ConfigHandler;
import com.darkona.adventurebackpack.item.IBackWearableItem;
import com.darkona.adventurebackpack.util.EnchUtils;
import com.darkona.adventurebackpack.util.PotionAndEnchantUtils;
import com.darkona.adventurebackpack.util.Wearing;

public class RendererWearableEquipped extends RendererLivingEntity {
Expand All @@ -42,7 +42,7 @@ public void render(Entity entity, double x, double y, double z, float rotX, floa
if (!ConfigHandler.enableBackRendering) {
return;
}
if (EnchUtils.getTranslucencyLevel(wearable) == 2) {
if (PotionAndEnchantUtils.getTranslucencyLevel(wearable) == 2) {
return;
}
GL11.glPushAttrib(GL11.GL_TRANSFORM_BIT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ConfigHandler {

public static boolean allowSoulBound = true;
public static boolean allowTranslucency = true;
public static boolean allowStickyItems = true;
public static boolean backpackDeathPlace = true;
public static boolean backpackAbilities = true;
public static boolean enableCampfireSpawn = false;
Expand Down Expand Up @@ -104,6 +105,11 @@ private static void loadConfiguration() {
.getBoolean("Allow SoulBound", "gameplay", true, "Allow SoulBound enchant on wearable packs");
allowTranslucency = config
.getBoolean("Allow Translucency", "gameplay", true, "Allow Translucency enchant on wearable packs");
allowStickyItems = config.getBoolean(
"Allow Sticky Items",
"gameplay",
true,
"Allow Sticky Items potion effect on wearable packs");
backpackAbilities = config.getBoolean(
"Backpack Abilities",
"gameplay",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import com.darkona.adventurebackpack.playerProperties.BackpackProperty;
import com.darkona.adventurebackpack.proxy.ServerProxy;
import com.darkona.adventurebackpack.reference.BackpackTypes;
import com.darkona.adventurebackpack.util.EnchUtils;
import com.darkona.adventurebackpack.util.LogHelper;
import com.darkona.adventurebackpack.util.PotionAndEnchantUtils;
import com.darkona.adventurebackpack.util.Wearing;

import cpw.mods.fml.common.eventhandler.Event;
Expand Down Expand Up @@ -170,7 +170,8 @@ public void playerDies(LivingDeathEvent event) {
player.worldObj.createExplosion(player, player.posX, player.posY, player.posZ, 4.0F, false);
}

if (player.getEntityWorld().getGameRules().getGameRuleBooleanValue("keepInventory")) {
if (player.getEntityWorld().getGameRules().getGameRuleBooleanValue("keepInventory")
|| PotionAndEnchantUtils.hasStickyItems(player)) {
((IBackWearableItem) props.getWearable().getItem())
.onPlayerDeath(player.worldObj, player, props.getWearable());
ServerProxy.storePlayerProps(player);
Expand All @@ -189,7 +190,7 @@ public void playerDeathDrop(PlayerDropsEvent event) {
ItemStack pack = Wearing.getWearingWearable(player);
BackpackProperty props = BackpackProperty.get(player);

if (EnchUtils.isSoulBounded(pack)
if (PotionAndEnchantUtils.isSoulBounded(pack)
|| (ConfigHandler.backpackDeathPlace && pack.getItem() instanceof ItemAdventureBackpack)) {
((IBackWearableItem) props.getWearable().getItem())
.onPlayerDeath(player.worldObj, player, props.getWearable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.item.ItemStack;

import com.darkona.adventurebackpack.inventory.ContainerAdventure;
import com.darkona.adventurebackpack.util.EnchUtils;
import com.darkona.adventurebackpack.util.PotionAndEnchantUtils;

@SuppressWarnings("WeakerAccess")
public abstract class ItemAdventure extends ItemAB implements IBackWearableItem {
Expand Down Expand Up @@ -41,7 +41,7 @@ public boolean onDroppedByPlayer(ItemStack stack, EntityPlayer player) {

@Override
public boolean isBookEnchantable(ItemStack stack, ItemStack book) {
return EnchUtils.isSoulBook(book) || EnchUtils.isTranslucencyBook(book);
return PotionAndEnchantUtils.isSoulBook(book) || PotionAndEnchantUtils.isTranslucencyBook(book);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import com.darkona.adventurebackpack.reference.BackpackTypes;
import com.darkona.adventurebackpack.util.BackpackUtils;
import com.darkona.adventurebackpack.util.CoordsUtils;
import com.darkona.adventurebackpack.util.EnchUtils;
import com.darkona.adventurebackpack.util.PotionAndEnchantUtils;
import com.darkona.adventurebackpack.util.Resources;
import com.darkona.adventurebackpack.util.TipUtils;
import com.darkona.adventurebackpack.util.Utils;
Expand Down Expand Up @@ -135,7 +135,8 @@ public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer pla
@Override
public void onPlayerDeath(World world, EntityPlayer player, ItemStack stack) {
if (world.isRemote || !ConfigHandler.backpackDeathPlace
|| EnchUtils.isSoulBounded(stack)
|| PotionAndEnchantUtils.isSoulBounded(stack)
|| PotionAndEnchantUtils.hasStickyItems(player)
|| player.getEntityWorld().getGameRules().getGameRuleBooleanValue("keepInventory")) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public final class LoadedMods {
public static final boolean THAUMCRAFT = registerMod("Thaumcraft");
public static final boolean WAILA = registerMod("waila");
public static final boolean HUNGEROVERHAUL = registerMod("HungerOverhaul");
public static final boolean WITCHERY = registerMod("witchery");
public static final boolean WITCHINGGADGETS = registerMod("WitchingGadgets");

private LoadedMods() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@

import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;

import com.darkona.adventurebackpack.config.ConfigHandler;
import com.darkona.adventurebackpack.reference.LoadedMods;

public final class EnchUtils {
public final class PotionAndEnchantUtils {

// -3 - disabled by config
// -2 - EnderIO not found
// -2 - mod not found
// -1 - enchantment not found
private static final int SOUL_BOUND_ID = setSoulBoundID();

private static final int TRANSLUCENCY_ID = setTranslucencyID();
private static final int STICKY_ITEMS_ID = setStickyItemsID();

private EnchUtils() {}
private PotionAndEnchantUtils() {}

private static int setSoulBoundID() {
if (!ConfigHandler.allowSoulBound) return -3;
Expand All @@ -40,10 +42,20 @@ private static int setTranslucencyID() {
return -1;
}

private static int setStickyItemsID() {
if (!ConfigHandler.allowStickyItems) return -3;

if (!LoadedMods.WITCHERY) return -2;

for (Potion potion : Potion.potionTypes)
if (potion != null && potion.getName().equals("witchery:potion.keepinventory")) return potion.getId();

return -1;
}

public static boolean isSoulBounded(ItemStack stack) {
if (SOUL_BOUND_ID > 0) return EnchantmentHelper.getEnchantmentLevel(SOUL_BOUND_ID, stack) > 0;
else return false;

}

public static int getTranslucencyLevel(ItemStack stack) {
Expand All @@ -64,4 +76,8 @@ public static boolean isTranslucencyBook(ItemStack book) {
}
return false;
}

public static boolean hasStickyItems(EntityPlayer player) {
return (STICKY_ITEMS_ID > 0) && player.isPotionActive(STICKY_ITEMS_ID);
}
}