A whole lot of formatting cleanup

Also changes NBTHolder to a standard Constants class with subclasses for each category
This commit is contained in:
Nick 2015-11-28 18:25:46 -08:00
parent f9802900db
commit 34dee6447b
74 changed files with 861 additions and 662 deletions

View file

@ -9,7 +9,8 @@ import net.minecraftforge.fluids.Fluid;
public class BloodMagicAPI {
@Getter @Setter
@Getter
@Setter
private static boolean loggingEnabled;
@Getter
@ -18,9 +19,11 @@ public class BloodMagicAPI {
@Getter
private static DamageSource damageSource = new DamageSourceBloodMagic();
@Getter @Setter
@Getter
@Setter
private static Item orbItem;
@Getter @Setter
@Getter
@Setter
private static Fluid lifeEssence;
}

View file

@ -0,0 +1,61 @@
package WayofTime.bloodmagic.api;
import java.util.Locale;
public class Constants {
public static class NBT {
public static final String OWNER_NAME = "ownerName";
public static final String USES = "uses";
public static final String UNUSABLE = "unusable";
public static final String SACRIFICE = "sacrifice";
public static final String DIMENSION_ID = "dimensionId";
public static final String X_COORD = "xCoord";
public static final String Y_COORD = "yCoord";
public static final String Z_COORD = "zCoord";
public static final String ORB_TIER = "orbTier";
public static final String CURRENT_ESSENCE = "currentEssence";
public static final String CURRENT_RITUAL = "currentRitual";
public static final String IS_RUNNING = "isRunning";
public static final String RUNTIME = "runtime";
public static final String REAGENT_TANKS = "reagentTanks";
public static final String CURRENT_INCENSE = "BM:CurrentIncense";
public static final String EMPTY = "Empty";
public static final String OUTPUT_AMOUNT = "outputAmount";
public static final String INPUT_AMOUNT = "inputAmount";
public static final String STORED_LP = "storedLP";
public static final String ALTAR_TIER = "upgradeLevel";
public static final String ALTAR_ACTIVE = "isActive";
public static final String ALTAR_LIQUID_REQ = "liquidRequired";
public static final String ALTAR_FILLABLE = "canBeFilled";
public static final String ALTAR_UPGRADED = "isUpgraded";
public static final String ALTAR_CONSUMPTION_RATE = "consumptionRate";
public static final String ALTAR_DRAIN_RATE = "drainRate";
public static final String ALTAR_CONSUMPTION_MULTIPLIER = "consumptionMultiplier";
public static final String ALTAR_EFFICIENCY_MULTIPLIER = "efficiencyMultiplier";
public static final String ALTAR_SELF_SACRIFICE_MULTIPLIER = "selfSacrificeMultiplier";
public static final String ALTAR_SACRIFICE_MULTIPLIER = "sacrificeMultiplier";
public static final String ALTAR_CAPACITY_MULTIPLIER = "capacityMultiplier";
public static final String ALTAR_ORB_CAPACITY_MULTIPLIER = "orbCapacityMultiplier";
public static final String ALTAR_DISLOCATION_MULTIPLIER = "dislocationMultiplier";
public static final String ALTAR_CAPACITY = "capacity";
public static final String ALTAR_BUFFER_CAPACITY = "bufferCapacity";
public static final String ALTAR_PROGRESS = "progress";
public static final String ALTAR_IS_RESULT_BLOCK = "isResultBlock";
public static final String ALTAR_LOCKDOWN_DURATION = "lockdownDuration";
public static final String ALTAR_ACCELERATION_UPGRADES = "accelerationUpgrades";
public static final String ALTAR_DEMON_BLOOD_DURATION = "demonBloodDuration";
public static final String ALTAR_COOLDOWN_AFTER_CRAFTING = "cooldownAfterCrafting";
}
public static class Mod {
public static final String MODID = "BloodMagic";
public static final String DOMAIN = MODID.toLowerCase(Locale.ENGLISH) + ":";
public static final String NAME = "Blood Magic: Alchemical Wizardry";
public static final String VERSION = "@VERSION@";
public static final String DEPEND = "";
}
}

View file

@ -34,6 +34,10 @@ public class ItemStackWrapper {
this(block, 1, 0);
}
public static ItemStackWrapper getHolder(ItemStack stack) {
return new ItemStackWrapper(stack.getItem(), stack.stackSize, stack.getItemDamage());
}
public ItemStack toStack() {
return new ItemStack(item, stackSize, meta);
}
@ -46,8 +50,4 @@ public class ItemStackWrapper {
public String toString() {
return stackSize + "x" + item.getUnlocalizedName() + "@" + this.meta;
}
public static ItemStackWrapper getHolder(ItemStack stack) {
return new ItemStackWrapper(stack.getItem(), stack.stackSize, stack.getItemDamage());
}
}

View file

@ -1,59 +0,0 @@
package WayofTime.bloodmagic.api;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class NBTHolder {
public static final String NBT_OWNER = "ownerName";
public static final String NBT_USES = "uses";
public static final String NBT_UNUSABLE = "unusable";
public static final String NBT_SACRIFICE = "sacrifice";
public static final String NBT_DIMID = "dimensionId";
public static final String NBT_COORDX = "xCoord";
public static final String NBT_COORDY = "yCoord";
public static final String NBT_COORDZ = "zCoord";
public static final String NBT_ORBTIER = "orbTier";
public static final String NBT_CURRENTESSENCE = "currentEssence";
public static final String NBT_CURRENTRITUAL = "currentRitual";
public static final String NBT_RUNNING = "isRunning";
public static final String NBT_RUNTIME = "runtime";
public static final String NBT_REAGENTTANK = "reagentTanks";
public static final String NBT_CURRENT_INCENSE = "BM:CurrentIncense";
public static final String NBT_EMPTY = "Empty";
public static final String NBT_OUTPUT_AMOUNT = "outputAmount";
public static final String NBT_INPUT_AMOUNT = "inputAmount";
//Altar Shtuff
public static final String NBT_ALTAR_TIER = "upgradeLevel";
public static final String NBT_ALTAR_ACTIVE = "isActive";
public static final String NBT_ALTAR_LIQUID_REQ = "liquidRequired";
public static final String NBT_ALTAR_FILLABLE = "canBeFilled";
public static final String NBT_ALTAR_UPGRADED = "isUpgraded";
public static final String NBT_ALTAR_CONSUMPTION_RATE = "consumptionRate";
public static final String NBT_ALTAR_DRAIN_RATE = "drainRate";
public static final String NBT_ALTAR_CONSUMPTION_MULTIPLIER = "consumptionMultiplier";
public static final String NBT_ALTAR_EFFICIENCY_MULTIPLIER = "efficiencyMultiplier";
public static final String NBT_ALTAR_SELF_SACRIFICE_MULTIPLIER = "selfSacrificeMultiplier";
public static final String NBT_ALTAR_SACRIFICE_MULTIPLIER = "sacrificeMultiplier";
public static final String NBT_ALTAR_CAPACITY_MULTIPLIER = "capacityMultiplier";
public static final String NBT_ALTAR_ORB_CAPACITY_MULTIPLIER = "orbCapacityMultiplier";
public static final String NBT_ALTAR_DISLOCATION_MULTIPLIER = "dislocationMultiplier";
public static final String NBT_ALTAR_CAPACITY = "capacity";
public static final String NBT_ALTAR_BUFFER_CAPACITY = "bufferCapacity";
public static final String NBT_ALTAR_PROGRESS = "progress";
public static final String NBT_ALTAR_IS_RESULT_BLOCK = "isResultBlock";
public static final String NBT_ALTAR_LOCKDOWN_DURATION = "lockdownDuration";
public static final String NBT_ALTAR_ACCELERATION_UPGRADES = "accelerationUpgrades";
public static final String NBT_ALTAR_DEMON_BLOOD_DURATION = "demonBloodDuration";
public static final String NBT_ALTAR_COOLDOWN_AFTER_CRAFTING = "cooldownAfterCrafting";
public static final String NBT_STORED_LP = "storedLP";
public static ItemStack checkNBT(ItemStack stack) {
if (stack.getTagCompound() == null)
stack.setTagCompound(new NBTTagCompound());
return stack;
}
}

View file

@ -44,8 +44,6 @@ public class AltarRecipe {
// public AltarRecipe(ItemStackWrapper input, EnumAltarTier minTier, int consumeRate, int drainRate) {
// this(input, null, minTier, 0, consumeRate, drainRate);
// }
public AltarRecipe(ItemStack input, @Nullable ItemStack output, EnumAltarTier minTier, int syphon, int consumeRate, int drainRate, boolean useTag) {
this.input = input;
this.output = output;

View file

@ -104,7 +104,7 @@ public enum EnumAltarTier {
public void buildComponents() {
altarComponents.addAll(FIVE.getAltarComponents());
for(int i = -4; i <= 2; i++) {
for (int i = -4; i <= 2; i++) {
altarComponents.add(new AltarComponent(new BlockPos(11, i, 11)));
altarComponents.add(new AltarComponent(new BlockPos(-11, i, -11)));
altarComponents.add(new AltarComponent(new BlockPos(11, i, -11)));

View file

@ -12,9 +12,9 @@ public class AddToNetworkEvent extends Event {
* This event is called whenever the network is added to. If cancelled, no LP will be drained from the source. If result is set to Result.DENY,
* the LP will still be drained but the soul network will not be added to.
*
* @param ownerNetwork Key used for the soul network
* @param addedAmount Amount added
* @param maximum Ceiling that the network can add to
* @param ownerNetwork Key used for the soul network
* @param addedAmount Amount added
* @param maximum Ceiling that the network can add to
*/
public AddToNetworkEvent(String ownerNetwork, int addedAmount, int maximum) {
this.ownerNetwork = ownerNetwork;

View file

@ -23,7 +23,7 @@ public class RitualEvent extends Event {
/**
* This event is called when a ritual is activated. If cancelled, it will not activate.
*
* <p/>
* {@link WayofTime.bloodmagic.api.util.helper.RitualHelper#activate(IMasterRitualStone, Ritual, EntityPlayer)}
*/
@Cancelable
@ -43,7 +43,7 @@ public class RitualEvent extends Event {
/**
* This event is called when a Ritual effect is performed. If cancelled, the effect will not happen.
*
* <p/>
* {@link WayofTime.bloodmagic.api.util.helper.RitualHelper#perform(IMasterRitualStone, Ritual)}
*/
@Cancelable
@ -56,7 +56,7 @@ public class RitualEvent extends Event {
/**
* This event is called when a Ritual is stopped by a {@link Ritual.BreakType}.
*
* <p/>
* {@link WayofTime.bloodmagic.api.util.helper.RitualHelper#stop(IMasterRitualStone, Ritual, Ritual.BreakType)}
*/
public static class RitualStopEvent extends RitualEvent {

View file

@ -7,9 +7,9 @@ import net.minecraftforge.fml.common.eventhandler.Event;
@Cancelable
public class SacrificeKnifeUsedEvent extends Event {
public final EntityPlayer player;
public final int healthDrained;
public boolean shouldDrainHealth;
public boolean shouldFillAltar;
public final int healthDrained;
public SacrificeKnifeUsedEvent(EntityPlayer player, boolean shouldDrainHealth, boolean shouldFillAltar, int hp) {
this.player = player;

View file

@ -48,15 +48,15 @@ public class SoulNetworkEvent extends Event {
/**
* Set result to deny the action i.e. damage/drain anyways. Cancelling event prevents action without penalties
*
* @param player Player using the item
* @param ownerNetwork Network that the item is tied to
* @param itemStack Item used
* @param drainAmount Original drain amount - change to alter cost
* @param player Player using the item
* @param ownerNetwork Network that the item is tied to
* @param itemStack Item used
* @param drainAmount Original drain amount - change to alter cost
*/
public ItemDrainNetworkEvent(EntityPlayer player, String ownerNetwork, ItemStack itemStack, int drainAmount) {
super(player, ownerNetwork, drainAmount);
this.itemStack = itemStack;
this.damageAmount = (float)(drainAmount) / 100.0f;
this.damageAmount = (float) (drainAmount) / 100.0f;
}
}
}

View file

@ -10,7 +10,7 @@ public interface IBindable {
/**
* Called when the player attempts to bind the item.
*
* <p/>
* If false, binding fails.
*/
boolean onBind(EntityPlayer player, ItemStack stack);

View file

@ -1,7 +1,7 @@
package WayofTime.bloodmagic.api.network;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.event.AddToNetworkEvent;
import WayofTime.bloodmagic.api.event.SoulNetworkEvent;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
@ -23,10 +23,10 @@ import net.minecraftforge.fml.common.eventhandler.Event;
@Setter
public class SoulNetwork extends WorldSavedData {
private int currentEssence;
private int orbTier;
@Nullable
private final EntityPlayer player;
private int currentEssence;
private int orbTier;
public SoulNetwork(String name) {
super(name);
@ -38,20 +38,20 @@ public class SoulNetwork extends WorldSavedData {
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
currentEssence = nbttagcompound.getInteger(NBTHolder.NBT_CURRENTESSENCE);
orbTier = nbttagcompound.getInteger(NBTHolder.NBT_ORBTIER);
currentEssence = nbttagcompound.getInteger(Constants.NBT.CURRENT_ESSENCE);
orbTier = nbttagcompound.getInteger(Constants.NBT.ORB_TIER);
}
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger(NBTHolder.NBT_CURRENTESSENCE, currentEssence);
nbttagcompound.setInteger(NBTHolder.NBT_ORBTIER, orbTier);
nbttagcompound.setInteger(Constants.NBT.CURRENT_ESSENCE, currentEssence);
nbttagcompound.setInteger(Constants.NBT.ORB_TIER, orbTier);
}
public int addLifeEssence(int toAdd, int maximum) {
AddToNetworkEvent event = new AddToNetworkEvent(mapName, toAdd, maximum);
if(MinecraftForge.EVENT_BUS.post(event))
if (MinecraftForge.EVENT_BUS.post(event))
return 0;
if (MinecraftServer.getServer() == null)
@ -71,7 +71,7 @@ public class SoulNetwork extends WorldSavedData {
return 0;
int newEss = Math.min(event.maximum, currEss + event.addedAmount);
if(event.getResult() != Event.Result.DENY)
if (event.getResult() != Event.Result.DENY)
data.setCurrentEssence(newEss);
return newEss - currEss;
@ -93,7 +93,7 @@ public class SoulNetwork extends WorldSavedData {
/**
* If the player exists on the server, syphon the given amount of LP from the player's LP network and
* damage for any remaining LP required.
*
* <p/>
* Always returns false on the client side.
*
* @return - Whether the action should be performed.
@ -105,12 +105,12 @@ public class SoulNetwork extends WorldSavedData {
if (!Strings.isNullOrEmpty(mapName)) {
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, mapName, getPlayer().getHeldItem(), toSyphon);
if(MinecraftForge.EVENT_BUS.post(event))
if (MinecraftForge.EVENT_BUS.post(event))
return false;
int drainAmount = syphon(event.syphon);
if(drainAmount == 0 || event.shouldDamage)
if (drainAmount == 0 || event.shouldDamage)
hurtPlayer(event.syphon);
return event.getResult() != Event.Result.DENY;

View file

@ -4,11 +4,10 @@ import WayofTime.bloodmagic.api.registry.OrbRegistry;
/**
* Base object for all Blood Orbs. Makes Orb creation quite a bit easier.
*
* <p/>
* Just create a new BloodOrb instance then register it with {@link OrbRegistry#registerOrb(BloodOrb)}
* This will allow the use of just one item ID for all orbs. If an addon dev needs more control over the intricacies
* of their orb (custom right clicking, renderers, etc), they can just create their own item as normal.
*
*/
public class BloodOrb {

View file

@ -4,6 +4,7 @@ import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.ritual.Ritual;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

View file

@ -14,6 +14,13 @@ public enum EnumRuneType implements IStringSerializable {
DUSK,
DAWN;
public static EnumRuneType byMetadata(int meta) {
if (meta < 0 || meta >= values().length)
meta = 0;
return values()[meta];
}
@Override
public String toString() {
return name().toLowerCase(Locale.ENGLISH);
@ -23,11 +30,4 @@ public enum EnumRuneType implements IStringSerializable {
public String getName() {
return this.toString();
}
public static EnumRuneType byMetadata(int meta) {
if (meta < 0 || meta >= values().length)
meta = 0;
return values()[meta];
}
}

View file

@ -16,10 +16,10 @@ public interface IMasterRitualStone {
void stopRitual();
void setCooldown(int cooldown);
int getCooldown();
void setCooldown(int cooldown);
void setActive(boolean active);
EnumFacing getDirection();

View file

@ -13,13 +13,12 @@ import java.util.ArrayList;
@EqualsAndHashCode
public abstract class Ritual {
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
private final String name;
private final int crystalLevel;
private final int activationCost;
private final RitualRenderer renderer;
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
public Ritual(String name, int crystalLevel, int activationCost) {
this(name, crystalLevel, activationCost, null);
}

View file

@ -1,6 +1,6 @@
package WayofTime.bloodmagic.api.util.helper;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.event.ItemBindEvent;
import WayofTime.bloodmagic.api.iface.IBindable;
import com.google.common.base.Strings;
@ -16,6 +16,7 @@ public class BindableHelper {
*
* @param stack - The ItemStack to bind
* @param player - The Player to bind the ItemStack to
*
* @return - Whether binding was successful
*/
public static boolean checkAndSetItemOwner(ItemStack stack, EntityPlayer player) {
@ -24,25 +25,26 @@ public class BindableHelper {
/**
* Bind an item to a username.
*
* <p/>
* Requires the Item contained in the ItemStack to be an instanceof {@link IBindable}
*
* <p/>
* Fires {@link ItemBindEvent}.
*
* @param stack - The ItemStack to bind
* @param ownerName - The username to bind the ItemStack to
*
* @return - Whether the binding was successful
*/
public static boolean checkAndSetItemOwner(ItemStack stack, String ownerName) {
stack = NBTHolder.checkNBT(stack);
stack = NBTHelper.checkNBT(stack);
if (!(stack.getItem() instanceof IBindable))
return false;
if (Strings.isNullOrEmpty(stack.getTagCompound().getString(NBTHolder.NBT_OWNER))) {
if (Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_NAME))) {
MinecraftForge.EVENT_BUS.post(new ItemBindEvent(PlayerHelper.getPlayerFromUsername(ownerName), ownerName, stack));
((IBindable) stack.getItem()).onBind(PlayerHelper.getPlayerFromUsername(ownerName), stack);
stack.getTagCompound().setString(NBTHolder.NBT_OWNER, ownerName);
stack.getTagCompound().setString(Constants.NBT.OWNER_NAME, ownerName);
return true;
}
@ -57,20 +59,21 @@ public class BindableHelper {
* @param ownerName - The username to bind the ItemStack to
*/
public static void setItemOwner(ItemStack stack, String ownerName) {
stack = NBTHolder.checkNBT(stack);
stack = NBTHelper.checkNBT(stack);
stack.getTagCompound().setString(NBTHolder.NBT_OWNER, ownerName);
stack.getTagCompound().setString(Constants.NBT.OWNER_NAME, ownerName);
}
/**
* Used to safely obtain the username of the ItemStack's owner
*
* @param stack - The ItemStack to check the owner of
*
* @return - The username of the ItemStack's owner
*/
public static String getOwnerName(ItemStack stack) {
stack = NBTHolder.checkNBT(stack);
stack = NBTHelper.checkNBT(stack);
return stack.getTagCompound().getString(NBTHolder.NBT_OWNER);
return stack.getTagCompound().getString(Constants.NBT.OWNER_NAME);
}
}

View file

@ -1,14 +1,15 @@
package WayofTime.bloodmagic.api.util.helper;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
public class IncenseHelper {
public static float getCurrentIncense(EntityPlayer player) {
NBTTagCompound data = player.getEntityData();
if (data.hasKey(NBTHolder.NBT_CURRENT_INCENSE)) {
return data.getFloat(NBTHolder.NBT_CURRENT_INCENSE);
if (data.hasKey(Constants.NBT.CURRENT_INCENSE)) {
return data.getFloat(Constants.NBT.CURRENT_INCENSE);
}
return 0;
@ -16,6 +17,6 @@ public class IncenseHelper {
public static void setCurrentIncense(EntityPlayer player, float amount) {
NBTTagCompound data = player.getEntityData();
data.setFloat(NBTHolder.NBT_CURRENT_INCENSE, amount);
data.setFloat(Constants.NBT.CURRENT_INCENSE, amount);
}
}

View file

@ -0,0 +1,14 @@
package WayofTime.bloodmagic.api.util.helper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class NBTHelper {
public static ItemStack checkNBT(ItemStack stack) {
if (stack.getTagCompound() == null)
stack.setTagCompound(new NBTTagCompound());
return stack;
}
}

View file

@ -1,7 +1,7 @@
package WayofTime.bloodmagic.api.util.helper;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.event.AddToNetworkEvent;
import WayofTime.bloodmagic.api.event.SoulNetworkEvent;
import WayofTime.bloodmagic.api.network.SoulNetwork;
@ -49,8 +49,8 @@ public class NetworkHelper {
}
public static boolean syphonFromContainer(ItemStack stack, SoulNetwork soulNetwork, int toSyphon) {
stack = NBTHolder.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(NBTHolder.NBT_OWNER);
stack = NBTHelper.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_NAME);
if (Strings.isNullOrEmpty(ownerName))
return false;
@ -73,9 +73,9 @@ public class NetworkHelper {
* Master method used to syphon from the player's network, and will damage them accordingly if they do not have enough LP.
* Does not drain on the client side.
*
* @param stack Owned itemStack
* @param player Player using the item
* @param syphon
* @param stack Owned itemStack
* @param player Player using the item
*
* @return True if the action should be executed and false if it should not. Always returns false if client-sided.
*/
@Deprecated
@ -83,18 +83,18 @@ public class NetworkHelper {
if (player.worldObj.isRemote)
return false;
stack = NBTHolder.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(NBTHolder.NBT_OWNER);
stack = NBTHelper.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_NAME);
if (!Strings.isNullOrEmpty(ownerName)) {
SoulNetworkEvent.ItemDrainNetworkEvent event = new SoulNetworkEvent.ItemDrainNetworkEvent(player, ownerName, stack, syphon);
if(MinecraftForge.EVENT_BUS.post(event))
if (MinecraftForge.EVENT_BUS.post(event))
return false;
int drainAmount = syphonFromNetwork(event.ownerName, event.syphon);
if(drainAmount == 0 || event.shouldDamage)
if (drainAmount == 0 || event.shouldDamage)
hurtPlayer(player, event.syphon);
//The event has been told to prevent the action but allow all repercussions of using the item.
@ -110,15 +110,15 @@ public class NetworkHelper {
@Deprecated
public static boolean syphonFromNetworkWhileInContainer(ItemStack stack, int syphon) {
stack = NBTHolder.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(NBTHolder.NBT_OWNER);
stack = NBTHelper.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_NAME);
if (Strings.isNullOrEmpty(ownerName))
return false;
SoulNetworkEvent.ItemDrainInContainerEvent event = new SoulNetworkEvent.ItemDrainInContainerEvent(stack, ownerName, syphon);
if(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
return false;
return syphonFromNetwork(event.ownerName, event.syphon) >= syphon;
@ -126,8 +126,8 @@ public class NetworkHelper {
@Deprecated
public static int syphonFromNetwork(ItemStack stack, int syphon) {
stack = NBTHolder.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(NBTHolder.NBT_OWNER);
stack = NBTHelper.checkNBT(stack);
String ownerName = stack.getTagCompound().getString(Constants.NBT.OWNER_NAME);
if (!Strings.isNullOrEmpty(ownerName))
return syphonFromNetwork(ownerName, syphon);
@ -167,7 +167,7 @@ public class NetworkHelper {
public static int addCurrentEssenceToMaximum(String ownerName, int addedEssence, int maximum) {
AddToNetworkEvent event = new AddToNetworkEvent(ownerName, addedEssence, maximum);
if(MinecraftForge.EVENT_BUS.post(event))
if (MinecraftForge.EVENT_BUS.post(event))
return 0;
if (MinecraftServer.getServer() == null)
@ -187,7 +187,7 @@ public class NetworkHelper {
return 0;
int newEss = Math.min(event.maximum, currEss + event.addedAmount);
if(event.getResult() != Event.Result.DENY)
if (event.getResult() != Event.Result.DENY)
data.setCurrentEssence(newEss);
return newEss - currEss;

View file

@ -1,6 +1,6 @@
package WayofTime.bloodmagic.api.util.helper;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import com.google.common.base.Strings;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -36,10 +36,10 @@ public class PlayerHelper {
}
public static void causeNauseaToPlayer(ItemStack stack) {
stack = NBTHolder.checkNBT(stack);
stack = NBTHelper.checkNBT(stack);
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(NBTHolder.NBT_OWNER)))
causeNauseaToPlayer(stack.getTagCompound().getString(NBTHolder.NBT_OWNER));
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_NAME)))
causeNauseaToPlayer(stack.getTagCompound().getString(Constants.NBT.OWNER_NAME));
}
public static void causeNauseaToPlayer(String ownerName) {

View file

@ -42,12 +42,12 @@ public class RitualHelper {
/**
* Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map.
* This is used to determine whether your effect is enabled or not.
*
* <p/>
* The config option will be created as {@code B:ClassName=true} with a comment of
* {@code Enables the ClassName ritual}.
*
* <p/>
* Use {@link #}
*
* <p/>
* Should be safe to modify at any point.
*
* @param config - Your mod's Forge {@link Configuration} object.