Divination Sigil
This commit is contained in:
parent
c701848011
commit
77ccc3a727
|
@ -7,6 +7,7 @@ public class NBTHolder {
|
||||||
|
|
||||||
public static final String NBT_OWNER = "ownerName";
|
public static final String NBT_OWNER = "ownerName";
|
||||||
public static final String NBT_USES = "uses";
|
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_SACRIFICE = "sacrifice";
|
||||||
public static final String NBT_DIMID = "dimensionId";
|
public static final String NBT_DIMID = "dimensionId";
|
||||||
public static final String NBT_COORDX = "xCoord";
|
public static final String NBT_COORDX = "xCoord";
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package WayofTime.alchemicalWizardry.api.iface;
|
||||||
|
|
||||||
|
public interface ISigil {
|
||||||
|
}
|
|
@ -136,6 +136,23 @@ public class NetworkHelper {
|
||||||
return newEss - currEss;
|
return newEss - currEss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get
|
||||||
|
|
||||||
|
public static int getCurrentEssence(String ownerName) {
|
||||||
|
if (MinecraftServer.getServer() == null)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
World world = MinecraftServer.getServer().worldServers[0];
|
||||||
|
SoulNetwork network = (SoulNetwork) world.loadItemData(SoulNetwork.class, ownerName);
|
||||||
|
|
||||||
|
if (network == null) {
|
||||||
|
network = new SoulNetwork(ownerName);
|
||||||
|
world.setItemData(ownerName, network);
|
||||||
|
}
|
||||||
|
|
||||||
|
return network.getCurrentEssence();
|
||||||
|
}
|
||||||
|
|
||||||
// Do damage
|
// Do damage
|
||||||
|
|
||||||
public static void hurtPlayer(EntityPlayer user, int energySyphoned) {
|
public static void hurtPlayer(EntityPlayer user, int energySyphoned) {
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
package WayofTime.alchemicalWizardry.api.util.helper;
|
package WayofTime.alchemicalWizardry.api.util.helper;
|
||||||
|
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
|
||||||
public class TextHelper {
|
public class TextHelper {
|
||||||
|
|
||||||
public static String getFormattedText(String string) {
|
public static String getFormattedText(String string) {
|
||||||
return string.replaceAll("&", "\u00A7");
|
return string.replaceAll("&", "\u00A7");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String localize(String key, Object ... format) {
|
||||||
|
return getFormattedText(StatCollector.translateToLocalFormatted(key, format));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
package WayofTime.alchemicalWizardry.item.sigil;
|
||||||
|
|
||||||
|
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||||
|
import WayofTime.alchemicalWizardry.api.NBTHolder;
|
||||||
|
import WayofTime.alchemicalWizardry.api.iface.ISigil;
|
||||||
|
import WayofTime.alchemicalWizardry.item.ItemBindable;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.BlockPos;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.StatCollector;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class ItemSigilBase extends ItemBindable implements ISigil {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private boolean toggleable;
|
||||||
|
|
||||||
|
public ItemSigilBase(String name, int energyUsed) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
setUnlocalizedName(AlchemicalWizardry.MODID + ".sigil." + name);
|
||||||
|
setEnergyUsed(energyUsed);
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemSigilBase(String name) {
|
||||||
|
this(name, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||||
|
super.onItemRightClick(stack, world, player);
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
|
super.onItemRightClick(stack, world, player);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) {
|
||||||
|
|
||||||
|
String desc = "tooltip.sigil." + name + ".desc";
|
||||||
|
|
||||||
|
if (StatCollector.canTranslate(desc))
|
||||||
|
tooltip.add(StatCollector.translateToLocal(desc));
|
||||||
|
|
||||||
|
super.addInformation(stack, player, tooltip, advanced);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToggleable() {
|
||||||
|
this.toggleable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUnusable(ItemStack stack) {
|
||||||
|
NBTHolder.checkNBT(stack);
|
||||||
|
|
||||||
|
return stack.getTagCompound().getBoolean(NBTHolder.NBT_UNUSABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack setUnusable(ItemStack stack, boolean unusable) {
|
||||||
|
NBTHolder.checkNBT(stack);
|
||||||
|
|
||||||
|
stack.getTagCompound().setBoolean(NBTHolder.NBT_UNUSABLE, unusable);
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getActivated(ItemStack stack) {
|
||||||
|
return stack.getItemDamage() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack setActivated(ItemStack stack, boolean activated) {
|
||||||
|
if (this.toggleable)
|
||||||
|
stack.setItemDamage(activated ? 1 : 0);
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package WayofTime.alchemicalWizardry.item.sigil;
|
||||||
|
|
||||||
|
import WayofTime.alchemicalWizardry.api.iface.IBloodAltar;
|
||||||
|
import WayofTime.alchemicalWizardry.api.util.helper.BindableHelper;
|
||||||
|
import WayofTime.alchemicalWizardry.api.util.helper.NetworkHelper;
|
||||||
|
import WayofTime.alchemicalWizardry.api.util.helper.TextHelper;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class ItemSigilDivination extends ItemSigilBase {
|
||||||
|
|
||||||
|
public ItemSigilDivination() {
|
||||||
|
super("divination");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||||
|
super.onItemRightClick(stack, world, player);
|
||||||
|
|
||||||
|
if (!world.isRemote && syphonBatteries(stack, player, getEnergyUsed())) {
|
||||||
|
MovingObjectPosition position = getMovingObjectPositionFromPlayer(world, player, false);
|
||||||
|
int currentEssence = NetworkHelper.getCurrentEssence(BindableHelper.getOwnerName(stack));
|
||||||
|
|
||||||
|
if (position == null) {
|
||||||
|
player.addChatComponentMessage(new ChatComponentText(TextHelper.localize("message.divinationsigil.currentessence", currentEssence)));
|
||||||
|
return stack;
|
||||||
|
} else {
|
||||||
|
if (position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||||
|
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
||||||
|
|
||||||
|
if (!(tile instanceof IBloodAltar)) {
|
||||||
|
player.addChatComponentMessage(new ChatComponentText(TextHelper.localize("message.divinationsigil.currentessence", currentEssence)));
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import WayofTime.alchemicalWizardry.api.AlchemicalWizardryAPI;
|
||||||
import WayofTime.alchemicalWizardry.api.orb.BloodOrb;
|
import WayofTime.alchemicalWizardry.api.orb.BloodOrb;
|
||||||
import WayofTime.alchemicalWizardry.api.registry.OrbRegistry;
|
import WayofTime.alchemicalWizardry.api.registry.OrbRegistry;
|
||||||
import WayofTime.alchemicalWizardry.item.ItemBloodOrb;
|
import WayofTime.alchemicalWizardry.item.ItemBloodOrb;
|
||||||
|
import WayofTime.alchemicalWizardry.item.sigil.ItemSigilDivination;
|
||||||
import WayofTime.alchemicalWizardry.util.helper.InventoryRenderHelper;
|
import WayofTime.alchemicalWizardry.util.helper.InventoryRenderHelper;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
|
@ -20,6 +21,7 @@ public class ModItems {
|
||||||
public static BloodOrb orbArchmage;
|
public static BloodOrb orbArchmage;
|
||||||
public static BloodOrb orbTranscendent;
|
public static BloodOrb orbTranscendent;
|
||||||
|
|
||||||
|
public static Item sigilDivination;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
bloodOrb = registerItem(new ItemBloodOrb());
|
bloodOrb = registerItem(new ItemBloodOrb());
|
||||||
|
@ -36,6 +38,8 @@ public class ModItems {
|
||||||
OrbRegistry.registerOrb(orbArchmage);
|
OrbRegistry.registerOrb(orbArchmage);
|
||||||
orbTranscendent = new BloodOrb("transcendent", 6, 30000000);
|
orbTranscendent = new BloodOrb("transcendent", 6, 30000000);
|
||||||
OrbRegistry.registerOrb(orbTranscendent);
|
OrbRegistry.registerOrb(orbTranscendent);
|
||||||
|
|
||||||
|
sigilDivination = registerItem(new ItemSigilDivination());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initRenders() {
|
public static void initRenders() {
|
||||||
|
|
Loading…
Reference in a new issue