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

@ -1,5 +1,6 @@
package WayofTime.bloodmagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.LogHelper;
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
import WayofTime.bloodmagic.proxy.CommonProxy;
@ -18,33 +19,26 @@ import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.io.File;
import java.util.Locale;
@Mod(modid = BloodMagic.MODID, name = BloodMagic.NAME, version = BloodMagic.VERSION, dependencies = BloodMagic.DEPEND, guiFactory = "WayofTime.bloodmagic.client.gui.ConfigGuiFactory")
@Mod(modid = Constants.Mod.MODID, name = Constants.Mod.NAME, version = Constants.Mod.VERSION, dependencies = Constants.Mod.DEPEND, guiFactory = "WayofTime.bloodmagic.client.gui.ConfigGuiFactory")
@Getter
public class BloodMagic {
public static final String MODID = "BloodMagic";
public static final String NAME = "Blood Magic: Alchemical Wizardry";
public static final String VERSION = "@VERSION@";
public static final String DEPEND = "";
public static final String DOMAIN = MODID.toLowerCase(Locale.ENGLISH) + ":";
@SidedProxy(serverSide = "WayofTime.bloodmagic.proxy.CommonProxy", clientSide = "WayofTime.bloodmagic.proxy.ClientProxy")
public static CommonProxy proxy;
@Mod.Instance(MODID)
@Mod.Instance(Constants.Mod.MODID)
public static BloodMagic instance;
public static CreativeTabs tabBloodMagic = new CreativeTabs(MODID + ".creativeTab") {
public static CreativeTabs tabBloodMagic = new CreativeTabs(Constants.Mod.MODID + ".creativeTab") {
@Override
public Item getTabIconItem() {
return ModItems.bloodOrb;
}
};
private InventoryRenderHelper renderHelper = new InventoryRenderHelper(DOMAIN);
private LogHelper logger = new LogHelper(MODID);
private InventoryRenderHelper renderHelper = new InventoryRenderHelper(Constants.Mod.DOMAIN);
private LogHelper logger = new LogHelper(Constants.Mod.MODID);
private File configDir;
@Mod.EventHandler

View file

@ -1,8 +1,7 @@
package WayofTime.bloodmagic;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.util.helper.RitualHelper;
import WayofTime.bloodmagic.registry.ModPotions;
import WayofTime.bloodmagic.util.Utils;
@ -20,8 +19,7 @@ import java.util.List;
public class ConfigHandler {
@Getter
@Setter
@Getter @Setter
private static Configuration config;
// Teleposer
@ -104,7 +102,7 @@ public class ConfigHandler {
category = "Teleposer Blacklist";
config.addCustomCategoryComment(category, "Block blacklisting");
teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[] {"minecraft:bedrock"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
teleposerBlacklisting = config.getStringList("teleposerBlacklist", category, new String[]{"minecraft:bedrock"}, "Stops specified blocks from being teleposed. Put entries on new lines. Valid syntax is:\nmodid:blockname:meta");
buildTeleposerBlacklist();
category = "Potions";

View file

@ -5,7 +5,6 @@ import WayofTime.bloodmagic.api.altar.*;
import WayofTime.bloodmagic.block.BlockBloodRune;
import WayofTime.bloodmagic.block.BlockBloodStoneBrick;
import WayofTime.bloodmagic.registry.ModBlocks;
import net.minecraft.block.BlockAir;
import net.minecraft.block.BlockBeacon;
import net.minecraft.block.BlockGlowstone;
import net.minecraft.init.Blocks;

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.

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
import WayofTime.bloodmagic.api.iface.IAltarReader;
import WayofTime.bloodmagic.tile.TileAltar;
@ -20,7 +21,7 @@ public class BlockAltar extends BlockContainer {
public BlockAltar() {
super(Material.rock);
setUnlocalizedName(BloodMagic.MODID + ".altar");
setUnlocalizedName(Constants.Mod.MODID + ".altar");
setCreativeTab(BloodMagic.tabBloodMagic);
}

View file

@ -1,17 +1,18 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.block.base.BlockString;
import net.minecraft.block.material.Material;
public class BlockBloodRune extends BlockString {
public static final String[] names = { "blank", "speed", "efficiency", "sacrifice", "selfSacrifice", "displacement", "capacity", "augCapacity", "orb", "acceleration" };
public static final String[] names = {"blank", "speed", "efficiency", "sacrifice", "selfSacrifice", "displacement", "capacity", "augCapacity", "orb", "acceleration"};
public BlockBloodRune() {
super(Material.rock, names);
setUnlocalizedName(BloodMagic.MODID + ".rune.");
setUnlocalizedName(Constants.Mod.MODID + ".rune.");
setCreativeTab(BloodMagic.tabBloodMagic);
setStepSound(soundTypeStone);
setHardness(2.0F);

View file

@ -1,17 +1,18 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.block.base.BlockString;
import net.minecraft.block.material.Material;
public class BlockBloodStoneBrick extends BlockString {
public static final String[] names = { "normal", "large" };
public static final String[] names = {"normal", "large"};
public BlockBloodStoneBrick() {
super(Material.rock, names);
setUnlocalizedName(BloodMagic.MODID + ".bloodstonebrick.");
setUnlocalizedName(Constants.Mod.MODID + ".bloodstonebrick.");
setCreativeTab(BloodMagic.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);

View file

@ -1,7 +1,7 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import lombok.Getter;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
@ -23,7 +23,7 @@ public class BlockLifeEssence extends BlockFluidClassic {
public BlockLifeEssence() {
super(lifeEssence, Material.water);
setUnlocalizedName(BloodMagic.MODID + ".fluid.lifeEssence");
setUnlocalizedName(Constants.Mod.MODID + ".fluid.lifeEssence");
lifeEssence.setBlock(this);
BloodMagicAPI.setLifeEssence(lifeEssence);
@ -42,7 +42,7 @@ public class BlockLifeEssence extends BlockFluidClassic {
public static class FluidLifeEssence extends Fluid {
public FluidLifeEssence() {
super("lifeEssence", new ResourceLocation(BloodMagic.DOMAIN + "blocks/lifeEssenceStill"), new ResourceLocation(BloodMagic.DOMAIN + "blocks/lifeEssenceFlowing"));
super("lifeEssence", new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceStill"), new ResourceLocation(Constants.Mod.DOMAIN + "blocks/lifeEssenceFlowing"));
setDensity(2000);
setViscosity(2000);

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.block.base.BlockStringContainer;
import WayofTime.bloodmagic.tile.TilePlinth;
import WayofTime.bloodmagic.util.Utils;
@ -15,12 +16,12 @@ import net.minecraft.world.World;
public class BlockPedestal extends BlockStringContainer {
public static String[] names = { "pedestal", "plinth" };
public static String[] names = {"pedestal", "plinth"};
public BlockPedestal() {
super(Material.rock, names);
setUnlocalizedName(BloodMagic.MODID + ".");
setUnlocalizedName(Constants.Mod.MODID + ".");
setCreativeTab(BloodMagic.tabBloodMagic);
setHardness(2.0F);
setResistance(5.0F);

View file

@ -2,6 +2,7 @@ package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry;
import WayofTime.bloodmagic.block.base.BlockStringContainer;
import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
@ -16,12 +17,12 @@ import net.minecraft.world.World;
public class BlockRitualController extends BlockStringContainer {
public static final String[] names = { "master", "imperfect" };
public static final String[] names = {"master", "imperfect"};
public BlockRitualController() {
super(Material.rock, names);
setUnlocalizedName(BloodMagic.MODID + ".stone.ritual.");
setUnlocalizedName(Constants.Mod.MODID + ".stone.ritual.");
setCreativeTab(BloodMagic.tabBloodMagic);
setStepSound(soundTypeStone);
setHardness(2.0F);

View file

@ -1,30 +1,31 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
import WayofTime.bloodmagic.api.ritual.IRitualStone;
import WayofTime.bloodmagic.block.base.BlockString;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
import WayofTime.bloodmagic.api.ritual.IRitualStone;
public class BlockRitualStone extends BlockString implements IRitualStone {
public static final String[] names = { "blank", "water", "fire", "earth", "air", "dusk", "dawn" };
public static final String[] names = {"blank", "water", "fire", "earth", "air", "dusk", "dawn"};
public BlockRitualStone() {
super(Material.iron, names);
public BlockRitualStone() {
super(Material.iron, names);
setUnlocalizedName(BloodMagic.MODID + ".ritualStone.");
setCreativeTab(BloodMagic.tabBloodMagic);
setStepSound(soundTypeStone);
setHardness(2.0F);
setResistance(5.0F);
setHarvestLevel("pickaxe", 2);
}
setUnlocalizedName(Constants.Mod.MODID + ".ritualStone.");
setCreativeTab(BloodMagic.tabBloodMagic);
setStepSound(soundTypeStone);
setHardness(2.0F);
setResistance(5.0F);
setHarvestLevel("pickaxe", 2);
}
@Override
public boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType) {
return runeType.toString().equals(names[getMetaFromState(world.getBlockState(pos))]);
}
@Override
public boolean isRuneType(World world, BlockPos pos, EnumRuneType runeType) {
return runeType.toString().equals(names[getMetaFromState(world.getBlockState(pos))]);
}
}

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyInteger;
@ -20,13 +21,13 @@ import java.util.List;
public class BlockSocket extends Block {
public static final String[] names = { "empty", "filled" };
public static final String[] names = {"empty", "filled"};
public static final PropertyInteger META = PropertyInteger.create("META", 0, names.length - 1);
public BlockSocket() {
super(Material.iron);
setUnlocalizedName(BloodMagic.MODID + ".socket.");
setUnlocalizedName(Constants.Mod.MODID + ".socket.");
setHardness(2.0F);
setResistance(5.0F);
setStepSound(soundTypeMetal);

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
@ -14,7 +15,7 @@ public class BlockSoulForge extends Block {
public BlockSoulForge() {
super(Material.iron);
setUnlocalizedName(BloodMagic.MODID + ".soulforge.");
setUnlocalizedName(Constants.Mod.MODID + ".soulforge.");
setHardness(2.0F);
setResistance(5.0F);
setStepSound(soundTypeMetal);
@ -28,7 +29,6 @@ public class BlockSoulForge extends Block {
return false;
return false;
}
}

View file

@ -0,0 +1,52 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.item.ItemTelepositionFocus;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public class BlockTeleposer extends BlockContainer {
public BlockTeleposer() {
super(Material.rock);
setCreativeTab(BloodMagic.tabBloodMagic);
setUnlocalizedName(Constants.Mod.MODID + ".teleposer");
setHardness(2.0F);
setResistance(5.0F);
}
@Override
public int getRenderType() {
return 3;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack playerItem = player.getCurrentEquippedItem();
if (playerItem != null && playerItem.getItem() instanceof ItemTelepositionFocus) {
BindableHelper.checkAndSetItemOwner(playerItem, player);
((ItemTelepositionFocus) playerItem.getItem()).setBlockPos(playerItem, world, pos);
return true;
}
// player.openGui(AlchemicalWizardry.instance, 1, world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
return null;
}
}

View file

@ -1,5 +1,7 @@
package WayofTime.bloodmagic.block;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
@ -9,59 +11,58 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import WayofTime.bloodmagic.BloodMagic;
public class BlockTestSpellBlock extends Block {
public static final PropertyDirection INPUT = PropertyDirection
.create("input");
public static final PropertyDirection OUTPUT = PropertyDirection
.create("output");
public static final PropertyDirection INPUT = PropertyDirection
.create("input");
public static final PropertyDirection OUTPUT = PropertyDirection
.create("output");
public BlockTestSpellBlock() {
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
public BlockTestSpellBlock() {
super(Material.rock);
setHardness(2.0F);
setResistance(5.0F);
setUnlocalizedName(BloodMagic.MODID + ".testSpellBlock");
setCreativeTab(BloodMagic.tabBloodMagic);
this.setDefaultState(this.blockState.getBaseState()
.withProperty(INPUT, EnumFacing.DOWN)
.withProperty(OUTPUT, EnumFacing.UP));
}
setUnlocalizedName(Constants.Mod.MODID + ".testSpellBlock");
setCreativeTab(BloodMagic.tabBloodMagic);
this.setDefaultState(this.blockState.getBaseState()
.withProperty(INPUT, EnumFacing.DOWN)
.withProperty(OUTPUT, EnumFacing.UP));
}
@Override
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState();
}
@Override
public IBlockState getStateFromMeta(int meta) {
return this.getDefaultState();
}
@Override
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
public int getMetaFromState(IBlockState state) {
return 0;
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
return state.withProperty(INPUT, EnumFacing.DOWN)
.withProperty(OUTPUT, EnumFacing.UP);
}
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
return state.withProperty(INPUT, EnumFacing.DOWN)
.withProperty(OUTPUT, EnumFacing.UP);
}
@Override
protected BlockState createBlockState() {
return new BlockState(this, new IProperty[] { INPUT, OUTPUT });
}
@Override
protected BlockState createBlockState() {
return new BlockState(this, new IProperty[]{INPUT, OUTPUT});
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public boolean isFullCube() {
return false;
}
@Override
public boolean isFullCube() {
return false;
}
@Override
public boolean isPassable(IBlockAccess blockAccess, BlockPos pos) {
return false;
}
@Override
public boolean isPassable(IBlockAccess blockAccess, BlockPos pos) {
return false;
}
}

View file

@ -26,9 +26,9 @@ import java.util.List;
/**
* Creates a block that has multiple meta-based states.
*
* <p/>
* These states will be numbered 0 through {@code maxMeta}.
*
* <p/>
* For {@link net.minecraft.tileentity.TileEntity}'s, use {@link BlockIntegerContainer}.
*/
@Getter
@ -105,6 +105,6 @@ public class BlockInteger extends Block {
}
private BlockState createRealBlockState() {
return new ExtendedBlockState(this, new IProperty[] { metaProp }, new IUnlistedProperty[] { unlistedMetaProp });
return new ExtendedBlockState(this, new IProperty[]{metaProp}, new IUnlistedProperty[]{unlistedMetaProp});
}
}

View file

@ -27,10 +27,10 @@ import java.util.List;
/**
* Creates a block that has multiple meta-based states.
*
* <p/>
* These states will be named after the given string array. Somewhere along the way, each
* value is {@code toLowerCase()}'ed, so the blockstate JSON needs all values to be lowercase.
*
* <p/>
* For {@link net.minecraft.tileentity.TileEntity}'s, use {@link BlockStringContainer}.
*/
@Getter
@ -109,6 +109,6 @@ public class BlockString extends Block {
}
private BlockState createRealBlockState() {
return new ExtendedBlockState(this, new IProperty[] { stringProp }, new IUnlistedProperty[] { unlistedStringProp });
return new ExtendedBlockState(this, new IProperty[]{stringProp}, new IUnlistedProperty[]{unlistedStringProp});
}
}

View file

@ -21,6 +21,10 @@ public class PropertyString extends PropertyHelper {
allowedValues = ImmutableSet.copyOf(hashSet);
}
public static PropertyString create(String name, String[] values) {
return new PropertyString(name, values);
}
@Override
public Collection getAllowedValues() {
return allowedValues;
@ -34,8 +38,4 @@ public class PropertyString extends PropertyHelper {
public String getName(Comparable value) {
return this.getName0(value.toString());
}
public static PropertyString create(String name, String[] values) {
return new PropertyString(name, values);
}
}

View file

@ -1,7 +1,7 @@
package WayofTime.bloodmagic.client.gui;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.ConfigHandler;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.config.ConfigElement;
import net.minecraftforge.fml.client.config.GuiConfig;
@ -13,7 +13,7 @@ import java.util.List;
public class ConfigGui extends GuiConfig {
public ConfigGui(GuiScreen parentScreen) {
super(parentScreen, getConfigElements(parentScreen), BloodMagic.MODID, false, false, "BloodMagic Configuration");
super(parentScreen, getConfigElements(parentScreen), Constants.Mod.MODID, false, false, "BloodMagic Configuration");
}
@SuppressWarnings("rawtypes")

View file

@ -1,6 +1,6 @@
package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
@ -13,12 +13,12 @@ import java.util.List;
public class ItemActivationCrystal extends ItemBindable {
public static String[] names = { "weak", "awakened", "creative" };
public static String[] names = {"weak", "awakened", "creative"};
public ItemActivationCrystal() {
super();
setUnlocalizedName(BloodMagic.MODID + ".activationCrystal.");
setUnlocalizedName(Constants.Mod.MODID + ".activationCrystal.");
setHasSubtypes(true);
setEnergyUsed(100);
}

View file

@ -2,9 +2,10 @@ package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.TextHelper;
import com.google.common.base.Strings;
@ -32,30 +33,6 @@ public class ItemBindable extends Item implements IBindable {
setMaxStackSize(1);
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
NBTHolder.checkNBT(stack);
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(NBTHolder.NBT_OWNER)))
tooltip.add(TextHelper.getFormattedText(String.format(StatCollector.translateToLocal("tooltip.BloodMagic.currentOwner"), stack.getTagCompound().getString(NBTHolder.NBT_OWNER))));
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
BindableHelper.checkAndSetItemOwner(stack, player);
return stack;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
BindableHelper.checkAndSetItemOwner(stack, player);
return false;
}
public static boolean syphonBatteries(ItemStack stack, EntityPlayer player, int damageToBeDone) {
if (!player.worldObj.isRemote) {
return NetworkHelper.syphonAndDamage(NetworkHelper.getSoulNetwork(BindableHelper.getOwnerName(stack), player.worldObj), damageToBeDone);
@ -94,6 +71,30 @@ public class ItemBindable extends Item implements IBindable {
}
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
NBTHelper.checkNBT(stack);
if (!Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_NAME)))
tooltip.add(TextHelper.getFormattedText(String.format(StatCollector.translateToLocal("tooltip.BloodMagic.currentOwner"), stack.getTagCompound().getString(Constants.NBT.OWNER_NAME))));
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
BindableHelper.checkAndSetItemOwner(stack, player);
return stack;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
BindableHelper.checkAndSetItemOwner(stack, player);
return false;
}
protected void damagePlayer(World world, EntityPlayer player, int damage) {
if (world != null) {
double posX = player.posX;
@ -127,9 +128,9 @@ public class ItemBindable extends Item implements IBindable {
}
public String getBindableOwner(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);
}
// IBindable

View file

@ -1,7 +1,6 @@
package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.IBindable;
import WayofTime.bloodmagic.api.orb.BloodOrb;
import WayofTime.bloodmagic.api.orb.IBloodOrb;
@ -23,7 +22,7 @@ import java.util.List;
public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable {
public ItemBloodOrb() {
setUnlocalizedName(BloodMagic.MODID + ".orb.");
setUnlocalizedName(Constants.Mod.MODID + ".orb.");
setHasSubtypes(true);
}
@ -53,19 +52,19 @@ public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable {
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
// SpellHelper.sendIndexedParticleToAllAround(world, posX, posY, posZ, 20, world.provider.getDimensionId(), 4, posX, posY, posZ);
if(PlayerHelper.isFakePlayer(player))
if (PlayerHelper.isFakePlayer(player))
return stack;
if (Strings.isNullOrEmpty(stack.getTagCompound().getString(NBTHolder.NBT_OWNER)))
if (Strings.isNullOrEmpty(stack.getTagCompound().getString(Constants.NBT.OWNER_NAME)))
return stack;
if (world.isRemote)
return stack;
if(stack.getTagCompound().getString(NBTHolder.NBT_OWNER).equals(PlayerHelper.getUsernameFromPlayer(player)))
NetworkHelper.setMaxOrbToMax(NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(NBTHolder.NBT_OWNER), world), getOrbLevel(stack.getItemDamage()));
if (stack.getTagCompound().getString(Constants.NBT.OWNER_NAME).equals(PlayerHelper.getUsernameFromPlayer(player)))
NetworkHelper.setMaxOrbToMax(NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(Constants.NBT.OWNER_NAME), world), getOrbLevel(stack.getItemDamage()));
NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(NBTHolder.NBT_OWNER), world).addLifeEssence(200, getMaxEssence(stack.getItemDamage()));
NetworkHelper.getSoulNetwork(stack.getTagCompound().getString(Constants.NBT.OWNER_NAME), world).addLifeEssence(200, getMaxEssence(stack.getItemDamage()));
hurtPlayer(player, 200);
return stack;
}

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModBlocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemBucket;
@ -10,7 +11,7 @@ public class ItemBucketEssence extends ItemBucket {
public ItemBucketEssence() {
super(ModBlocks.lifeEssence);
setUnlocalizedName(BloodMagic.MODID + ".bucket.lifeEssence");
setUnlocalizedName(Constants.Mod.MODID + ".bucket.lifeEssence");
setContainerItem(Items.bucket);
setCreativeTab(BloodMagic.tabBloodMagic);
}

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.DamageSourceBloodMagic;
import WayofTime.bloodmagic.api.altar.IBloodAltar;
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
@ -30,7 +31,7 @@ public class ItemSacrificialDagger extends Item {
public ItemSacrificialDagger() {
super();
setUnlocalizedName(BloodMagic.MODID + ".sacrificialDagger.");
setUnlocalizedName(Constants.Mod.MODID + ".sacrificialDagger.");
setCreativeTab(BloodMagic.tabBloodMagic);
setHasSubtypes(true);
setMaxStackSize(1);

View file

@ -0,0 +1,91 @@
package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.util.helper.BindableHelper;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.BlockPos;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Arrays;
import java.util.List;
public class ItemTelepositionFocus extends ItemBindable {
public static String[] names = {"weak", "enhanced", "reinforced", "demonic"};
public ItemTelepositionFocus() {
super();
setUnlocalizedName(Constants.Mod.MODID + ".focus.");
setCreativeTab(BloodMagic.tabBloodMagic);
setMaxStackSize(1);
setHasSubtypes(true);
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void getSubItems(Item id, CreativeTabs creativeTab, List list) {
for (int i = 0; i < names.length; i++)
list.add(new ItemStack(id, 1, i));
}
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
if (BindableHelper.checkAndSetItemOwner(stack, player))
if (player.isSneaking())
return stack;
return stack;
}
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localize("tooltip.BloodMagic.telepositionfocus." + names[stack.getItemDamage()]))));
super.addInformation(stack, player, tooltip, advanced);
NBTTagCompound tag = stack.getTagCompound();
BlockPos coords = getBlockPos(stack);
tooltip.add(String.format(StatCollector.translateToLocal("tooltip.alchemy.coords"), coords.getX(), coords.getY(), coords.getZ()));
tooltip.add(String.format(StatCollector.translateToLocal("tooltip.alchemy.dimension"), tag.getInteger(Constants.NBT.DIMENSION_ID)));
}
public World getWorld(ItemStack stack) {
stack = NBTHelper.checkNBT(stack);
return DimensionManager.getWorld(stack.getTagCompound().getInteger(Constants.NBT.DIMENSION_ID));
}
public BlockPos getBlockPos(ItemStack stack) {
stack = NBTHelper.checkNBT(stack);
return new BlockPos(stack.getTagCompound().getInteger(Constants.NBT.X_COORD), stack.getTagCompound().getInteger(Constants.NBT.Y_COORD), stack.getTagCompound().getInteger(Constants.NBT.Z_COORD));
}
public ItemStack setBlockPos(ItemStack stack, World world, BlockPos pos) {
NBTTagCompound itemTag = stack.getTagCompound();
itemTag.setInteger(Constants.NBT.X_COORD, pos.getX());
itemTag.setInteger(Constants.NBT.Y_COORD, pos.getY());
itemTag.setInteger(Constants.NBT.Z_COORD, pos.getZ());
itemTag.setInteger(Constants.NBT.DIMENSION_ID, world.provider.getDimensionId());
return stack;
}
}

View file

@ -1,37 +1,39 @@
package WayofTime.bloodmagic.item.armour;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModItems;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.registry.ModItems;
public class ItemLivingArmour extends ItemArmor {
public static String[] names = { "helmet", "chest", "legs", "boots" };
public ItemLivingArmour(int armorType) {
super(ItemArmor.ArmorMaterial.IRON, 0, armorType);
setUnlocalizedName(BloodMagic.MODID + ".livingArmour.");
setMaxDamage(250);
setCreativeTab(BloodMagic.tabBloodMagic);
}
public static String[] names = {"helmet", "chest", "legs", "boots"};
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if (this == ModItems.livingArmourChest
|| this == ModItems.livingArmourHelmet
|| this == ModItems.livingArmourBoots) {
return "bloodmagic:models/armor/boundArmour_layer_1.png";
}
public ItemLivingArmour(int armorType) {
super(ItemArmor.ArmorMaterial.IRON, 0, armorType);
setUnlocalizedName(Constants.Mod.MODID + ".livingArmour.");
setMaxDamage(250);
setCreativeTab(BloodMagic.tabBloodMagic);
}
if (this == ModItems.livingArmourLegs) {
return "bloodmagic:models/armor/boundArmour_layer_2.png";
} else {
return null;
}
}
@Override
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
if (this == ModItems.livingArmourChest
|| this == ModItems.livingArmourHelmet
|| this == ModItems.livingArmourBoots) {
return "bloodmagic:models/armor/boundArmour_layer_1.png";
}
if (this == ModItems.livingArmourLegs) {
return "bloodmagic:models/armor/boundArmour_layer_2.png";
} else {
return null;
}
}
@Override
public String getUnlocalizedName(ItemStack stack) {
return super.getUnlocalizedName(stack) + names[armorType];
}

View file

@ -1,9 +1,9 @@
package WayofTime.bloodmagic.item.block;
import WayofTime.bloodmagic.block.BlockRitualStone;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import WayofTime.bloodmagic.block.BlockRitualStone;
public class ItemBlockRitualStone extends ItemBlock {

View file

@ -1,8 +1,9 @@
package WayofTime.bloodmagic.item.gear;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.tile.TileAltar;
import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.entity.Entity;
@ -23,7 +24,7 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator {
public ItemPackSacrifice() {
super(ArmorMaterial.CHAIN, 0, 1);
setUnlocalizedName(BloodMagic.MODID + ".pack.sacrifice");
setUnlocalizedName(Constants.Mod.MODID + ".pack.sacrifice");
setCreativeTab(BloodMagic.tabBloodMagic);
}
@ -45,10 +46,10 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator {
TileAltar altar = (TileAltar) tile;
if(!altar.isActive()) {
if (!altar.isActive()) {
int amount = this.getStoredLP(stack);
if(amount > 0) {
if (amount > 0) {
int filledAmount = altar.fillMainTank(amount);
amount -= filledAmount;
setStoredLP(stack, amount);
@ -63,19 +64,19 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator {
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
return BloodMagic.DOMAIN + "models/armor/bloodPack_layer_1.png";
return Constants.Mod.DOMAIN + "models/armor/bloodPack_layer_1.png";
}
@Override
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
stack = NBTHolder.checkNBT(stack);
stack = NBTHelper.checkNBT(stack);
list.add(TextHelper.localize("tooltip.BloodMagic.pack.sacrifice.desc"));
list.add(TextHelper.localize("tooltip.BloodMagic.pack.stored", getStoredLP(stack)));
}
public void addLP(ItemStack stack, int toAdd) {
stack = NBTHolder.checkNBT(stack);
stack = NBTHelper.checkNBT(stack);
if (toAdd < 0)
toAdd = 0;
@ -87,12 +88,12 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator {
}
public void setStoredLP(ItemStack stack, int lp) {
stack = NBTHolder.checkNBT(stack);
stack.getTagCompound().setInteger(NBTHolder.NBT_STORED_LP, lp);
stack = NBTHelper.checkNBT(stack);
stack.getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
}
public int getStoredLP(ItemStack stack) {
stack = NBTHolder.checkNBT(stack);
return stack.getTagCompound().getInteger(NBTHolder.NBT_STORED_LP);
stack = NBTHelper.checkNBT(stack);
return stack.getTagCompound().getInteger(Constants.NBT.STORED_LP);
}
}

View file

@ -1,8 +1,9 @@
package WayofTime.bloodmagic.item.gear;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.IAltarManipulator;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.tile.TileAltar;
import WayofTime.bloodmagic.util.helper.TextHelper;
@ -16,7 +17,7 @@ import net.minecraft.world.World;
import java.util.List;
public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator{
public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator {
public final int CONVERSION = 100; // How much LP per half heart
public final int CAPACITY = 10000; // Max LP storage
@ -26,7 +27,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
public ItemPackSelfSacrifice() {
super(ArmorMaterial.CHAIN, 0, 1);
setUnlocalizedName(BloodMagic.MODID + ".pack.selfSacrifice");
setUnlocalizedName(Constants.Mod.MODID + ".pack.selfSacrifice");
setCreativeTab(BloodMagic.tabBloodMagic);
}
@ -48,10 +49,10 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
TileAltar altar = (TileAltar) tile;
if(!altar.isActive()) {
if (!altar.isActive()) {
int amount = this.getStoredLP(stack);
if(amount > 0) {
if (amount > 0) {
int filledAmount = altar.fillMainTank(amount);
amount -= filledAmount;
setStoredLP(stack, amount);
@ -79,19 +80,19 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
return BloodMagic.DOMAIN + "models/armor/bloodPack_layer_1.png";
return Constants.Mod.DOMAIN + "models/armor/bloodPack_layer_1.png";
}
@Override
@SuppressWarnings("unchecked")
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
stack = NBTHolder.checkNBT(stack);
stack = NBTHelper.checkNBT(stack);
list.add(TextHelper.localize("tooltip.BloodMagic.pack.selfSacrifice.desc"));
list.add(TextHelper.localize("tooltip.BloodMagic.pack.stored", getStoredLP(stack)));
}
public void addLP(ItemStack stack, int toAdd) {
stack = NBTHolder.checkNBT(stack);
stack = NBTHelper.checkNBT(stack);
if (toAdd < 0)
toAdd = 0;
@ -103,12 +104,12 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
}
public void setStoredLP(ItemStack stack, int lp) {
stack = NBTHolder.checkNBT(stack);
stack.getTagCompound().setInteger(NBTHolder.NBT_STORED_LP, lp);
stack = NBTHelper.checkNBT(stack);
stack.getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
}
public int getStoredLP(ItemStack stack) {
stack = NBTHolder.checkNBT(stack);
return stack.getTagCompound().getInteger(NBTHolder.NBT_STORED_LP);
stack = NBTHelper.checkNBT(stack);
return stack.getTagCompound().getInteger(Constants.NBT.STORED_LP);
}
}

View file

@ -1,10 +1,10 @@
package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.iface.ISigil;
import WayofTime.bloodmagic.util.helper.TextHelper;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.item.ItemBindable;
import WayofTime.bloodmagic.util.helper.TextHelper;
import lombok.Getter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
@ -20,14 +20,14 @@ import java.util.List;
@Getter
public class ItemSigilBase extends ItemBindable implements ISigil {
protected final String tooltipBase;
private final String name;
private boolean toggleable;
protected final String tooltipBase;
public ItemSigilBase(String name, int energyUsed) {
super();
setUnlocalizedName(BloodMagic.MODID + ".sigil." + name);
setUnlocalizedName(Constants.Mod.MODID + ".sigil." + name);
setEnergyUsed(energyUsed);
this.name = name;
@ -68,15 +68,15 @@ public class ItemSigilBase extends ItemBindable implements ISigil {
}
public boolean isUnusable(ItemStack stack) {
NBTHolder.checkNBT(stack);
NBTHelper.checkNBT(stack);
return stack.getTagCompound().getBoolean(NBTHolder.NBT_UNUSABLE);
return stack.getTagCompound().getBoolean(Constants.NBT.UNUSABLE);
}
public ItemStack setUnusable(ItemStack stack, boolean unusable) {
NBTHolder.checkNBT(stack);
NBTHelper.checkNBT(stack);
stack.getTagCompound().setBoolean(NBTHolder.NBT_UNUSABLE, unusable);
stack.getTagCompound().setBoolean(Constants.NBT.UNUSABLE, unusable);
return stack;
}

View file

@ -51,8 +51,7 @@ public class ItemSigilLava extends ItemSigilBase {
this.tryPlaceLava(world, blockpos1);
}
}
}
else {
} else {
return stack;
}
@ -114,11 +113,9 @@ public class ItemSigilLava extends ItemSigilBase {
public boolean canPlaceLava(World world, BlockPos blockPos) {
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial().isSolid()) {
return false;
}
else if ((world.getBlockState(blockPos).getBlock() == Blocks.lava || world.getBlockState(blockPos).getBlock() == Blocks.flowing_lava) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) {
} else if ((world.getBlockState(blockPos).getBlock() == Blocks.lava || world.getBlockState(blockPos).getBlock() == Blocks.flowing_lava) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0) {
return false;
}
else {
} else {
world.setBlockState(blockPos, Blocks.lava.getBlockState().getBaseState());
return true;
}

View file

@ -47,8 +47,7 @@ public class ItemSigilVoid extends ItemSigilBase {
return stack;
}
}
}
else {
} else {
return stack;
}

View file

@ -51,8 +51,7 @@ public class ItemSigilWater extends ItemSigilBase {
this.tryPlaceWater(world, blockpos1);
}
}
}
else {
} else {
return stack;
}
@ -123,8 +122,7 @@ public class ItemSigilWater extends ItemSigilBase {
if (!worldIn.isAirBlock(pos) && !flag) {
return false;
}
else {
} else {
if (worldIn.provider.doesWaterVaporize()) {
int i = pos.getX();
int j = pos.getY();
@ -134,8 +132,7 @@ public class ItemSigilWater extends ItemSigilBase {
for (int l = 0; l < 8; ++l) {
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D, 0);
}
}
else {
} else {
if (!worldIn.isRemote && flag && !material.isLiquid()) {
worldIn.destroyBlock(pos, true);
}

View file

@ -1,6 +1,6 @@
package WayofTime.bloodmagic.network;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.util.ChatUtil;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity;
@ -11,7 +11,7 @@ import net.minecraftforge.fml.relauncher.Side;
public class BloodMagicPacketHandler {
public static final SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(BloodMagic.MODID);
public static final SimpleNetworkWrapper INSTANCE = new SimpleNetworkWrapper(Constants.Mod.MODID);
public static void init() {
INSTANCE.registerMessage(ChatUtil.PacketNoSpamChat.Handler.class, ChatUtil.PacketNoSpamChat.class, 0, Side.CLIENT);

View file

@ -1,6 +1,6 @@
package WayofTime.bloodmagic.proxy;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.registry.ModItems;
import WayofTime.bloodmagic.util.helper.InventoryRenderHelper;
@ -15,8 +15,8 @@ public class ClientProxy extends CommonProxy {
ModBlocks.initRenders();
ModItems.initRenders();
OBJLoader.instance.addDomain(BloodMagic.MODID);
ModelLoader.setCustomModelResourceLocation(InventoryRenderHelper.getItemFromBlock(ModBlocks.altar), 0, new ModelResourceLocation(BloodMagic.DOMAIN + "BlockAltar", "inventory"));
OBJLoader.instance.addDomain(Constants.Mod.MODID);
ModelLoader.setCustomModelResourceLocation(InventoryRenderHelper.getItemFromBlock(ModBlocks.altar), 0, new ModelResourceLocation(Constants.Mod.DOMAIN + "BlockAltar", "inventory"));
}
@Override

View file

@ -1,18 +1,19 @@
package WayofTime.bloodmagic.registry;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.ConfigHandler;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.block.*;
import WayofTime.bloodmagic.item.block.*;
import WayofTime.bloodmagic.tile.TileAltar;
import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
import WayofTime.bloodmagic.tile.TilePlinth;
import WayofTime.bloodmagic.util.helper.InventoryRenderHelper;
import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.ConfigHandler;
import WayofTime.bloodmagic.tile.TileAltar;
import WayofTime.bloodmagic.tile.TileImperfectRitualStone;
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
import WayofTime.bloodmagic.util.helper.InventoryRenderHelper;
public class ModBlocks {
public static Block altar;
@ -21,6 +22,7 @@ public class ModBlocks {
public static Block ritualStone;
public static Block testSpellBlock;
public static Block pedestal;
public static Block teleposer;
public static Block lifeEssence;
@ -37,16 +39,17 @@ public class ModBlocks {
ritualStone = registerBlock(new BlockRitualStone(), ItemBlockRitualStone.class);
testSpellBlock = registerBlock(new BlockTestSpellBlock());
pedestal = registerBlock(new BlockPedestal(), ItemBlockPedestal.class);
teleposer = registerBlock(new BlockTeleposer());
bloodStoneBrick = registerBlock(new BlockBloodStoneBrick(), ItemBlockBloodStoneBrick.class);
initTiles();
}
public static void initTiles() {
GameRegistry.registerTileEntity(TileAltar.class, BloodMagic.MODID + ":" + TileAltar.class.getSimpleName());
GameRegistry.registerTileEntity(TileImperfectRitualStone.class, BloodMagic.MODID + ":" + TileImperfectRitualStone.class.getSimpleName());
GameRegistry.registerTileEntity(TileMasterRitualStone.class, BloodMagic.MODID + ":" + TileMasterRitualStone.class.getSimpleName());
GameRegistry.registerTileEntity(TilePlinth.class, BloodMagic.MODID + ":" + TilePlinth.class.getSimpleName());
GameRegistry.registerTileEntity(TileAltar.class, Constants.Mod.MODID + ":" + TileAltar.class.getSimpleName());
GameRegistry.registerTileEntity(TileImperfectRitualStone.class, Constants.Mod.MODID + ":" + TileImperfectRitualStone.class.getSimpleName());
GameRegistry.registerTileEntity(TileMasterRitualStone.class, Constants.Mod.MODID + ":" + TileMasterRitualStone.class.getSimpleName());
GameRegistry.registerTileEntity(TilePlinth.class, Constants.Mod.MODID + ":" + TilePlinth.class.getSimpleName());
}
public static void initRenders() {
@ -76,6 +79,7 @@ public class ModBlocks {
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(bloodStoneBrick), 1);
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(pedestal), 0);
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(pedestal), 1);
renderHelper.itemRender(InventoryRenderHelper.getItemFromBlock(teleposer));
}
private static Block registerBlock(Block block, Class<? extends ItemBlock> itemBlock, String name) {

View file

@ -1,12 +1,9 @@
package WayofTime.bloodmagic.registry;
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
import WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.ConfigHandler;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.orb.BloodOrb;
import WayofTime.bloodmagic.api.registry.OrbRegistry;
import WayofTime.bloodmagic.item.ItemActivationCrystal;
@ -14,12 +11,12 @@ import WayofTime.bloodmagic.item.ItemBloodOrb;
import WayofTime.bloodmagic.item.ItemBucketEssence;
import WayofTime.bloodmagic.item.ItemSacrificialDagger;
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
import WayofTime.bloodmagic.item.sigil.ItemSigilAir;
import WayofTime.bloodmagic.item.sigil.ItemSigilDivination;
import WayofTime.bloodmagic.item.sigil.ItemSigilLava;
import WayofTime.bloodmagic.item.sigil.ItemSigilVoid;
import WayofTime.bloodmagic.item.sigil.ItemSigilWater;
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
import WayofTime.bloodmagic.item.gear.ItemPackSelfSacrifice;
import WayofTime.bloodmagic.item.sigil.*;
import WayofTime.bloodmagic.util.helper.InventoryRenderHelper;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class ModItems {
@ -44,7 +41,7 @@ public class ModItems {
public static Item sigilWater;
public static Item sigilLava;
public static Item sigilVoid;
public static Item livingArmourHelmet;
public static Item livingArmourChest;
public static Item livingArmourLegs;
@ -79,7 +76,7 @@ public class ModItems {
sigilWater = registerItem(new ItemSigilWater());
sigilLava = registerItem(new ItemSigilLava());
sigilVoid = registerItem(new ItemSigilVoid());
livingArmourHelmet = registerItem(new ItemLivingArmour(0), "ItemLivingArmourHelmet");
livingArmourChest = registerItem(new ItemLivingArmour(1), "ItemLivingArmourChest");
livingArmourLegs = registerItem(new ItemLivingArmour(2), "ItemLivingArmourLegs");
@ -90,12 +87,12 @@ public class ModItems {
InventoryRenderHelper renderHelper = BloodMagic.instance.getRenderHelper();
renderHelper.itemRenderAll(bloodOrb);
OrbRegistry.registerOrbTexture(orbWeak, BloodMagic.DOMAIN + "ItemBloodOrbWeak");
OrbRegistry.registerOrbTexture(orbApprentice, BloodMagic.DOMAIN + "ItemBloodOrbApprentice");
OrbRegistry.registerOrbTexture(orbMagician, BloodMagic.DOMAIN + "ItemBloodOrbMagician");
OrbRegistry.registerOrbTexture(orbMaster, BloodMagic.DOMAIN + "ItemBloodOrbMaster");
OrbRegistry.registerOrbTexture(orbArchmage, BloodMagic.DOMAIN + "ItemBloodOrbArchmage");
OrbRegistry.registerOrbTexture(orbTranscendent, BloodMagic.DOMAIN + "ItemBloodOrbTranscendent");
OrbRegistry.registerOrbTexture(orbWeak, Constants.Mod.DOMAIN + "ItemBloodOrbWeak");
OrbRegistry.registerOrbTexture(orbApprentice, Constants.Mod.DOMAIN + "ItemBloodOrbApprentice");
OrbRegistry.registerOrbTexture(orbMagician, Constants.Mod.DOMAIN + "ItemBloodOrbMagician");
OrbRegistry.registerOrbTexture(orbMaster, Constants.Mod.DOMAIN + "ItemBloodOrbMaster");
OrbRegistry.registerOrbTexture(orbArchmage, Constants.Mod.DOMAIN + "ItemBloodOrbArchmage");
OrbRegistry.registerOrbTexture(orbTranscendent, Constants.Mod.DOMAIN + "ItemBloodOrbTranscendent");
renderHelper.itemRender(bucketEssence);
@ -113,7 +110,7 @@ public class ModItems {
renderHelper.itemRender(sigilWater);
renderHelper.itemRender(sigilLava);
renderHelper.itemRender(sigilVoid);
renderHelper.itemRender(livingArmourHelmet);
renderHelper.itemRender(livingArmourChest);
renderHelper.itemRender(livingArmourLegs);

View file

@ -3,6 +3,8 @@ package WayofTime.bloodmagic.registry;
import WayofTime.bloodmagic.api.altar.AltarRecipe;
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
import WayofTime.bloodmagic.api.registry.OrbRegistry;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@ -12,12 +14,8 @@ public class ModRecipes {
}
public static void addAltarRecipes() {
// AltarRecipeRegistry.registerRecipe(new AltarRecipe(new ItemStackWrapper(Items.diamond), new ItemStackWrapper(ModItems.bloodOrb, 0), EnumAltarTier.ONE, 2000, 2, 1, false));
AltarRecipeRegistry.registerRecipe(new AltarRecipe(new ItemStack(Items.diamond), new ItemStack(ModItems.bloodOrb, 0), EnumAltarTier.ONE, 2000, 2, 1, false));
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 1), new ItemStack(Items.emerald), 2, 5000, 5, 5, false);
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 2), new ItemStack(Blocks.gold_block), 3, 25000, 20, 20, false);
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 3), new ItemStack(ModItems.weakBloodShard), 4, 40000, 30, 50, false);
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 4), new ItemStack(ModItems.demonBloodShard), 5, 75000, 50, 100, false);
// AltarRecipeRegistry.registerRecipe(new ItemStack(ModItems.bloodOrb, 5), new ItemStack(ModBlocks.blockCrystal), 6, 200000, 100, 200, false);
AltarRecipeRegistry.registerRecipe(new AltarRecipe(new ItemStack(Items.diamond), OrbRegistry.getOrbStack(ModItems.orbWeak), EnumAltarTier.ONE, 2000, 2, 1, false));
AltarRecipeRegistry.registerRecipe(new AltarRecipe(new ItemStack(Items.emerald), OrbRegistry.getOrbStack(ModItems.orbApprentice), EnumAltarTier.TWO, 5000, 2, 1, false));
AltarRecipeRegistry.registerRecipe(new AltarRecipe(new ItemStack(Blocks.gold_block), OrbRegistry.getOrbStack(ModItems.orbMagician), EnumAltarTier.THREE, 25000, 2, 1, false));
}
}

View file

@ -3,7 +3,6 @@ package WayofTime.bloodmagic.ritual.imperfect;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.ritual.imperfect.IImperfectRitualStone;
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;

View file

@ -3,7 +3,6 @@ package WayofTime.bloodmagic.ritual.imperfect;
import WayofTime.bloodmagic.api.BlockStack;
import WayofTime.bloodmagic.api.ritual.imperfect.IImperfectRitualStone;
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;

View file

@ -2,7 +2,7 @@ package WayofTime.bloodmagic.tile;
import WayofTime.bloodmagic.altar.BloodAltar;
import WayofTime.bloodmagic.api.BloodMagicAPI;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.altar.AltarRecipe;
import WayofTime.bloodmagic.api.altar.AltarUpgrade;
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
@ -12,6 +12,7 @@ import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.block.BlockLifeEssence;
import com.google.common.base.Enums;
import com.google.common.base.Strings;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -23,14 +24,13 @@ import net.minecraftforge.fluids.*;
public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlayerListBox, IFluidTank, IFluidHandler {
public boolean isActive;
protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
protected FluidStack fluidInput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
private EnumAltarTier altarTier = EnumAltarTier.ONE;
private AltarUpgrade upgrade = new AltarUpgrade();
private int capacity = FluidContainerRegistry.BUCKET_VOLUME * 10;
private FluidStack fluid = new FluidStack(BloodMagicAPI.getLifeEssence(), 0);
protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
protected FluidStack fluidInput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
private int liquidRequired; //mB
private boolean canBeFilled;
private int consumptionRate;
@ -47,9 +47,6 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
private boolean isResultBlock;
private int bufferCapacity = FluidContainerRegistry.BUCKET_VOLUME;
private int progress;
public boolean isActive = false;
private int lockdownDuration;
private int demonBloodDuration;
@ -65,41 +62,41 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
if (!tagCompound.hasKey(NBTHolder.NBT_EMPTY)) {
if (!tagCompound.hasKey(Constants.NBT.EMPTY)) {
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound);
if (fluid != null)
setMainFluid(fluid);
FluidStack fluidOut = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger(NBTHolder.NBT_OUTPUT_AMOUNT));
FluidStack fluidOut = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger(Constants.NBT.OUTPUT_AMOUNT));
setOutputFluid(fluidOut);
FluidStack fluidIn = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger(NBTHolder.NBT_INPUT_AMOUNT));
FluidStack fluidIn = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger(Constants.NBT.INPUT_AMOUNT));
setInputFluid(fluidIn);
}
altarTier = Enums.getIfPresent(EnumAltarTier.class, tagCompound.getString(NBTHolder.NBT_ALTAR_TIER)).or(EnumAltarTier.ONE);
isActive = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_ACTIVE);
liquidRequired = tagCompound.getInteger(NBTHolder.NBT_ALTAR_LIQUID_REQ);
canBeFilled = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_FILLABLE);
isUpgraded = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_UPGRADED);
consumptionRate = tagCompound.getInteger(NBTHolder.NBT_ALTAR_CONSUMPTION_RATE);
drainRate = tagCompound.getInteger(NBTHolder.NBT_ALTAR_DRAIN_RATE);
consumptionMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_CONSUMPTION_MULTIPLIER);
efficiencyMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_EFFICIENCY_MULTIPLIER);
selfSacrificeEfficiencyMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_SELF_SACRIFICE_MULTIPLIER);
sacrificeEfficiencyMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_SACRIFICE_MULTIPLIER);
capacityMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_CAPACITY_MULTIPLIER);
orbCapacityMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_ORB_CAPACITY_MULTIPLIER);
dislocationMultiplier = tagCompound.getFloat(NBTHolder.NBT_ALTAR_DISLOCATION_MULTIPLIER);
capacity = tagCompound.getInteger(NBTHolder.NBT_ALTAR_CAPACITY);
bufferCapacity = tagCompound.getInteger(NBTHolder.NBT_ALTAR_BUFFER_CAPACITY);
progress = tagCompound.getInteger(NBTHolder.NBT_ALTAR_PROGRESS);
isResultBlock = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_IS_RESULT_BLOCK);
lockdownDuration = tagCompound.getInteger(NBTHolder.NBT_ALTAR_LOCKDOWN_DURATION);
accelerationUpgrades = tagCompound.getInteger(NBTHolder.NBT_ALTAR_ACCELERATION_UPGRADES);
demonBloodDuration = tagCompound.getInteger(NBTHolder.NBT_ALTAR_DEMON_BLOOD_DURATION);
cooldownAfterCrafting = tagCompound.getInteger(NBTHolder.NBT_ALTAR_COOLDOWN_AFTER_CRAFTING);
altarTier = Enums.getIfPresent(EnumAltarTier.class, tagCompound.getString(Constants.NBT.ALTAR_TIER)).or(EnumAltarTier.ONE);
isActive = tagCompound.getBoolean(Constants.NBT.ALTAR_ACTIVE);
liquidRequired = tagCompound.getInteger(Constants.NBT.ALTAR_LIQUID_REQ);
canBeFilled = tagCompound.getBoolean(Constants.NBT.ALTAR_FILLABLE);
isUpgraded = tagCompound.getBoolean(Constants.NBT.ALTAR_UPGRADED);
consumptionRate = tagCompound.getInteger(Constants.NBT.ALTAR_CONSUMPTION_RATE);
drainRate = tagCompound.getInteger(Constants.NBT.ALTAR_DRAIN_RATE);
consumptionMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_CONSUMPTION_MULTIPLIER);
efficiencyMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_EFFICIENCY_MULTIPLIER);
selfSacrificeEfficiencyMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_SELF_SACRIFICE_MULTIPLIER);
sacrificeEfficiencyMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_SACRIFICE_MULTIPLIER);
capacityMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_CAPACITY_MULTIPLIER);
orbCapacityMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_ORB_CAPACITY_MULTIPLIER);
dislocationMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_DISLOCATION_MULTIPLIER);
capacity = tagCompound.getInteger(Constants.NBT.ALTAR_CAPACITY);
bufferCapacity = tagCompound.getInteger(Constants.NBT.ALTAR_BUFFER_CAPACITY);
progress = tagCompound.getInteger(Constants.NBT.ALTAR_PROGRESS);
isResultBlock = tagCompound.getBoolean(Constants.NBT.ALTAR_IS_RESULT_BLOCK);
lockdownDuration = tagCompound.getInteger(Constants.NBT.ALTAR_LOCKDOWN_DURATION);
accelerationUpgrades = tagCompound.getInteger(Constants.NBT.ALTAR_ACCELERATION_UPGRADES);
demonBloodDuration = tagCompound.getInteger(Constants.NBT.ALTAR_DEMON_BLOOD_DURATION);
cooldownAfterCrafting = tagCompound.getInteger(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING);
}
@Override
@ -109,36 +106,36 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
if (fluid != null)
fluid.writeToNBT(tagCompound);
else
tagCompound.setString(NBTHolder.NBT_EMPTY, "");
tagCompound.setString(Constants.NBT.EMPTY, "");
if (fluidOutput != null)
tagCompound.setInteger(NBTHolder.NBT_OUTPUT_AMOUNT, fluidOutput.amount);
tagCompound.setInteger(Constants.NBT.OUTPUT_AMOUNT, fluidOutput.amount);
if (fluidInput != null)
tagCompound.setInteger(NBTHolder.NBT_INPUT_AMOUNT, fluidInput.amount);
tagCompound.setInteger(Constants.NBT.INPUT_AMOUNT, fluidInput.amount);
tagCompound.setString(NBTHolder.NBT_ALTAR_TIER, altarTier.name());
tagCompound.setBoolean(NBTHolder.NBT_ALTAR_ACTIVE, isActive);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_LIQUID_REQ, liquidRequired);
tagCompound.setBoolean(NBTHolder.NBT_ALTAR_FILLABLE, canBeFilled);
tagCompound.setBoolean(NBTHolder.NBT_ALTAR_UPGRADED, isUpgraded);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_CONSUMPTION_RATE, consumptionRate);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_DRAIN_RATE, drainRate);
tagCompound.setFloat(NBTHolder.NBT_ALTAR_CONSUMPTION_MULTIPLIER, consumptionMultiplier);
tagCompound.setFloat(NBTHolder.NBT_ALTAR_EFFICIENCY_MULTIPLIER, efficiencyMultiplier);
tagCompound.setFloat(NBTHolder.NBT_ALTAR_SACRIFICE_MULTIPLIER, sacrificeEfficiencyMultiplier);
tagCompound.setFloat(NBTHolder.NBT_ALTAR_SELF_SACRIFICE_MULTIPLIER, selfSacrificeEfficiencyMultiplier);
tagCompound.setBoolean(NBTHolder.NBT_ALTAR_IS_RESULT_BLOCK, isResultBlock);
tagCompound.setFloat(NBTHolder.NBT_ALTAR_CAPACITY_MULTIPLIER, capacityMultiplier);
tagCompound.setFloat(NBTHolder.NBT_ALTAR_ORB_CAPACITY_MULTIPLIER, orbCapacityMultiplier);
tagCompound.setFloat(NBTHolder.NBT_ALTAR_DISLOCATION_MULTIPLIER, dislocationMultiplier);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_CAPACITY, capacity);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_PROGRESS, progress);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_BUFFER_CAPACITY, bufferCapacity);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_LOCKDOWN_DURATION, lockdownDuration);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_ACCELERATION_UPGRADES, accelerationUpgrades);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_DEMON_BLOOD_DURATION, demonBloodDuration);
tagCompound.setInteger(NBTHolder.NBT_ALTAR_COOLDOWN_AFTER_CRAFTING, cooldownAfterCrafting);
tagCompound.setString(Constants.NBT.ALTAR_TIER, altarTier.name());
tagCompound.setBoolean(Constants.NBT.ALTAR_ACTIVE, isActive);
tagCompound.setInteger(Constants.NBT.ALTAR_LIQUID_REQ, liquidRequired);
tagCompound.setBoolean(Constants.NBT.ALTAR_FILLABLE, canBeFilled);
tagCompound.setBoolean(Constants.NBT.ALTAR_UPGRADED, isUpgraded);
tagCompound.setInteger(Constants.NBT.ALTAR_CONSUMPTION_RATE, consumptionRate);
tagCompound.setInteger(Constants.NBT.ALTAR_DRAIN_RATE, drainRate);
tagCompound.setFloat(Constants.NBT.ALTAR_CONSUMPTION_MULTIPLIER, consumptionMultiplier);
tagCompound.setFloat(Constants.NBT.ALTAR_EFFICIENCY_MULTIPLIER, efficiencyMultiplier);
tagCompound.setFloat(Constants.NBT.ALTAR_SACRIFICE_MULTIPLIER, sacrificeEfficiencyMultiplier);
tagCompound.setFloat(Constants.NBT.ALTAR_SELF_SACRIFICE_MULTIPLIER, selfSacrificeEfficiencyMultiplier);
tagCompound.setBoolean(Constants.NBT.ALTAR_IS_RESULT_BLOCK, isResultBlock);
tagCompound.setFloat(Constants.NBT.ALTAR_CAPACITY_MULTIPLIER, capacityMultiplier);
tagCompound.setFloat(Constants.NBT.ALTAR_ORB_CAPACITY_MULTIPLIER, orbCapacityMultiplier);
tagCompound.setFloat(Constants.NBT.ALTAR_DISLOCATION_MULTIPLIER, dislocationMultiplier);
tagCompound.setInteger(Constants.NBT.ALTAR_CAPACITY, capacity);
tagCompound.setInteger(Constants.NBT.ALTAR_PROGRESS, progress);
tagCompound.setInteger(Constants.NBT.ALTAR_BUFFER_CAPACITY, bufferCapacity);
tagCompound.setInteger(Constants.NBT.ALTAR_LOCKDOWN_DURATION, lockdownDuration);
tagCompound.setInteger(Constants.NBT.ALTAR_ACCELERATION_UPGRADES, accelerationUpgrades);
tagCompound.setInteger(Constants.NBT.ALTAR_DEMON_BLOOD_DURATION, demonBloodDuration);
tagCompound.setInteger(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING, cooldownAfterCrafting);
}
@Override
@ -151,26 +148,24 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
if (lockdownDuration > 0)
lockdownDuration--;
if (!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0) {
{
IBlockState block = worldObj.getBlockState(new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()));
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()), block, block.getBlock());
block = worldObj.getBlockState(new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()));
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX() - 1, this.pos.getY(), this.pos.getZ()), block, block.getBlock());
block = worldObj.getBlockState(new BlockPos(this.pos.getX(), this.pos.getY() + 1, this.pos.getZ()));
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX() , this.pos.getY() + 1, this.pos.getZ()), block, block.getBlock());
block = worldObj.getBlockState(new BlockPos(this.pos.getX(), this.pos.getY() - 1, this.pos.getZ()));
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX(), this.pos.getY() - 1, this.pos.getZ()), block, block.getBlock());
block = worldObj.getBlockState(new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() + 1));
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() + 1), block, block.getBlock());
block = worldObj.getBlockState(new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1));
block.getBlock().onNeighborBlockChange(worldObj, new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1), block, block.getBlock());
}
if (!getWorld().isRemote && getWorld().getWorldTime() % 20 == 0) {
IBlockState block = getWorld().getBlockState(new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()));
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()), block, block.getBlock());
block = getWorld().getBlockState(new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()));
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX() - 1, this.pos.getY(), this.pos.getZ()), block, block.getBlock());
block = getWorld().getBlockState(new BlockPos(this.pos.getX(), this.pos.getY() + 1, this.pos.getZ()));
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX(), this.pos.getY() + 1, this.pos.getZ()), block, block.getBlock());
block = getWorld().getBlockState(new BlockPos(this.pos.getX(), this.pos.getY() - 1, this.pos.getZ()));
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX(), this.pos.getY() - 1, this.pos.getZ()), block, block.getBlock());
block = getWorld().getBlockState(new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() + 1));
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() + 1), block, block.getBlock());
block = getWorld().getBlockState(new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1));
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1), block, block.getBlock());
}
if (getWorld().getTotalWorldTime() % (Math.max(20 - this.accelerationUpgrades, 1)) == 0)
everySecond();
if (getWorld().getTotalWorldTime() % 100 == 0 && (this.isActive || this.cooldownAfterCrafting <= 0))
if (getWorld().getTotalWorldTime() % 100 == 0 && (this.isActive || this.cooldownAfterCrafting <= 0))
everyFiveSeconds();
updat();
@ -196,17 +191,16 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
@Override
public void startCycle() {
if (worldObj != null)
worldObj.markBlockForUpdate(pos);
if (getWorld() != null)
getWorld().markBlockForUpdate(pos);
checkTier();
if (fluid == null || fluid.amount <= 0)
return;
if (!isActive) {
if (!isActive)
progress = 0;
}
if (getStackInSlot(0) != null) {
// Do recipes
@ -232,19 +226,17 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
private void updat() {
if (!isActive) {
if (cooldownAfterCrafting > 0) {
if (cooldownAfterCrafting > 0)
cooldownAfterCrafting--;
}
return;
}
if (getStackInSlot(0) == null) {
if (getStackInSlot(0) == null)
return;
}
int worldTime = (int) (worldObj.getWorldTime() % 24000);
int worldTime = (int) (getWorld().getWorldTime() % 24000);
if (worldObj.isRemote)
if (getWorld().isRemote)
return;
float f = 1.0F;
@ -257,57 +249,51 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
int stackSize = getStackInSlot(0).stackSize;
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
if (liquidDrained > (liquidRequired * stackSize - progress)) {
if (liquidDrained > (liquidRequired * stackSize - progress))
liquidDrained = liquidRequired * stackSize - progress;
}
fluid.amount = fluid.amount - liquidDrained;
progress += liquidDrained;
if (worldTime % 4 == 0) {
worldObj.spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
}
if (worldTime % 4 == 0)
getWorld().spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
if (progress >= liquidRequired * stackSize) {
ItemStack result = this.result;
if (result != null) {
if (result != null)
result.stackSize *= stackSize;
}
setInventorySlotContents(0, result);
progress = 0;
for (int i = 0; i < 8; i++) {
worldObj.spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
}
for (int i = 0; i < 8; i++)
getWorld().spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
this.isActive = false;
}
} else if (progress > 0) {
progress -= (int) (efficiencyMultiplier * drainRate);
if (worldTime % 2 == 0) {
worldObj.spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
}
if (worldTime % 2 == 0)
getWorld().spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
}
} else {
ItemStack returnedItem = getStackInSlot(0);
if (!(returnedItem.getItem() instanceof IBloodOrb)) {
if (!(returnedItem.getItem() instanceof IBloodOrb))
return;
}
IBloodOrb item = (IBloodOrb) (returnedItem.getItem());
NBTTagCompound itemTag = returnedItem.getTagCompound();
if (itemTag == null) {
if (itemTag == null)
return;
}
String ownerName = itemTag.getString(NBTHolder.NBT_OWNER);
String ownerName = itemTag.getString(Constants.NBT.OWNER_NAME);
if (ownerName.equals("")) {
if (Strings.isNullOrEmpty(ownerName))
return;
}
if (fluid != null && fluid.amount >= 1) {
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
@ -316,14 +302,12 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
fluid.amount = fluid.amount - drain;
if (worldTime % 4 == 0) {
worldObj.spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
}
if (worldTime % 4 == 0)
getWorld().spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
}
}
if (worldObj != null) {
worldObj.markBlockForUpdate(pos);
}
if (getWorld() != null)
getWorld().markBlockForUpdate(pos);
}
private void checkTier() {
@ -335,12 +319,12 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
if (tier.equals(EnumAltarTier.ONE))
upgrade = new AltarUpgrade();
else
upgrade = BloodAltar.getUpgrades(worldObj, pos, tier);
upgrade = BloodAltar.getUpgrades(getWorld(), pos, tier);
if (this.fluid.amount > this.capacity)
this.fluid.amount = this.capacity;
worldObj.markBlockForUpdate(pos);
getWorld().markBlockForUpdate(pos);
}
public int fillMainTank(int amount) {
@ -365,17 +349,12 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
return slot == 0;
}
public TileAltar setUpgrade(AltarUpgrade upgrade) {
this.upgrade = upgrade;
return this;
}
public AltarUpgrade getUpgrade() {
return upgrade;
}
public TileAltar setTier(EnumAltarTier tier) {
this.altarTier = tier;
public TileAltar setUpgrade(AltarUpgrade upgrade) {
this.upgrade = upgrade;
return this;
}
@ -394,6 +373,11 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
return altarTier;
}
public TileAltar setTier(EnumAltarTier tier) {
this.altarTier = tier;
return this;
}
@Override
public int getProgress() {
return progress;

View file

@ -19,12 +19,11 @@ import net.minecraft.world.World;
public class TileInventory extends TileEntity implements IInventory {
protected int[] syncedSlots = new int[0];
private ItemStack[] inventory;
private int size;
private String name;
protected int[] syncedSlots = new int[0];
public TileInventory(int size, String name) {
this.inventory = new ItemStack[size];
this.size = size;
@ -49,7 +48,7 @@ public class TileInventory extends TileEntity implements IInventory {
for (int i = 0; i < tags.tagCount(); i++) {
if (!isSyncedSlot(i)) {
NBTTagCompound data = tags.getCompoundTagAt(i);
byte j = data.getByte("Slot") ;
byte j = data.getByte("Slot");
if (j >= 0 && j < inventory.length) {
inventory[j] = ItemStack.loadItemStackFromNBT(data);
@ -75,6 +74,24 @@ public class TileInventory extends TileEntity implements IInventory {
tagCompound.setTag("Items", tags);
}
@Override
public Packet getDescriptionPacket() {
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return new S35PacketUpdateTileEntity(getPos(), -999, nbt);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
super.onDataPacket(net, pkt);
readFromNBT(pkt.getNbtCompound());
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) {
return oldState.getBlock() != newState.getBlock();
}
public void dropItems() {
InventoryHelper.dropInventoryItems(getWorld(), getPos(), this);
}
@ -196,25 +213,4 @@ public class TileInventory extends TileEntity implements IInventory {
public IChatComponent getDisplayName() {
return new ChatComponentTranslation("tile.BloodMagic." + name + ".name");
}
@Override
public Packet getDescriptionPacket()
{
NBTTagCompound nbt = new NBTTagCompound();
writeToNBT(nbt);
return new S35PacketUpdateTileEntity(getPos(), -999, nbt);
}
@Override
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt)
{
super.onDataPacket(net, pkt);
readFromNBT(pkt.getNbtCompound());
}
@Override
public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState)
{
return oldState.getBlock() != newState.getBlock();
}
}

View file

@ -1,11 +1,12 @@
package WayofTime.bloodmagic.tile;
import WayofTime.bloodmagic.api.NBTHolder;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.event.RitualEvent;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.registry.RitualRegistry;
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import WayofTime.bloodmagic.api.util.helper.RitualHelper;
import WayofTime.bloodmagic.item.ItemActivationCrystal;
@ -38,15 +39,15 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
private EnumFacing direction;
public void readClientNBT(NBTTagCompound tag) {
currentRitual = RitualRegistry.getRitualForId(tag.getString(NBTHolder.NBT_CURRENTRITUAL));
active = tag.getBoolean(NBTHolder.NBT_RUNNING);
activeTime = tag.getInteger(NBTHolder.NBT_RUNTIME);
currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL));
active = tag.getBoolean(Constants.NBT.IS_RUNNING);
activeTime = tag.getInteger(Constants.NBT.RUNTIME);
}
public void writeClientNBT(NBTTagCompound tag) {
tag.setString(NBTHolder.NBT_CURRENTRITUAL, RitualRegistry.getIdForRitual(currentRitual));
tag.setBoolean(NBTHolder.NBT_RUNNING, active);
tag.setInteger(NBTHolder.NBT_RUNTIME, activeTime);
tag.setString(Constants.NBT.CURRENT_RITUAL, RitualRegistry.getIdForRitual(currentRitual));
tag.setBoolean(Constants.NBT.IS_RUNNING, active);
tag.setInteger(Constants.NBT.RUNTIME, activeTime);
}
@Override
@ -56,8 +57,8 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
@Override
public boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator) {
activationCrystal = NBTHolder.checkNBT(activationCrystal);
String crystalOwner = activationCrystal.getTagCompound().getString(NBTHolder.NBT_OWNER);
activationCrystal = NBTHelper.checkNBT(activationCrystal);
String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_NAME);
Ritual ritual = RitualRegistry.getRitualForId("");
if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) {
@ -93,13 +94,13 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
}
@Override
public void setCooldown(int cooldown) {
this.cooldown = cooldown;
public int getCooldown() {
return cooldown;
}
@Override
public int getCooldown() {
return cooldown;
public void setCooldown(int cooldown) {
this.cooldown = cooldown;
}
@Override

View file

@ -17,50 +17,6 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
public class ChatUtil {
/**
* @author tterrag1098
*
* Ripped from EnderCore (and slightly altered)
*/
public static class PacketNoSpamChat implements IMessage {
private IChatComponent[] chatLines;
public PacketNoSpamChat() {
chatLines = new IChatComponent[0];
}
private PacketNoSpamChat(IChatComponent... lines) {
// this is guaranteed to be >1 length by accessing methods
this.chatLines = lines;
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(chatLines.length);
for (IChatComponent c : chatLines) {
ByteBufUtils.writeUTF8String(buf, IChatComponent.Serializer.componentToJson(c));
}
}
@Override
public void fromBytes(ByteBuf buf) {
chatLines = new IChatComponent[buf.readInt()];
for (int i = 0; i < chatLines.length; i++) {
chatLines[i] = IChatComponent.Serializer.jsonToComponent(ByteBufUtils.readUTF8String(buf));
}
}
public static class Handler implements IMessageHandler<PacketNoSpamChat, IMessage> {
@Override
public IMessage onMessage(PacketNoSpamChat message, MessageContext ctx) {
sendNoSpamMessages(message.chatLines);
return null;
}
}
}
private static final int DELETION_ID = 2525277;
private static int lastAdded;
@ -78,8 +34,8 @@ public class ChatUtil {
/**
* Returns a standard {@link ChatComponentText} for the given {@link String}.
*
* @param s
* The string to wrap.
* @param s The string to wrap.
*
* @return An {@link IChatComponent} containing the string.
*/
public static IChatComponent wrap(String s) {
@ -100,10 +56,8 @@ public class ChatUtil {
/**
* Returns a translatable chat component for the given string and format args.
*
* @param s
* The string to format
* @param args
* The args to apply to the format
* @param s The string to format
* @param args The args to apply to the format
*/
public static IChatComponent wrapFormatted(String s, Object... args) {
return new ChatComponentTranslation(s, args);
@ -112,10 +66,8 @@ public class ChatUtil {
/**
* Simply sends the passed lines to the player in a chat message.
*
* @param player
* The player to send the chat to
* @param lines
* The lines to send
* @param player The player to send the chat to
* @param lines The lines to send
*/
public static void sendChat(EntityPlayer player, String... lines) {
sendChat(player, wrap(lines));
@ -133,10 +85,8 @@ public class ChatUtil {
/**
* Sends all passed chat components to the player.
*
* @param player
* The player to send the chat lines to.
* @param lines
* The {@link IChatComponent chat components} to send.yes
* @param player The player to send the chat lines to.
* @param lines The {@link IChatComponent chat components} to send.yes
*/
public static void sendChat(EntityPlayer player, IChatComponent... lines) {
for (IChatComponent c : lines) {
@ -157,8 +107,8 @@ public class ChatUtil {
* Same as {@link #sendNoSpamClient(IChatComponent...)}, but wraps the Strings
* automatically.
*
* @param lines
* The chat lines to send
* @param lines The chat lines to send
*
* @see #wrap(String)
*/
public static void sendNoSpamClient(String... lines) {
@ -223,16 +173,58 @@ public class ChatUtil {
/**
* Sends a chat message to the client, deleting past messages also sent via
* this method.
* <p>
* <p/>
* Credit to RWTema for the idea
*
* @param player
* The player to send the chat message to
* @param lines
* The chat lines to send.
* @param player The player to send the chat message to
* @param lines The chat lines to send.
*/
public static void sendNoSpam(EntityPlayerMP player, IChatComponent... lines) {
if (lines.length > 0)
BloodMagicPacketHandler.INSTANCE.sendTo(new PacketNoSpamChat(lines), player);
}
/**
* @author tterrag1098
* <p/>
* Ripped from EnderCore (and slightly altered)
*/
public static class PacketNoSpamChat implements IMessage {
private IChatComponent[] chatLines;
public PacketNoSpamChat() {
chatLines = new IChatComponent[0];
}
private PacketNoSpamChat(IChatComponent... lines) {
// this is guaranteed to be >1 length by accessing methods
this.chatLines = lines;
}
@Override
public void toBytes(ByteBuf buf) {
buf.writeInt(chatLines.length);
for (IChatComponent c : chatLines) {
ByteBufUtils.writeUTF8String(buf, IChatComponent.Serializer.componentToJson(c));
}
}
@Override
public void fromBytes(ByteBuf buf) {
chatLines = new IChatComponent[buf.readInt()];
for (int i = 0; i < chatLines.length; i++) {
chatLines[i] = IChatComponent.Serializer.jsonToComponent(ByteBufUtils.readUTF8String(buf));
}
}
public static class Handler implements IMessageHandler<PacketNoSpamChat, IMessage> {
@Override
public IMessage onMessage(PacketNoSpamChat message, MessageContext ctx) {
sendNoSpamMessages(message.chatLines);
return null;
}
}
}
}

View file

@ -10,9 +10,9 @@ public class Utils {
public static boolean isInteger(String integer) {
try {
Integer.parseInt(integer);
} catch(NumberFormatException e) {
} catch (NumberFormatException e) {
return false;
} catch(NullPointerException e) {
} catch (NullPointerException e) {
return false;
}
// only got here if we didn't return false
@ -21,7 +21,7 @@ public class Utils {
/**
* Used for inserting an ItemStack with a stacksize of 1 to a tile's inventory at slot 0.
*
* <p/>
* EG: Block Altar
*
* @param tile - The {@link TileInventory} to input the item to

View file

@ -8,7 +8,6 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.FillBucketEvent;
import net.minecraftforge.fml.common.eventhandler.Event;

View file

@ -1,6 +1,6 @@
package WayofTime.bloodmagic.util.helper;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.Constants;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.ItemMeshDefinition;
@ -14,15 +14,15 @@ import net.minecraftforge.client.model.ModelLoader;
/**
* @author <a href="https://github.com/TehNut">TehNut</a>
*
* The goal of this class is to make registering the inventory renders
* for your Items/Blocks a much simpler and easier process.
*
* You must call this at the post initialization stage on
* the clientside only.
*
* If you pass a Block through here that uses the default
* ItemBlock, you should specify a custom name.
* <p/>
* The goal of this class is to make registering the inventory renders
* for your Items/Blocks a much simpler and easier process.
* <p/>
* You must call this at the post initialization stage on
* the clientside only.
* <p/>
* If you pass a Block through here that uses the default
* ItemBlock, you should specify a custom name.
*/
public class InventoryRenderHelper {
@ -31,7 +31,7 @@ public class InventoryRenderHelper {
* your modid in all lowercase with a colon at the end.
*/
private final String domain;
public InventoryRenderHelper(String domain) {
this.domain = domain;
}
@ -102,7 +102,7 @@ public class InventoryRenderHelper {
ModelLoader.setCustomMeshDefinition(InventoryRenderHelper.getItemFromBlock(block), new ItemMeshDefinition() {
@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
return new ModelResourceLocation(BloodMagic.DOMAIN + toRender.getClass().getSimpleName(), "fluid");
return new ModelResourceLocation(Constants.Mod.DOMAIN + toRender.getClass().getSimpleName(), "fluid");
}
});
ModelLoader.setCustomStateMapper(block, new StateMapperBase() {
@ -114,14 +114,20 @@ public class InventoryRenderHelper {
}
/**
*
* @param block - Block to get Item of
* @return - The ItemBlock that corresponds to the Block.
*
* @return - The ItemBlock that corresponds to the Block.
*/
public static Item getItemFromBlock(Block block) {
return Item.getItemFromBlock(block);
}
/**
* Finds the class name of the given Item. If handed an ItemBlock, it will
* use the class name of the contained Block.
*
* @return The class name of the given Item
*/
private static String getClassName(Item item) {
return item instanceof ItemBlock ? Block.getBlockFromItem(item).getClass().getSimpleName() : item.getClass().getSimpleName();
}

View file

@ -1,8 +1,9 @@
package WayofTime.bloodmagic.util.helper;
import com.google.common.collect.Lists;
import net.minecraft.util.StatCollector;
import org.apache.commons.lang3.text.WordUtils;
import java.util.ArrayList;
import java.util.List;
public class TextHelper {
@ -11,30 +12,51 @@ public class TextHelper {
return string.replaceAll("&", "\u00A7");
}
public static String localize(String key, Object ... format) {
return getFormattedText(StatCollector.translateToLocalFormatted(key, format));
public static String localize(String input, Object... format) {
return StatCollector.translateToLocalFormatted(input, format);
}
/**
* Localizes all strings in a list, using the prefix.
*
* @param unloc
* The list of unlocalized strings.
* @return A list of localized versions of the passed strings.
*/
public static List<String> localizeAll(List<String> unloc) {
List<String> ret = Lists.newArrayList();
for (String s : unloc)
ret.add(localize(s));
public static String localizeEffect(String input, Object... format) {
return localize(input.replaceAll("&", "\u00A7"), format);
}
public static String[] localizeAll(String[] input) {
String[] ret = new String[input.length];
for (int i = 0; i < input.length; i++)
ret[i] = localize(input[i]);
return ret;
}
public static String[] localizeAll(String... unloc) {
String[] ret = new String[unloc.length];
for (int i = 0; i < ret.length; i++)
ret[i] = localize(unloc[i]);
public static String[] localizeAllEffect(String[] input) {
String[] ret = new String[input.length];
for (int i = 0; i < input.length; i++)
ret[i] = localizeEffect(input[i]);
return ret;
}
public static ArrayList<String> localizeAll(List<String> input) {
ArrayList<String> ret = new ArrayList<String>(input.size());
for (int i = 0; i < input.size(); i++)
ret.add(i, localize(input.get(i)));
return ret;
}
public static ArrayList<String> localizeAllEffect(List<String> input) {
ArrayList<String> ret = new ArrayList<String>(input.size());
for (int i = 0; i < input.size(); i++)
ret.add(i, localizeEffect(input.get(i)));
return ret;
}
public static String[] cutLongString(String string, int characters) {
return WordUtils.wrap(string, characters, "/cut", false).split("/cut");
}
public static String[] cutLongString(String string) {
return cutLongString(string, 30);
}
}

View file

@ -0,0 +1,17 @@
{
"forge_marker": 1,
"defaults": {
"textures": { },
"model": "orientable"
},
"variants": {
"normal": [{
"textures": {
"top": "bloodmagic:blocks/Teleposer_Top",
"side": "bloodmagic:blocks/Teleposer_Side",
"front": "bloodmagic:blocks/Teleposer_Side",
"bottom": "bloodmagic:blocks/Teleposer_Side"
}
}]
}
}

View file

@ -20,6 +20,11 @@ item.BloodMagic.scribe.air.name=Air Scribing Tools
item.BloodMagic.scribe.dusk.name=Dusk Scribing Tools
item.BloodMagic.scribe.dawn.name=Dawn Scribing Tools
item.BloodMagic.focus.weak.name=Teleposition Focus
item.BloodMagic.focus.enhanced.name=Enhanced Teleposition Focus
item.BloodMagic.focus.reinforced.name=Reinforced Teleposition Focus
item.BloodMagic.focus.demonic.name=Demonic Teleposition Focus
item.BloodMagic.slate.blank.name=Blank Slate
item.BloodMagic.slate.reinforced.name=Reinforced Slate
item.BloodMagic.slate.imbued.name=Imbued Slate

View file

@ -0,0 +1,9 @@
{
"parent": "block/orientable",
"textures": {
"top": "bloodmagic:blocks/Teleposer_Top",
"side": "bloodmagic:blocks/Teleposer_Side",
"front": "bloodmagic:blocks/Teleposer_Side",
"bottom": "bloodmagic:blocks/Teleposer_Side"
}
}

View file

@ -0,0 +1,10 @@
{
"parent": "bloodmagic:block/BlockTeleposer",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}