Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -5,8 +5,6 @@ import WayofTime.bloodmagic.client.IVariantProvider;
|
|||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -18,12 +16,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemActivationCrystal extends ItemBindableBase implements IVariantProvider
|
||||
{
|
||||
public static String[] names = { "weak", "awakened", "creative" };
|
||||
public class ItemActivationCrystal extends ItemBindableBase implements IVariantProvider {
|
||||
public static String[] names = {"weak", "awakened", "creative"};
|
||||
|
||||
public ItemActivationCrystal()
|
||||
{
|
||||
public ItemActivationCrystal() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".activationCrystal.");
|
||||
|
@ -31,15 +27,13 @@ public class ItemActivationCrystal extends ItemBindableBase implements IVariantP
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -49,16 +43,14 @@ public class ItemActivationCrystal extends ItemBindableBase implements IVariantP
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(TextHelper.localize("tooltip.bloodmagic.activationCrystal." + names[stack.getItemDamage()]));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=weak"));
|
||||
ret.add(new ImmutablePair<Integer, String>(1, "type=demonic"));
|
||||
|
@ -66,8 +58,7 @@ public class ItemActivationCrystal extends ItemBindableBase implements IVariantP
|
|||
return ret;
|
||||
}
|
||||
|
||||
public int getCrystalLevel(ItemStack stack)
|
||||
{
|
||||
public int getCrystalLevel(ItemStack stack) {
|
||||
return stack.getItemDamage() > 1 ? Integer.MAX_VALUE : stack.getItemDamage() + 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,5 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.altar.BloodAltar;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
|
@ -33,14 +12,31 @@ import WayofTime.bloodmagic.block.BlockAltar;
|
|||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantProvider
|
||||
{
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantProvider {
|
||||
private EnumAltarTier tierToBuild = EnumAltarTier.ONE;
|
||||
|
||||
public ItemAltarMaker()
|
||||
{
|
||||
public ItemAltarMaker() {
|
||||
super();
|
||||
setUnlocalizedName(BloodMagic.MODID + ".altarMaker");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -50,30 +46,26 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentTier", stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (world.isRemote)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.bloodmagic.altarMaker.creativeOnly"));
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
if (player.isSneaking()) {
|
||||
if (stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) >= EnumAltarTier.MAXTIERS - 1)
|
||||
stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, 0);
|
||||
else
|
||||
|
@ -88,8 +80,7 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP
|
|||
if (rayTrace == null || rayTrace.typeOfHit == RayTraceResult.Type.MISS || rayTrace.typeOfHit == RayTraceResult.Type.ENTITY)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(rayTrace.getBlockPos()).getBlock() instanceof BlockAltar)
|
||||
{
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(rayTrace.getBlockPos()).getBlock() instanceof BlockAltar) {
|
||||
ChatUtil.sendNoSpam(player, TextHelper.localizeEffect("chat.bloodmagic.altarMaker.building", NumeralHelper.toRoman(tierToBuild.toInt())));
|
||||
buildAltar(world, rayTrace.getBlockPos());
|
||||
IBlockState state = world.getBlockState(rayTrace.getBlockPos());
|
||||
|
@ -101,28 +92,24 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=altarmaker"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setTierToBuild(EnumAltarTier tierToBuild)
|
||||
{
|
||||
public void setTierToBuild(EnumAltarTier tierToBuild) {
|
||||
this.tierToBuild = tierToBuild;
|
||||
}
|
||||
|
||||
public void buildAltar(World world, BlockPos pos)
|
||||
{
|
||||
public void buildAltar(World world, BlockPos pos) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
if (tierToBuild == EnumAltarTier.ONE)
|
||||
return;
|
||||
|
||||
for (AltarComponent altarComponent : tierToBuild.getAltarComponents())
|
||||
{
|
||||
for (AltarComponent altarComponent : tierToBuild.getAltarComponents()) {
|
||||
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
||||
Block blockForComponent = Utils.getBlockForComponent(altarComponent.getComponent());
|
||||
|
||||
|
@ -132,8 +119,7 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP
|
|||
((IBloodAltar) world.getTileEntity(pos)).checkTier();
|
||||
}
|
||||
|
||||
public String destroyAltar(EntityPlayer player)
|
||||
{
|
||||
public String destroyAltar(EntityPlayer player) {
|
||||
World world = player.getEntityWorld();
|
||||
if (world.isRemote)
|
||||
return "";
|
||||
|
@ -145,10 +131,8 @@ public class ItemAltarMaker extends Item implements IAltarManipulator, IVariantP
|
|||
|
||||
if (altarTier.equals(EnumAltarTier.ONE))
|
||||
return "" + altarTier.toInt();
|
||||
else
|
||||
{
|
||||
for (AltarComponent altarComponent : altarTier.getAltarComponents())
|
||||
{
|
||||
else {
|
||||
for (AltarComponent altarComponent : altarTier.getAltarComponents()) {
|
||||
BlockPos componentPos = pos.add(altarComponent.getOffset());
|
||||
IBlockState componentState = world.getBlockState(pos);
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -15,20 +17,14 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyArray;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemArcaneAshes extends Item implements IVariantProvider
|
||||
{
|
||||
public ItemArcaneAshes()
|
||||
{
|
||||
public class ItemArcaneAshes extends Item implements IVariantProvider {
|
||||
public ItemArcaneAshes() {
|
||||
setUnlocalizedName(BloodMagic.MODID + ".arcaneAshes");
|
||||
setMaxStackSize(1);
|
||||
setMaxDamage(19); //Allows for 20 uses
|
||||
|
@ -37,26 +33,21 @@ public class ItemArcaneAshes extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.arcaneAshes"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
BlockPos newPos = blockPos.offset(side);
|
||||
|
||||
if (world.isAirBlock(newPos))
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (world.isAirBlock(newPos)) {
|
||||
if (!world.isRemote) {
|
||||
EnumFacing rotation = EnumFacing.fromAngle(player.getRotationYawHead());
|
||||
world.setBlockState(newPos, RegistrarBloodMagicBlocks.ALCHEMY_ARRAY.getDefaultState());
|
||||
TileEntity tile = world.getTileEntity(newPos);
|
||||
if (tile instanceof TileAlchemyArray)
|
||||
{
|
||||
if (tile instanceof TileAlchemyArray) {
|
||||
((TileAlchemyArray) tile).setRotation(rotation);
|
||||
}
|
||||
|
||||
|
@ -70,8 +61,7 @@ public class ItemArcaneAshes extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=arcaneashes"));
|
||||
return ret;
|
||||
|
|
|
@ -6,7 +6,6 @@ import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
|||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -14,10 +13,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBindableBase extends ItemBindable
|
||||
{
|
||||
public ItemBindableBase()
|
||||
{
|
||||
public class ItemBindableBase extends ItemBindable {
|
||||
public ItemBindableBase() {
|
||||
super();
|
||||
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -25,8 +22,7 @@ public class ItemBindableBase extends ItemBindable
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.orb.BloodOrb;
|
||||
import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -14,29 +19,19 @@ import net.minecraft.util.*;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.orb.BloodOrb;
|
||||
import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindable
|
||||
{
|
||||
public ItemBloodOrb()
|
||||
{
|
||||
public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindable {
|
||||
public ItemBloodOrb() {
|
||||
setUnlocalizedName(BloodMagic.MODID + ".orb");
|
||||
this.setMaxDamage(0);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
BloodOrb orb = getOrb(stack);
|
||||
if (orb == null)
|
||||
return super.getUnlocalizedName(stack);
|
||||
|
@ -45,8 +40,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab
|
|||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -60,8 +54,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
BloodOrb orb = getOrb(stack);
|
||||
|
||||
|
@ -76,8 +69,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab
|
|||
if (PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
if (!stack.hasTagCompound()) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
|
@ -97,8 +89,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.orb.desc"));
|
||||
|
||||
BloodOrb orb = getOrb(stack);
|
||||
|
@ -109,22 +100,19 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IBindab
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack stack)
|
||||
{
|
||||
public ItemStack getContainerItem(ItemStack stack) {
|
||||
return stack.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack)
|
||||
{
|
||||
public boolean hasContainerItem(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// IBindable
|
||||
|
||||
@Override
|
||||
public boolean onBind(EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
public boolean onBind(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,12 +14,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBloodShard extends Item implements IVariantProvider
|
||||
{
|
||||
public String[] names = { "weak", "demon" };
|
||||
public class ItemBloodShard extends Item implements IVariantProvider {
|
||||
public String[] names = {"weak", "demon"};
|
||||
|
||||
public ItemBloodShard()
|
||||
{
|
||||
public ItemBloodShard() {
|
||||
super();
|
||||
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -29,8 +27,7 @@ public class ItemBloodShard extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -39,14 +36,12 @@ public class ItemBloodShard extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=weak"));
|
||||
ret.add(new ImmutablePair<Integer, String>(1, "type=demonic"));
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -28,40 +30,31 @@ import net.minecraftforge.event.world.BlockEvent;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider
|
||||
{
|
||||
public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider {
|
||||
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.PLANKS, Blocks.BOOKSHELF, Blocks.LOG, Blocks.LOG2, Blocks.CHEST, Blocks.PUMPKIN, Blocks.LIT_PUMPKIN, Blocks.MELON_BLOCK, Blocks.LADDER);
|
||||
|
||||
public ItemBoundAxe()
|
||||
{
|
||||
public ItemBoundAxe() {
|
||||
super("axe", 7, EFFECTIVE_ON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving)
|
||||
{
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge)
|
||||
{
|
||||
protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
|
@ -73,12 +66,9 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider
|
|||
|
||||
BlockPos playerPos = player.getPosition();
|
||||
|
||||
for (int i = -range; i <= range; i++)
|
||||
{
|
||||
for (int j = 0; j <= 2 * range; j++)
|
||||
{
|
||||
for (int k = -range; k <= range; k++)
|
||||
{
|
||||
for (int i = -range; i <= range; i++) {
|
||||
for (int j = 0; j <= 2 * range; j++) {
|
||||
for (int k = -range; k <= range; k++) {
|
||||
BlockPos blockPos = playerPos.add(i, j, k);
|
||||
BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos);
|
||||
|
||||
|
@ -92,16 +82,13 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider
|
|||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
continue;
|
||||
|
||||
if (blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1.0F)
|
||||
{
|
||||
if (blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1.0F) {
|
||||
float strengthVsBlock = getStrVsBlock(stack, blockStack.getState());
|
||||
|
||||
if (strengthVsBlock > 1.1F || blockStack.getBlock() instanceof BlockLeaves && world.canMineBlockBody(player, blockPos))
|
||||
{
|
||||
if (strengthVsBlock > 1.1F || blockStack.getBlock() instanceof BlockLeaves && world.canMineBlockBody(player, blockPos)) {
|
||||
if (silkTouch && blockStack.getBlock().canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player))
|
||||
drops.add(new ItemStackWrapper(blockStack));
|
||||
else
|
||||
{
|
||||
else {
|
||||
List<ItemStack> itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl);
|
||||
|
||||
for (ItemStack stacks : itemDrops)
|
||||
|
@ -121,11 +108,9 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
|
||||
{
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 11 : 2, 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -3.0, 0));
|
||||
}
|
||||
|
@ -134,21 +119,18 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionActivatable("ItemBoundAxe");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("active=true");
|
||||
ret.add("active=false");
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -25,50 +29,38 @@ import net.minecraftforge.event.world.BlockEvent;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
||||
{
|
||||
public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider {
|
||||
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.ACTIVATOR_RAIL, Blocks.COAL_ORE, Blocks.COBBLESTONE, Blocks.DETECTOR_RAIL, Blocks.DIAMOND_BLOCK, Blocks.DIAMOND_ORE, Blocks.STONE_SLAB, Blocks.GOLDEN_RAIL, Blocks.GOLD_BLOCK, Blocks.GOLD_ORE, Blocks.ICE, Blocks.IRON_BLOCK, Blocks.IRON_ORE, Blocks.LAPIS_BLOCK, Blocks.LAPIS_ORE, Blocks.LIT_REDSTONE_ORE, Blocks.MOSSY_COBBLESTONE, Blocks.NETHERRACK, Blocks.PACKED_ICE, Blocks.RAIL, Blocks.REDSTONE_ORE, Blocks.SANDSTONE, Blocks.RED_SANDSTONE, Blocks.STONE, Blocks.STONE_SLAB);
|
||||
|
||||
public ItemBoundPickaxe()
|
||||
{
|
||||
public ItemBoundPickaxe() {
|
||||
super("pickaxe", 5, EFFECTIVE_ON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving)
|
||||
{
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHarvestBlock(IBlockState blockIn)
|
||||
{
|
||||
public boolean canHarvestBlock(IBlockState blockIn) {
|
||||
return blockIn == Blocks.OBSIDIAN ? this.toolMaterial.getHarvestLevel() == 3
|
||||
: (blockIn != Blocks.DIAMOND_BLOCK && blockIn != Blocks.DIAMOND_ORE ? (blockIn != Blocks.EMERALD_ORE && blockIn != Blocks.EMERALD_BLOCK ? (blockIn != Blocks.GOLD_BLOCK && blockIn != Blocks.GOLD_ORE ? (blockIn != Blocks.IRON_BLOCK && blockIn != Blocks.IRON_ORE ? (blockIn != Blocks.LAPIS_BLOCK && blockIn != Blocks.LAPIS_ORE ? (blockIn != Blocks.REDSTONE_ORE && blockIn != Blocks.LIT_REDSTONE_ORE ? (blockIn.getMaterial() == Material.ROCK || (blockIn.getMaterial() == Material.IRON || blockIn.getMaterial() == Material.ANVIL)) : this.toolMaterial.getHarvestLevel() >= 2)
|
||||
: this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2);
|
||||
: this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 1) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2) : this.toolMaterial.getHarvestLevel() >= 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||
{
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state) {
|
||||
if (!getActivated(stack))
|
||||
return 1.0F;
|
||||
|
||||
|
@ -76,8 +68,7 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge)
|
||||
{
|
||||
protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
|
@ -89,12 +80,9 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
|
||||
BlockPos playerPos = player.getPosition();
|
||||
|
||||
for (int i = -range; i <= range; i++)
|
||||
{
|
||||
for (int j = 0; j <= 2 * range; j++)
|
||||
{
|
||||
for (int k = -range; k <= range; k++)
|
||||
{
|
||||
for (int i = -range; i <= range; i++) {
|
||||
for (int j = 0; j <= 2 * range; j++) {
|
||||
for (int k = -range; k <= range; k++) {
|
||||
BlockPos blockPos = playerPos.add(i, j, k);
|
||||
BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos);
|
||||
|
||||
|
@ -108,16 +96,13 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
continue;
|
||||
|
||||
if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1)
|
||||
{
|
||||
if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1) {
|
||||
float strengthVsBlock = getStrVsBlock(stack, blockStack.getState());
|
||||
|
||||
if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos))
|
||||
{
|
||||
if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) {
|
||||
if (silkTouch && blockStack.getBlock().canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player))
|
||||
drops.add(new ItemStackWrapper(blockStack));
|
||||
else
|
||||
{
|
||||
else {
|
||||
List<ItemStack> itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl);
|
||||
for (ItemStack stacks : itemDrops)
|
||||
drops.add(ItemStackWrapper.getHolder(stacks));
|
||||
|
@ -136,11 +121,9 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
|
||||
{
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 5 : 2, 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0));
|
||||
}
|
||||
|
@ -149,21 +132,18 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionActivatable("ItemBoundPickaxe");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("active=true");
|
||||
ret.add("active=false");
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -25,42 +29,31 @@ import net.minecraftforge.event.world.BlockEvent;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider
|
||||
{
|
||||
public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider {
|
||||
private static final Set<Block> EFFECTIVE_ON = Sets.newHashSet(Blocks.CLAY, Blocks.DIRT, Blocks.FARMLAND, Blocks.GRASS, Blocks.GRAVEL, Blocks.MYCELIUM, Blocks.SAND, Blocks.SNOW, Blocks.SNOW_LAYER, Blocks.SOUL_SAND);
|
||||
|
||||
public ItemBoundShovel()
|
||||
{
|
||||
public ItemBoundShovel() {
|
||||
super("shovel", 1, EFFECTIVE_ON);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving)
|
||||
{
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge)
|
||||
{
|
||||
protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) {
|
||||
if (world.isRemote)
|
||||
return;
|
||||
|
||||
|
@ -72,12 +65,9 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider
|
|||
|
||||
BlockPos playerPos = player.getPosition();
|
||||
|
||||
for (int i = -range; i <= range; i++)
|
||||
{
|
||||
for (int j = 0; j <= 2 * range; j++)
|
||||
{
|
||||
for (int k = -range; k <= range; k++)
|
||||
{
|
||||
for (int i = -range; i <= range; i++) {
|
||||
for (int j = 0; j <= 2 * range; j++) {
|
||||
for (int k = -range; k <= range; k++) {
|
||||
BlockPos blockPos = playerPos.add(i, j, k);
|
||||
BlockStack blockStack = BlockStack.getStackFromPos(world, blockPos);
|
||||
|
||||
|
@ -92,16 +82,13 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider
|
|||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
continue;
|
||||
|
||||
if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1)
|
||||
{
|
||||
if (blockStack.getBlock() != null && blockStack.getBlock().getBlockHardness(blockStack.getState(), world, blockPos) != -1) {
|
||||
float strengthVsBlock = getStrVsBlock(stack, blockStack.getState());
|
||||
|
||||
if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos))
|
||||
{
|
||||
if (strengthVsBlock > 1.1F && world.canMineBlockBody(player, blockPos)) {
|
||||
if (silkTouch && blockStack.getBlock().canSilkHarvest(world, blockPos, world.getBlockState(blockPos), player))
|
||||
drops.add(new ItemStackWrapper(blockStack));
|
||||
else
|
||||
{
|
||||
else {
|
||||
List<ItemStack> itemDrops = blockStack.getBlock().getDrops(world, blockPos, world.getBlockState(blockPos), fortuneLvl);
|
||||
for (ItemStack stacks : itemDrops)
|
||||
drops.add(ItemStackWrapper.getHolder(stacks));
|
||||
|
@ -120,11 +107,9 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
|
||||
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
|
||||
{
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", 5, 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", -2.5, 0));
|
||||
}
|
||||
|
@ -133,21 +118,18 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionActivatable("ItemBoundShovel");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("active=true");
|
||||
ret.add("active=false");
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IActivatable;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
@ -17,7 +25,6 @@ import net.minecraft.entity.SharedMonsterAttributes;
|
|||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemSword;
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
@ -28,25 +35,13 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IActivatable;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBoundSword extends ItemSword implements IBindable, IActivatable, IMeshProvider
|
||||
{
|
||||
public ItemBoundSword()
|
||||
{
|
||||
public class ItemBoundSword extends ItemSword implements IBindable, IActivatable, IMeshProvider {
|
||||
public ItemBoundSword() {
|
||||
super(RegistrarBloodMagicItems.BOUND_TOOL_MATERIAL);
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".bound.sword");
|
||||
|
@ -54,8 +49,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (player.isSneaking())
|
||||
setActivatedState(stack, !getActivated(stack));
|
||||
|
@ -74,8 +68,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
if (Strings.isNullOrEmpty(getOwnerUUID(stack))) {
|
||||
setActivatedState(stack, false);
|
||||
return;
|
||||
|
@ -86,27 +79,23 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving)
|
||||
{
|
||||
public boolean onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase entityLiving) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems)
|
||||
{
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
if (!isInCreativeTab(tab))
|
||||
return;
|
||||
|
||||
|
@ -115,8 +104,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
@ -130,11 +118,9 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
|
||||
{
|
||||
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getActivated(stack) ? 8 : 2, 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4, 0));
|
||||
}
|
||||
|
@ -143,21 +129,18 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionActivatable("ItemBoundSword");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("active=true");
|
||||
ret.add("active=false");
|
||||
|
@ -167,36 +150,30 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
|
|||
// IBindable
|
||||
|
||||
@Override
|
||||
public boolean onBind(EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
public boolean onBind(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerName(ItemStack stack)
|
||||
{
|
||||
public String getOwnerName(ItemStack stack) {
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerUUID(ItemStack stack)
|
||||
{
|
||||
public String getOwnerUUID(ItemStack stack) {
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
|
||||
}
|
||||
|
||||
// IActivatable
|
||||
|
||||
@Override
|
||||
public boolean getActivated(ItemStack stack)
|
||||
{
|
||||
public boolean getActivated(ItemStack stack) {
|
||||
return stack != null && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated) {
|
||||
if (stack != null) {
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,22 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.event.BoundToolEvent;
|
||||
import WayofTime.bloodmagic.api.iface.IActivatable;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multiset;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
@ -23,7 +28,6 @@ import net.minecraft.entity.item.EntityItem;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemTool;
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
@ -35,30 +39,20 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ItemStackWrapper;
|
||||
import WayofTime.bloodmagic.api.event.BoundToolEvent;
|
||||
import WayofTime.bloodmagic.api.iface.IActivatable;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Multiset;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
||||
{
|
||||
public class ItemBoundTool extends ItemTool implements IBindable, IActivatable {
|
||||
public final int chargeTime = 30;
|
||||
protected final String tooltipBase;
|
||||
private final String name;
|
||||
|
||||
public Map<ItemStack, Boolean> heldDownMap = new HashMap<ItemStack, Boolean>();
|
||||
public Map<ItemStack, Integer> heldDownCountMap = new HashMap<ItemStack, Integer>();
|
||||
|
||||
public final int chargeTime = 30;
|
||||
|
||||
public ItemBoundTool(String name, float damage, Set<Block> effectiveBlocks)
|
||||
{
|
||||
public ItemBoundTool(String name, float damage, Set<Block> effectiveBlocks) {
|
||||
super(damage, 1, RegistrarBloodMagicItems.BOUND_TOOL_MATERIAL, effectiveBlocks);
|
||||
setUnlocalizedName(BloodMagic.MODID + ".bound." + name);
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -69,20 +63,17 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||
{
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state) {
|
||||
return getActivated(stack) ? toolMaterial.getEfficiencyOnProperMaterial() : 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return slotChanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems)
|
||||
{
|
||||
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
if (isInCreativeTab(tab))
|
||||
return;
|
||||
|
||||
|
@ -90,19 +81,16 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
if (Strings.isNullOrEmpty(getOwnerUUID(stack))) {
|
||||
setActivatedState(stack, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity instanceof EntityPlayer && getActivated(stack) && isSelected && getBeingHeldDown(stack) && stack == ((EntityPlayer) entity).getActiveItemStack())
|
||||
{
|
||||
if (entity instanceof EntityPlayer && getActivated(stack) && isSelected && getBeingHeldDown(stack) && stack == ((EntityPlayer) entity).getActiveItemStack()) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
setHeldDownCount(stack, Math.min(player.getItemInUseCount(), chargeTime));
|
||||
} else if (!isSelected)
|
||||
{
|
||||
} else if (!isSelected) {
|
||||
setBeingHeldDown(stack, false);
|
||||
}
|
||||
|
||||
|
@ -110,41 +98,35 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
|||
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage((EntityPlayer) entity, 20);
|
||||
}
|
||||
|
||||
protected int getHeldDownCount(ItemStack stack)
|
||||
{
|
||||
protected int getHeldDownCount(ItemStack stack) {
|
||||
if (!heldDownCountMap.containsKey(stack))
|
||||
return 0;
|
||||
|
||||
return heldDownCountMap.get(stack);
|
||||
}
|
||||
|
||||
protected void setHeldDownCount(ItemStack stack, int count)
|
||||
{
|
||||
protected void setHeldDownCount(ItemStack stack, int count) {
|
||||
heldDownCountMap.put(stack, count);
|
||||
}
|
||||
|
||||
protected boolean getBeingHeldDown(ItemStack stack)
|
||||
{
|
||||
protected boolean getBeingHeldDown(ItemStack stack) {
|
||||
if (!heldDownMap.containsKey(stack))
|
||||
return false;
|
||||
|
||||
return heldDownMap.get(stack);
|
||||
}
|
||||
|
||||
protected void setBeingHeldDown(ItemStack stack, boolean heldDown)
|
||||
{
|
||||
protected void setBeingHeldDown(ItemStack stack, boolean heldDown) {
|
||||
heldDownMap.put(stack, heldDown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (player.isSneaking())
|
||||
setActivatedState(stack, !getActivated(stack));
|
||||
|
||||
if (!player.isSneaking() && getActivated(stack))
|
||||
{
|
||||
if (!player.isSneaking() && getActivated(stack)) {
|
||||
BoundToolEvent.Charge event = new BoundToolEvent.Charge(player, stack);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
return new ActionResult<>(EnumActionResult.FAIL, event.result);
|
||||
|
@ -157,13 +139,10 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft)
|
||||
{
|
||||
if (entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) {
|
||||
if (entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entityLiving;
|
||||
if (!player.isSneaking() && getActivated(stack))
|
||||
{
|
||||
if (!player.isSneaking() && getActivated(stack)) {
|
||||
int i = this.getMaxItemUseDuration(stack) - timeLeft;
|
||||
BoundToolEvent.Release event = new BoundToolEvent.Release(player, stack, i);
|
||||
if (MinecraftForge.EVENT_BUS.post(event))
|
||||
|
@ -177,39 +156,33 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
|||
}
|
||||
}
|
||||
|
||||
protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge)
|
||||
{
|
||||
protected void onBoundRelease(ItemStack stack, World world, EntityPlayer player, int charge) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving)
|
||||
{
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack stack)
|
||||
{
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability()
|
||||
{
|
||||
public int getItemEnchantability() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (TextHelper.canTranslate(tooltipBase + "desc"))
|
||||
tooltip.add(TextHelper.localizeEffect(tooltipBase + "desc"));
|
||||
|
||||
|
@ -225,80 +198,51 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getToolClasses(ItemStack stack)
|
||||
{
|
||||
public Set<String> getToolClasses(ItemStack stack) {
|
||||
return ImmutableSet.of(name);
|
||||
}
|
||||
|
||||
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
|
||||
return ArrayListMultimap.create(); // No-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack)
|
||||
{
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
return getActivated(stack) && getBeingHeldDown(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
return ((double) -Math.min(getHeldDownCount(stack), chargeTime) / chargeTime) + 1;
|
||||
}
|
||||
|
||||
protected static void dropStacks(Multiset<ItemStackWrapper> drops, World world, BlockPos posToDrop)
|
||||
{
|
||||
for (Multiset.Entry<ItemStackWrapper> entry : drops.entrySet())
|
||||
{
|
||||
int count = entry.getCount();
|
||||
ItemStackWrapper stack = entry.getElement();
|
||||
int maxStackSize = stack.item.getItemStackLimit(stack.toStack(1));
|
||||
|
||||
while (count >= maxStackSize)
|
||||
{
|
||||
world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(maxStackSize)));
|
||||
count -= maxStackSize;
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(count)));
|
||||
}
|
||||
@Override
|
||||
public String getOwnerName(ItemStack stack) {
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
|
||||
}
|
||||
|
||||
// IBindable
|
||||
|
||||
@Override
|
||||
public String getOwnerName(ItemStack stack)
|
||||
{
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_NAME) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwnerUUID(ItemStack stack)
|
||||
{
|
||||
public String getOwnerUUID(ItemStack stack) {
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getString(Constants.NBT.OWNER_UUID) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBind(EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
public boolean onBind(EntityPlayer player, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActivated(ItemStack stack) {
|
||||
return stack != null && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
// IActivatable
|
||||
|
||||
@Override
|
||||
public boolean getActivated(ItemStack stack)
|
||||
{
|
||||
return stack != null && NBTHelper.checkNBT(stack).getTagCompound().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated) {
|
||||
if (stack != null) {
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
}
|
||||
|
@ -325,4 +269,20 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
|
|||
public int getChargeTime() {
|
||||
return chargeTime;
|
||||
}
|
||||
|
||||
protected static void dropStacks(Multiset<ItemStackWrapper> drops, World world, BlockPos posToDrop) {
|
||||
for (Multiset.Entry<ItemStackWrapper> entry : drops.entrySet()) {
|
||||
int count = entry.getCount();
|
||||
ItemStackWrapper stack = entry.getElement();
|
||||
int maxStackSize = stack.item.getItemStackLimit(stack.toStack(1));
|
||||
|
||||
while (count >= maxStackSize) {
|
||||
world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(maxStackSize)));
|
||||
count -= maxStackSize;
|
||||
}
|
||||
|
||||
if (count > 0)
|
||||
world.spawnEntity(new EntityItem(world, posToDrop.getX(), posToDrop.getY(), posToDrop.getZ(), stack.toStack(count)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,21 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
|
||||
public class ItemComponent extends Item implements IVariantProvider
|
||||
{
|
||||
private static ArrayList<String> names = new ArrayList<String>();
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemComponent extends Item implements IVariantProvider {
|
||||
public static final String REAGENT_WATER = "reagentWater";
|
||||
public static final String REAGENT_LAVA = "reagentLava";
|
||||
public static final String REAGENT_AIR = "reagentAir";
|
||||
|
@ -54,9 +49,9 @@ public class ItemComponent extends Item implements IVariantProvider
|
|||
public static final String REAGENT_CLAW = "reagentClaw";
|
||||
public static final String REAGENT_BOUNCE = "reagentBounce";
|
||||
public static final String REAGENT_FROST = "reagentFrost";
|
||||
private static ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
public ItemComponent()
|
||||
{
|
||||
public ItemComponent() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".baseComponent.");
|
||||
|
@ -66,8 +61,7 @@ public class ItemComponent extends Item implements IVariantProvider
|
|||
buildItemList();
|
||||
}
|
||||
|
||||
private void buildItemList()
|
||||
{
|
||||
private void buildItemList() {
|
||||
names.add(0, REAGENT_WATER);
|
||||
names.add(1, REAGENT_LAVA);
|
||||
names.add(2, REAGENT_AIR);
|
||||
|
@ -104,15 +98,13 @@ public class ItemComponent extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names.get(stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -120,22 +112,19 @@ public class ItemComponent extends Item implements IVariantProvider
|
|||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String name)
|
||||
{
|
||||
return new ItemStack(RegistrarBloodMagicItems.COMPONENT, 1, names.indexOf(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
for (String name : names)
|
||||
ret.add(new ImmutablePair<Integer, String>(names.indexOf(name), "type=" + name));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String key, int stackSize)
|
||||
{
|
||||
public static ItemStack getStack(String name) {
|
||||
return new ItemStack(RegistrarBloodMagicItems.COMPONENT, 1, names.indexOf(name));
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String key, int stackSize) {
|
||||
ItemStack stack = getStack(key);
|
||||
stack.setCount(stackSize);
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PurificationHelper;
|
||||
import WayofTime.bloodmagic.api_impl.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
|
@ -14,23 +15,15 @@ import net.minecraft.init.SoundEvents;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.fml.common.registry.EntityRegistry;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PurificationHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemDaggerOfSacrifice extends Item implements IVariantProvider
|
||||
{
|
||||
public ItemDaggerOfSacrifice()
|
||||
{
|
||||
public class ItemDaggerOfSacrifice extends Item implements IVariantProvider {
|
||||
public ItemDaggerOfSacrifice() {
|
||||
super();
|
||||
setUnlocalizedName(BloodMagic.MODID + ".daggerOfSacrifice");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -39,8 +32,7 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
if (attacker instanceof FakePlayer)
|
||||
return false;
|
||||
|
||||
|
@ -66,18 +58,15 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider
|
|||
return false;
|
||||
|
||||
int lifeEssence = (int) (lifeEssenceRatio * target.getHealth());
|
||||
if (target instanceof EntityAnimal)
|
||||
{
|
||||
if (target instanceof EntityAnimal) {
|
||||
lifeEssence = (int) (lifeEssence * (1 + PurificationHelper.getCurrentPurity((EntityAnimal) target)));
|
||||
}
|
||||
|
||||
if (target.isChild())
|
||||
{
|
||||
if (target.isChild()) {
|
||||
lifeEssence *= 0.5F;
|
||||
}
|
||||
|
||||
if (PlayerSacrificeHelper.findAndFillAltar(attacker.getEntityWorld(), target, lifeEssence, true))
|
||||
{
|
||||
if (PlayerSacrificeHelper.findAndFillAltar(attacker.getEntityWorld(), target, lifeEssence, true)) {
|
||||
target.getEntityWorld().playSound(null, target.posX, target.posY, target.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (target.getEntityWorld().rand.nextFloat() - target.getEntityWorld().rand.nextFloat()) * 0.8F);
|
||||
target.setHealth(-1);
|
||||
target.onDeath(WayofTime.bloodmagic.api.BloodMagicAPI.damageSource);
|
||||
|
@ -87,8 +76,7 @@ public class ItemDaggerOfSacrifice extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = Lists.newArrayList();
|
||||
ret.add(Pair.of(0, "type=normal"));
|
||||
return ret;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -11,18 +13,13 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVariantProvider
|
||||
{
|
||||
public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVariantProvider {
|
||||
public static final ArrayList<String> NAMES = Lists.newArrayList();
|
||||
|
||||
public static final String CRYSTAL_DEFAULT = "crystalDefault";
|
||||
|
@ -31,8 +28,7 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria
|
|||
public static final String CRYSTAL_DESTRUCTIVE = "crystalDestructive";
|
||||
public static final String CRYSTAL_STEADFAST = "crystalSteadfast";
|
||||
|
||||
public ItemDemonCrystal()
|
||||
{
|
||||
public ItemDemonCrystal() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".demonCrystal.");
|
||||
|
@ -42,8 +38,7 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria
|
|||
buildItemList();
|
||||
}
|
||||
|
||||
private void buildItemList()
|
||||
{
|
||||
private void buildItemList() {
|
||||
NAMES.add(0, CRYSTAL_DEFAULT);
|
||||
NAMES.add(1, CRYSTAL_CORROSIVE);
|
||||
NAMES.add(2, CRYSTAL_DESTRUCTIVE);
|
||||
|
@ -52,15 +47,13 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + NAMES.get(stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -68,25 +61,17 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria
|
|||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String name)
|
||||
{
|
||||
return new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, 1, NAMES.indexOf(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWill(ItemStack willStack)
|
||||
{
|
||||
public double getWill(ItemStack willStack) {
|
||||
return getDiscretization(willStack) * willStack.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double drainWill(ItemStack willStack, double drainAmount)
|
||||
{
|
||||
public double drainWill(ItemStack willStack, double drainAmount) {
|
||||
double discretization = getDiscretization(willStack);
|
||||
int drainedNumber = (int) Math.floor(Math.min(willStack.getCount() * discretization, drainAmount) / discretization);
|
||||
|
||||
if (drainedNumber > 0)
|
||||
{
|
||||
if (drainedNumber > 0) {
|
||||
willStack.shrink(drainedNumber);
|
||||
return drainedNumber * discretization;
|
||||
}
|
||||
|
@ -95,23 +80,24 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria
|
|||
}
|
||||
|
||||
@Override
|
||||
public double getDiscretization(ItemStack willStack)
|
||||
{
|
||||
public double getDiscretization(ItemStack willStack) {
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getType(ItemStack willStack)
|
||||
{
|
||||
public EnumDemonWillType getType(ItemStack willStack) {
|
||||
return EnumDemonWillType.values()[MathHelper.clamp(willStack.getMetadata(), 0, EnumDemonWillType.values().length - 1)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
for (String name : NAMES)
|
||||
ret.add(new ImmutablePair<Integer, String>(NAMES.indexOf(name), "type=" + name));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String name) {
|
||||
return new ItemStack(RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL, 1, NAMES.indexOf(name));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.iface.IDemonWillViewer;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -11,19 +11,15 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.iface.IDemonWillViewer;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemDemonWillGauge extends Item implements IVariantProvider, IDemonWillViewer
|
||||
{
|
||||
public ItemDemonWillGauge()
|
||||
{
|
||||
public class ItemDemonWillGauge extends Item implements IVariantProvider, IDemonWillViewer {
|
||||
public ItemDemonWillGauge() {
|
||||
setUnlocalizedName(BloodMagic.MODID + ".willGauge");
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -31,28 +27,24 @@ public class ItemDemonWillGauge extends Item implements IVariantProvider, IDemon
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.willGauge"))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=willgauge"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
public boolean canSeeDemonWillAura(World world, ItemStack stack, EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
public int getDemonWillAuraResolution(World world, ItemStack stack, EntityPlayer player) {
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
|
@ -15,19 +16,14 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemExperienceBook extends Item implements IVariantProvider
|
||||
{
|
||||
public ItemExperienceBook()
|
||||
{
|
||||
public class ItemExperienceBook extends Item implements IVariantProvider {
|
||||
public ItemExperienceBook() {
|
||||
setUnlocalizedName(BloodMagic.MODID + ".experienceTome");
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -35,15 +31,13 @@ public class ItemExperienceBook extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect(ItemStack stack)
|
||||
{
|
||||
public boolean hasEffect(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.experienceTome"));
|
||||
|
||||
if (!stack.hasTagCompound())
|
||||
|
@ -56,11 +50,9 @@ public class ItemExperienceBook extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
if (player.isSneaking())
|
||||
absorbOneLevelExpFromPlayer(stack, player);
|
||||
else
|
||||
|
@ -71,15 +63,13 @@ public class ItemExperienceBook extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=experiencetome"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void giveOneLevelExpToPlayer(ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
public void giveOneLevelExpToPlayer(ItemStack stack, EntityPlayer player) {
|
||||
float progress = player.experience;
|
||||
int expToNext = getExperienceForNextLevel(player.experienceLevel);
|
||||
|
||||
|
@ -88,37 +78,30 @@ public class ItemExperienceBook extends Item implements IVariantProvider
|
|||
|
||||
System.out.println("Needed: " + neededExp + ", contained: " + containedExp + ", exp to next: " + expToNext);
|
||||
|
||||
if (containedExp >= neededExp)
|
||||
{
|
||||
if (containedExp >= neededExp) {
|
||||
setStoredExperience(stack, containedExp - neededExp);
|
||||
addPlayerXP(player, neededExp);
|
||||
|
||||
if (player.experienceLevel % 5 == 0)
|
||||
{
|
||||
if (player.experienceLevel % 5 == 0) {
|
||||
float f = player.experienceLevel > 30 ? 1.0F : (float) player.experienceLevel / 30.0F;
|
||||
player.getEntityWorld().playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_PLAYER_LEVELUP, player.getSoundCategory(), f * 0.75F, 1.0F);
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
setStoredExperience(stack, 0);
|
||||
addPlayerXP(player, (int) containedExp);
|
||||
}
|
||||
}
|
||||
|
||||
public void absorbOneLevelExpFromPlayer(ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
public void absorbOneLevelExpFromPlayer(ItemStack stack, EntityPlayer player) {
|
||||
float progress = player.experience;
|
||||
|
||||
if (progress > 0)
|
||||
{
|
||||
if (progress > 0) {
|
||||
int expDeduction = (int) getExperienceAcquiredToNext(player);
|
||||
if (expDeduction > 0)
|
||||
{
|
||||
if (expDeduction > 0) {
|
||||
addPlayerXP(player, -expDeduction);
|
||||
addExperience(stack, expDeduction);
|
||||
}
|
||||
} else if (progress == 0 && player.experienceLevel > 0)
|
||||
{
|
||||
} else if (progress == 0 && player.experienceLevel > 0) {
|
||||
int expDeduction = getExperienceForNextLevel(player.experienceLevel - 1);
|
||||
addPlayerXP(player, -expDeduction);
|
||||
addExperience(stack, expDeduction);
|
||||
|
@ -126,13 +109,11 @@ public class ItemExperienceBook extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
// Credits to Ender IO for some of the experience code, although now modified slightly for my convenience.
|
||||
public static int getPlayerXP(EntityPlayer player)
|
||||
{
|
||||
public static int getPlayerXP(EntityPlayer player) {
|
||||
return (int) (getExperienceForLevel(player.experienceLevel) + (player.experience * player.xpBarCap()));
|
||||
}
|
||||
|
||||
public static void addPlayerXP(EntityPlayer player, int amount)
|
||||
{
|
||||
public static void addPlayerXP(EntityPlayer player, int amount) {
|
||||
int experience = Math.max(0, getPlayerXP(player) + amount);
|
||||
player.experienceTotal = experience;
|
||||
player.experienceLevel = getLevelForExperience(experience);
|
||||
|
@ -140,8 +121,7 @@ public class ItemExperienceBook extends Item implements IVariantProvider
|
|||
player.experience = (float) (experience - expForLevel) / (float) player.xpBarCap();
|
||||
}
|
||||
|
||||
public static void setStoredExperience(ItemStack stack, double exp)
|
||||
{
|
||||
public static void setStoredExperience(ItemStack stack, double exp) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -149,8 +129,7 @@ public class ItemExperienceBook extends Item implements IVariantProvider
|
|||
tag.setDouble("experience", exp);
|
||||
}
|
||||
|
||||
public static double getStoredExperience(ItemStack stack)
|
||||
{
|
||||
public static double getStoredExperience(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -158,65 +137,50 @@ public class ItemExperienceBook extends Item implements IVariantProvider
|
|||
return tag.getDouble("experience");
|
||||
}
|
||||
|
||||
public static void addExperience(ItemStack stack, double exp)
|
||||
{
|
||||
public static void addExperience(ItemStack stack, double exp) {
|
||||
setStoredExperience(stack, getStoredExperience(stack) + exp);
|
||||
}
|
||||
|
||||
public static int getExperienceForNextLevel(int currentLevel)
|
||||
{
|
||||
if (currentLevel < 16)
|
||||
{
|
||||
public static int getExperienceForNextLevel(int currentLevel) {
|
||||
if (currentLevel < 16) {
|
||||
return 2 * currentLevel + 7;
|
||||
} else if (currentLevel < 31)
|
||||
{
|
||||
} else if (currentLevel < 31) {
|
||||
return 5 * currentLevel - 38;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return 9 * currentLevel - 158;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Change to calculation form.
|
||||
public static int getExperienceForLevel(int level)
|
||||
{
|
||||
if (level >= 21863)
|
||||
{
|
||||
public static int getExperienceForLevel(int level) {
|
||||
if (level >= 21863) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
if (level == 0)
|
||||
{
|
||||
if (level == 0) {
|
||||
return 0;
|
||||
}
|
||||
int res = 0;
|
||||
for (int i = 0; i < level; i++)
|
||||
{
|
||||
for (int i = 0; i < level; i++) {
|
||||
res += getExperienceForNextLevel(i);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public static double getExperienceAcquiredToNext(EntityPlayer player)
|
||||
{
|
||||
public static double getExperienceAcquiredToNext(EntityPlayer player) {
|
||||
return player.experience * player.xpBarCap();
|
||||
}
|
||||
|
||||
public static int getLevelForExperience(double exp)
|
||||
{
|
||||
if (exp <= 352)
|
||||
{
|
||||
public static int getLevelForExperience(double exp) {
|
||||
if (exp <= 352) {
|
||||
return (int) Math.floor(solveParabola(1, 6, -exp));
|
||||
} else if (exp <= 1507)
|
||||
{
|
||||
} else if (exp <= 1507) {
|
||||
return (int) Math.floor(solveParabola(2.5, -40.5, 360 - exp));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return (int) Math.floor(solveParabola(4.5, -162.5, 2220 - exp));
|
||||
}
|
||||
}
|
||||
|
||||
public static double solveParabola(double a, double b, double c)
|
||||
{
|
||||
public static double solveParabola(double a, double b, double c) {
|
||||
return (-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.block.BlockRitualStone;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -20,21 +21,15 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.block.BlockRitualStone;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemInscriptionTool extends ItemBindableBase implements IVariantProvider
|
||||
{
|
||||
public ItemInscriptionTool()
|
||||
{
|
||||
public class ItemInscriptionTool extends ItemBindableBase implements IVariantProvider {
|
||||
public ItemInscriptionTool() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".scribe.");
|
||||
|
@ -42,20 +37,17 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + EnumRuneType.values()[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
for (int i = 1; i < EnumRuneType.values().length; i++)
|
||||
{
|
||||
for (int i = 1; i < EnumRuneType.values().length; i++) {
|
||||
ItemStack stack = NBTHelper.checkNBT(new ItemStack(this, 1, i));
|
||||
stack.getTagCompound().setInteger(Constants.NBT.USES, 10);
|
||||
list.add(stack);
|
||||
|
@ -63,19 +55,16 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
if (state.getBlock() instanceof BlockRitualStone && !((BlockRitualStone) state.getBlock()).isRuneType(world, pos, getType(stack)))
|
||||
{
|
||||
if (state.getBlock() instanceof BlockRitualStone && !((BlockRitualStone) state.getBlock()).isRuneType(world, pos, getType(stack))) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
int uses = stack.getTagCompound().getInteger(Constants.NBT.USES);
|
||||
|
||||
world.setBlockState(pos, state.withProperty(((BlockRitualStone) state.getBlock()).getProperty(), getType(stack)));
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
stack.getTagCompound().setInteger(Constants.NBT.USES, --uses);
|
||||
if (uses <= 0)
|
||||
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
|
||||
|
@ -87,46 +76,40 @@ public class ItemInscriptionTool extends ItemBindableBase implements IVariantPro
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack)
|
||||
{
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
return stack.hasTagCompound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
int uses = stack.getTagCompound().getInteger(Constants.NBT.USES);
|
||||
|
||||
return 1.0 - ((double) uses / (double) 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack) {
|
||||
int uses = stack.getTagCompound().getInteger(Constants.NBT.USES);
|
||||
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float)(uses) / 10) / 3.0F, 1.0F, 1.0F);
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float) (uses) / 10) / 3.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag) {
|
||||
list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.inscriber.desc"))));
|
||||
super.addInformation(stack, world, list, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
for (int i = 1; i < EnumRuneType.values().length; i++)
|
||||
ret.add(new ImmutablePair<Integer, String>(i, "type=" + EnumRuneType.values()[i].name()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public EnumRuneType getType(ItemStack stack)
|
||||
{
|
||||
public EnumRuneType getType(ItemStack stack) {
|
||||
return EnumRuneType.values()[stack.getItemDamage()];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,26 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvider
|
||||
{
|
||||
public ItemLavaCrystal()
|
||||
{
|
||||
public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvider {
|
||||
public ItemLavaCrystal() {
|
||||
super();
|
||||
setUnlocalizedName(BloodMagic.MODID + ".lavaCrystal");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack itemStack)
|
||||
{
|
||||
public ItemStack getContainerItem(ItemStack itemStack) {
|
||||
NetworkHelper.getSoulNetwork(this.getOwnerUUID(itemStack)).syphon(25);
|
||||
ItemStack copiedStack = itemStack.copy();
|
||||
copiedStack.setItemDamage(copiedStack.getItemDamage());
|
||||
|
@ -34,8 +29,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack itemStack)
|
||||
{
|
||||
public boolean hasContainerItem(ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -59,8 +53,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = Lists.newArrayList();
|
||||
ret.add(Pair.of(0, "type=normal"));
|
||||
return ret;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
@ -25,14 +24,11 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPotionFlask extends Item implements IMeshProvider
|
||||
{
|
||||
public ItemPotionFlask()
|
||||
{
|
||||
public class ItemPotionFlask extends Item implements IMeshProvider {
|
||||
public ItemPotionFlask() {
|
||||
setUnlocalizedName(BloodMagic.MODID + ".potionFlask");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setMaxStackSize(1);
|
||||
|
@ -41,27 +37,22 @@ public class ItemPotionFlask extends Item implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving)
|
||||
{
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entityLiving) {
|
||||
EntityPlayer player = entityLiving instanceof EntityPlayer ? (EntityPlayer) entityLiving : null;
|
||||
|
||||
int remainingUses = stack.getMaxDamage() - stack.getItemDamage();
|
||||
if (remainingUses <= 0)
|
||||
{
|
||||
if (remainingUses <= 0) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
stack.getTagCompound().setBoolean("empty", true);
|
||||
return stack;
|
||||
}
|
||||
|
||||
if (player == null || !player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (player == null || !player.capabilities.isCreativeMode) {
|
||||
stack.setItemDamage(stack.getItemDamage() + 1);
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
for (PotionEffect potioneffect : PotionUtils.getEffectsFromStack(stack))
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
for (PotionEffect potioneffect : PotionUtils.getEffectsFromStack(stack)) {
|
||||
entityLiving.addPotionEffect(new PotionEffect(potioneffect));
|
||||
}
|
||||
}
|
||||
|
@ -70,20 +61,17 @@ public class ItemPotionFlask extends Item implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack stack)
|
||||
{
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.DRINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
int remainingUses = stack.getMaxDamage() - stack.getItemDamage();
|
||||
if (remainingUses > 0 || !stack.hasTagCompound() || !stack.getTagCompound().hasKey("empty"))
|
||||
|
@ -91,8 +79,7 @@ public class ItemPotionFlask extends Item implements IMeshProvider
|
|||
|
||||
RayTraceResult trace = rayTrace(world, player, true);
|
||||
|
||||
if (trace.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(trace.getBlockPos()).getMaterial() == Material.WATER)
|
||||
{
|
||||
if (trace.typeOfHit == RayTraceResult.Type.BLOCK && world.getBlockState(trace.getBlockPos()).getMaterial() == Material.WATER) {
|
||||
world.playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F);
|
||||
player.setHeldItem(hand, new ItemStack(this));
|
||||
return EnumActionResult.SUCCESS;
|
||||
|
@ -102,12 +89,10 @@ public class ItemPotionFlask extends Item implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
int remainingUses = stack.getMaxDamage() - stack.getItemDamage();
|
||||
if (remainingUses <= 0)
|
||||
{
|
||||
if (remainingUses <= 0) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
stack.getTagCompound().setBoolean("empty", true);
|
||||
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
|
||||
|
@ -118,8 +103,7 @@ public class ItemPotionFlask extends Item implements IMeshProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
PotionUtils.addPotionTooltip(stack, tooltip, 1.0F);
|
||||
tooltip.add("");
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.potion.uses", stack.getMaxDamage() - stack.getItemDamage()));
|
||||
|
@ -138,8 +122,7 @@ public class ItemPotionFlask extends Item implements IMeshProvider
|
|||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return stack -> {
|
||||
boolean full = true;
|
||||
if (stack.hasTagCompound() && stack.getTagCompound().hasKey("empty"))
|
||||
|
@ -150,14 +133,12 @@ public class ItemPotionFlask extends Item implements IMeshProvider
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
return Lists.newArrayList("full=true", "full=false");
|
||||
}
|
||||
}
|
|
@ -1,9 +1,20 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
||||
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.api.ritual.RitualComponent;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.util.helper.RitualHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.handler.event.ClientHandler;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -23,35 +34,19 @@ import net.minecraft.util.text.TextComponentTranslation;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
||||
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.api.ritual.RitualComponent;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.util.helper.RitualHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.tile.TileMasterRitualStone;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.handler.event.ClientHandler;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ItemRitualDiviner extends Item implements IVariantProvider
|
||||
{
|
||||
public static String[] names = { "normal", "dusk", "dawn" };
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemRitualDiviner extends Item implements IVariantProvider {
|
||||
public static final String tooltipBase = "tooltip.bloodmagic.diviner.";
|
||||
public static String[] names = {"normal", "dusk", "dawn"};
|
||||
|
||||
public ItemRitualDiviner()
|
||||
{
|
||||
public ItemRitualDiviner() {
|
||||
setUnlocalizedName(BloodMagic.MODID + ".ritualDiviner");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setHasSubtypes(true);
|
||||
|
@ -59,14 +54,12 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHighlightTip(ItemStack stack, String displayName)
|
||||
{
|
||||
public String getHighlightTip(ItemStack stack, String displayName) {
|
||||
if (Strings.isNullOrEmpty(getCurrentRitual(stack)))
|
||||
return displayName;
|
||||
|
||||
|
@ -79,8 +72,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -89,21 +81,16 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (player.isSneaking())
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
if (player.isSneaking()) {
|
||||
if (world.isRemote) {
|
||||
trySetDisplayedRitual(stack, world, pos);
|
||||
}
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else if (addRuneToRitual(stack, world, pos, player))
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
} else if (addRuneToRitual(stack, world, pos, player)) {
|
||||
if (world.isRemote) {
|
||||
spawnParticles(world, pos.up(), 15);
|
||||
}
|
||||
|
||||
|
@ -116,64 +103,47 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
|
||||
/**
|
||||
* Adds a single rune to the ritual.
|
||||
*
|
||||
* @param stack
|
||||
* - The Ritual Diviner stack
|
||||
* @param world
|
||||
* - The World
|
||||
* @param pos
|
||||
* - Block Position of the MRS.
|
||||
* @param player
|
||||
* - The Player attempting to place the ritual
|
||||
*
|
||||
*
|
||||
* @param stack - The Ritual Diviner stack
|
||||
* @param world - The World
|
||||
* @param pos - Block Position of the MRS.
|
||||
* @param player - The Player attempting to place the ritual
|
||||
* @return - True if a rune was successfully added
|
||||
*/
|
||||
public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, EntityPlayer player)
|
||||
{
|
||||
public boolean addRuneToRitual(ItemStack stack, World world, BlockPos pos, EntityPlayer player) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileMasterRitualStone)
|
||||
{
|
||||
if (tile instanceof TileMasterRitualStone) {
|
||||
Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack));
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
EnumFacing direction = getDirection(stack);
|
||||
for (RitualComponent component : ritual.getComponents())
|
||||
{
|
||||
if (!canPlaceRitualStone(component.getRuneType(), stack))
|
||||
{
|
||||
for (RitualComponent component : ritual.getComponents()) {
|
||||
if (!canPlaceRitualStone(component.getRuneType(), stack)) {
|
||||
return false;
|
||||
}
|
||||
BlockPos offset = component.getOffset(direction);
|
||||
BlockPos newPos = pos.add(offset);
|
||||
IBlockState state = world.getBlockState(newPos);
|
||||
Block block = state.getBlock();
|
||||
if (RitualHelper.isRune(world, newPos))
|
||||
{
|
||||
if (RitualHelper.isRuneType(world, newPos, component.getRuneType()))
|
||||
{
|
||||
if (world.isRemote)
|
||||
{
|
||||
if (RitualHelper.isRune(world, newPos)) {
|
||||
if (RitualHelper.isRuneType(world, newPos, component.getRuneType())) {
|
||||
if (world.isRemote) {
|
||||
undisplayHologram();
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
// Replace existing ritual stone
|
||||
RitualHelper.setRuneType(world, newPos, component.getRuneType());
|
||||
return true;
|
||||
}
|
||||
} else if (block.isAir(state, world, newPos) || block.isReplaceable(world, newPos))
|
||||
{
|
||||
if (!consumeStone(stack, world, player))
|
||||
{
|
||||
} else if (block.isAir(state, world, newPos) || block.isReplaceable(world, newPos)) {
|
||||
if (!consumeStone(stack, world, player)) {
|
||||
return false;
|
||||
}
|
||||
int meta = component.getRuneType().ordinal();
|
||||
IBlockState newState = RegistrarBloodMagicBlocks.RITUAL_STONE.getStateFromMeta(meta);
|
||||
world.setBlockState(newPos, newState);
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return false; // TODO: Possibly replace the block with a
|
||||
// ritual stone
|
||||
}
|
||||
|
@ -185,17 +155,14 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void trySetDisplayedRitual(ItemStack itemStack, World world, BlockPos pos)
|
||||
{
|
||||
public void trySetDisplayedRitual(ItemStack itemStack, World world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileMasterRitualStone)
|
||||
{
|
||||
if (tile instanceof TileMasterRitualStone) {
|
||||
Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(itemStack));
|
||||
TileMasterRitualStone masterRitualStone = (TileMasterRitualStone) tile;
|
||||
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
EnumFacing direction = getDirection(itemStack);
|
||||
ClientHandler.setRitualHolo(masterRitualStone, ritual, direction, true);
|
||||
}
|
||||
|
@ -203,32 +170,26 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void undisplayHologram()
|
||||
{
|
||||
public void undisplayHologram() {
|
||||
ClientHandler.setRitualHoloToNull();
|
||||
}
|
||||
|
||||
// TODO: Make this work for any IRitualStone
|
||||
public boolean consumeStone(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (player.capabilities.isCreativeMode)
|
||||
{
|
||||
public boolean consumeStone(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (player.capabilities.isCreativeMode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
NonNullList<ItemStack> inventory = player.inventory.mainInventory;
|
||||
for (ItemStack newStack : inventory)
|
||||
{
|
||||
for (ItemStack newStack : inventory) {
|
||||
if (newStack.isEmpty()) {
|
||||
|
||||
continue;
|
||||
}
|
||||
Item item = newStack.getItem();
|
||||
if (item instanceof ItemBlock)
|
||||
{
|
||||
if (item instanceof ItemBlock) {
|
||||
Block block = ((ItemBlock) item).getBlock();
|
||||
if (block == RegistrarBloodMagicBlocks.RITUAL_STONE)
|
||||
{
|
||||
if (block == RegistrarBloodMagicBlocks.RITUAL_STONE) {
|
||||
newStack.shrink(1);
|
||||
return true;
|
||||
}
|
||||
|
@ -240,32 +201,26 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
Ritual ritual = RitualRegistry.getRitualForId(this.getCurrentRitual(stack));
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
tooltip.add(TextHelper.localize("tooltip.bloodmagic.diviner.currentRitual") + TextHelper.localize(ritual.getUnlocalizedName()));
|
||||
|
||||
boolean sneaking = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
|
||||
boolean extraInfo = sneaking && Keyboard.isKeyDown(Keyboard.KEY_M);
|
||||
|
||||
if (extraInfo)
|
||||
{
|
||||
if (extraInfo) {
|
||||
tooltip.add("");
|
||||
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
if (TextHelper.canTranslate(ritual.getUnlocalizedName() + "." + type.getName().toLowerCase() + ".info"))
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
if (TextHelper.canTranslate(ritual.getUnlocalizedName() + "." + type.getName().toLowerCase() + ".info")) {
|
||||
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(ritual.getUnlocalizedName() + "." + type.getName().toLowerCase() + ".info"))));
|
||||
}
|
||||
}
|
||||
} else if (sneaking)
|
||||
{
|
||||
} else if (sneaking) {
|
||||
tooltip.add(TextHelper.localize(tooltipBase + "currentDirection", Utils.toFancyCasing(getDirection(stack).getName())));
|
||||
tooltip.add("");
|
||||
ArrayList<RitualComponent> componentList = ritual.getComponents();
|
||||
|
@ -279,31 +234,29 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
int dawnRunes = 0;
|
||||
int totalRunes = componentList.size();
|
||||
|
||||
for (RitualComponent component : componentList)
|
||||
{
|
||||
switch (component.getRuneType())
|
||||
{
|
||||
case BLANK:
|
||||
blankRunes++;
|
||||
break;
|
||||
case AIR:
|
||||
airRunes++;
|
||||
break;
|
||||
case EARTH:
|
||||
earthRunes++;
|
||||
break;
|
||||
case FIRE:
|
||||
fireRunes++;
|
||||
break;
|
||||
case WATER:
|
||||
waterRunes++;
|
||||
break;
|
||||
case DUSK:
|
||||
duskRunes++;
|
||||
break;
|
||||
case DAWN:
|
||||
dawnRunes++;
|
||||
break;
|
||||
for (RitualComponent component : componentList) {
|
||||
switch (component.getRuneType()) {
|
||||
case BLANK:
|
||||
blankRunes++;
|
||||
break;
|
||||
case AIR:
|
||||
airRunes++;
|
||||
break;
|
||||
case EARTH:
|
||||
earthRunes++;
|
||||
break;
|
||||
case FIRE:
|
||||
fireRunes++;
|
||||
break;
|
||||
case WATER:
|
||||
waterRunes++;
|
||||
break;
|
||||
case DUSK:
|
||||
duskRunes++;
|
||||
break;
|
||||
case DAWN:
|
||||
dawnRunes++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,11 +277,9 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
|
||||
tooltip.add("");
|
||||
tooltip.add(TextHelper.localize(tooltipBase + "totalRune", totalRunes));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
tooltip.add("");
|
||||
if (TextHelper.canTranslate(ritual.getUnlocalizedName() + ".info"))
|
||||
{
|
||||
if (TextHelper.canTranslate(ritual.getUnlocalizedName() + ".info")) {
|
||||
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(ritual.getUnlocalizedName() + ".info"))));
|
||||
tooltip.add("");
|
||||
}
|
||||
|
@ -340,19 +291,15 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
RayTraceResult ray = this.rayTrace(world, player, false);
|
||||
if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
|
||||
}
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (player.isSneaking()) {
|
||||
if (!world.isRemote) {
|
||||
cycleRitual(stack, player);
|
||||
}
|
||||
|
||||
|
@ -363,25 +310,19 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack)
|
||||
{
|
||||
if (entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) {
|
||||
if (entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entityLiving;
|
||||
|
||||
RayTraceResult ray = this.rayTrace(player.getEntityWorld(), player, false);
|
||||
if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!player.isSwingInProgress)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
{
|
||||
if (!player.isSwingInProgress) {
|
||||
if (player.isSneaking()) {
|
||||
cycleRitualBackwards(stack, player);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
cycleDirection(stack, player);
|
||||
}
|
||||
}
|
||||
|
@ -391,8 +332,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=basic"));
|
||||
ret.add(new ImmutablePair<Integer, String>(1, "type=dusk"));
|
||||
|
@ -400,41 +340,36 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
return ret;
|
||||
}
|
||||
|
||||
public void cycleDirection(ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
public void cycleDirection(ItemStack stack, EntityPlayer player) {
|
||||
EnumFacing direction = getDirection(stack);
|
||||
EnumFacing newDirection;
|
||||
switch (direction)
|
||||
{
|
||||
case NORTH:
|
||||
newDirection = EnumFacing.EAST;
|
||||
break;
|
||||
case EAST:
|
||||
newDirection = EnumFacing.SOUTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
newDirection = EnumFacing.WEST;
|
||||
break;
|
||||
case WEST:
|
||||
newDirection = EnumFacing.NORTH;
|
||||
break;
|
||||
default:
|
||||
newDirection = EnumFacing.NORTH;
|
||||
switch (direction) {
|
||||
case NORTH:
|
||||
newDirection = EnumFacing.EAST;
|
||||
break;
|
||||
case EAST:
|
||||
newDirection = EnumFacing.SOUTH;
|
||||
break;
|
||||
case SOUTH:
|
||||
newDirection = EnumFacing.WEST;
|
||||
break;
|
||||
case WEST:
|
||||
newDirection = EnumFacing.NORTH;
|
||||
break;
|
||||
default:
|
||||
newDirection = EnumFacing.NORTH;
|
||||
}
|
||||
|
||||
setDirection(stack, newDirection);
|
||||
notifyDirectionChange(newDirection, player);
|
||||
}
|
||||
|
||||
public void notifyDirectionChange(EnumFacing direction, EntityPlayer player)
|
||||
{
|
||||
public void notifyDirectionChange(EnumFacing direction, EntityPlayer player) {
|
||||
ChatUtil.sendNoSpam(player, TextHelper.localize(tooltipBase + "currentDirection", Utils.toFancyCasing(direction.getName())));
|
||||
}
|
||||
|
||||
public void setDirection(ItemStack stack, EnumFacing direction)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
public void setDirection(ItemStack stack, EnumFacing direction) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
|
@ -443,10 +378,8 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
}
|
||||
|
||||
public EnumFacing getDirection(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
public EnumFacing getDirection(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
|
@ -454,8 +387,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
int dir = tag.getInteger(Constants.NBT.DIRECTION);
|
||||
if (dir == 0)
|
||||
{
|
||||
if (dir == 0) {
|
||||
return EnumFacing.NORTH;
|
||||
}
|
||||
|
||||
|
@ -464,52 +396,42 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
|
||||
/**
|
||||
* Cycles the selected ritual to the next available ritual that is enabled.
|
||||
*
|
||||
* @param stack
|
||||
* - The ItemStack of the ritual diviner
|
||||
* @param player
|
||||
* - The player using the ritual diviner
|
||||
*
|
||||
* @param stack - The ItemStack of the ritual diviner
|
||||
* @param player - The player using the ritual diviner
|
||||
*/
|
||||
public void cycleRitual(ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
public void cycleRitual(ItemStack stack, EntityPlayer player) {
|
||||
String key = getCurrentRitual(stack);
|
||||
List<String> idList = RitualRegistry.getOrderedIds();
|
||||
String firstId = "";
|
||||
boolean foundId = false;
|
||||
boolean foundFirst = false;
|
||||
|
||||
for (String str : idList)
|
||||
{
|
||||
for (String str : idList) {
|
||||
Ritual ritual = RitualRegistry.getRitualForId(str);
|
||||
|
||||
if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual))
|
||||
{
|
||||
if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!foundFirst)
|
||||
{
|
||||
if (!foundFirst) {
|
||||
firstId = str;
|
||||
foundFirst = true;
|
||||
}
|
||||
|
||||
if (foundId)
|
||||
{
|
||||
if (foundId) {
|
||||
setCurrentRitual(stack, str);
|
||||
notifyRitualChange(str, player);
|
||||
return;
|
||||
} else
|
||||
{
|
||||
if (str.equals(key))
|
||||
{
|
||||
} else {
|
||||
if (str.equals(key)) {
|
||||
foundId = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundFirst)
|
||||
{
|
||||
if (foundFirst) {
|
||||
setCurrentRitual(stack, firstId);
|
||||
notifyRitualChange(firstId, player);
|
||||
}
|
||||
|
@ -517,68 +439,56 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
|
||||
/**
|
||||
* Does the same as cycleRitual but instead cycles backwards.
|
||||
*
|
||||
*
|
||||
* @param stack
|
||||
* @param player
|
||||
*/
|
||||
public void cycleRitualBackwards(ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
public void cycleRitualBackwards(ItemStack stack, EntityPlayer player) {
|
||||
String key = getCurrentRitual(stack);
|
||||
List<String> idList = RitualRegistry.getOrderedIds();
|
||||
String firstId = "";
|
||||
boolean foundId = false;
|
||||
boolean foundFirst = false;
|
||||
|
||||
for (int i = idList.size() - 1; i >= 0; i--)
|
||||
{
|
||||
for (int i = idList.size() - 1; i >= 0; i--) {
|
||||
String str = idList.get(i);
|
||||
Ritual ritual = RitualRegistry.getRitualForId(str);
|
||||
|
||||
if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual))
|
||||
{
|
||||
if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!foundFirst)
|
||||
{
|
||||
if (!foundFirst) {
|
||||
firstId = str;
|
||||
foundFirst = true;
|
||||
}
|
||||
|
||||
if (foundId)
|
||||
{
|
||||
if (foundId) {
|
||||
setCurrentRitual(stack, str);
|
||||
notifyRitualChange(str, player);
|
||||
return;
|
||||
} else
|
||||
{
|
||||
if (str.equals(key))
|
||||
{
|
||||
} else {
|
||||
if (str.equals(key)) {
|
||||
foundId = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundFirst)
|
||||
{
|
||||
if (foundFirst) {
|
||||
setCurrentRitual(stack, firstId);
|
||||
notifyRitualChange(firstId, player);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canDivinerPerformRitual(ItemStack stack, Ritual ritual)
|
||||
{
|
||||
if (ritual == null)
|
||||
{
|
||||
public boolean canDivinerPerformRitual(ItemStack stack, Ritual ritual) {
|
||||
if (ritual == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ArrayList<RitualComponent> components = ritual.getComponents();
|
||||
for (RitualComponent component : components)
|
||||
{
|
||||
if (!canPlaceRitualStone(component.getRuneType(), stack))
|
||||
{
|
||||
for (RitualComponent component : components) {
|
||||
if (!canPlaceRitualStone(component.getRuneType(), stack)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -586,19 +496,15 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
return true;
|
||||
}
|
||||
|
||||
public void notifyRitualChange(String key, EntityPlayer player)
|
||||
{
|
||||
public void notifyRitualChange(String key, EntityPlayer player) {
|
||||
Ritual ritual = RitualRegistry.getRitualForId(key);
|
||||
if (ritual != null)
|
||||
{
|
||||
if (ritual != null) {
|
||||
player.sendStatusMessage(new TextComponentTranslation(ritual.getUnlocalizedName()), true);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCurrentRitual(ItemStack stack, String key)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
public void setCurrentRitual(ItemStack stack, String key) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
|
@ -607,10 +513,8 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
tag.setString(Constants.NBT.CURRENT_RITUAL, key);
|
||||
}
|
||||
|
||||
public String getCurrentRitual(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
public String getCurrentRitual(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
|
@ -618,44 +522,37 @@ public class ItemRitualDiviner extends Item implements IVariantProvider
|
|||
return tag.getString(Constants.NBT.CURRENT_RITUAL);
|
||||
}
|
||||
|
||||
public boolean canPlaceRitualStone(EnumRuneType rune, ItemStack stack)
|
||||
{
|
||||
public boolean canPlaceRitualStone(EnumRuneType rune, ItemStack stack) {
|
||||
int meta = stack.getItemDamage();
|
||||
switch (rune)
|
||||
{
|
||||
case BLANK:
|
||||
case AIR:
|
||||
case EARTH:
|
||||
case FIRE:
|
||||
case WATER:
|
||||
return true;
|
||||
case DUSK:
|
||||
return meta >= 1;
|
||||
case DAWN:
|
||||
return meta >= 2;
|
||||
switch (rune) {
|
||||
case BLANK:
|
||||
case AIR:
|
||||
case EARTH:
|
||||
case FIRE:
|
||||
case WATER:
|
||||
return true;
|
||||
case DUSK:
|
||||
return meta >= 1;
|
||||
case DAWN:
|
||||
return meta >= 2;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void spawnParticles(World worldIn, BlockPos pos, int amount)
|
||||
{
|
||||
public static void spawnParticles(World worldIn, BlockPos pos, int amount) {
|
||||
IBlockState state = worldIn.getBlockState(pos);
|
||||
Block block = worldIn.getBlockState(pos).getBlock();
|
||||
|
||||
if (block.isAir(state, worldIn, pos))
|
||||
{
|
||||
for (int i = 0; i < amount; ++i)
|
||||
{
|
||||
if (block.isAir(state, worldIn, pos)) {
|
||||
for (int i = 0; i < amount; ++i) {
|
||||
double d0 = itemRand.nextGaussian() * 0.02D;
|
||||
double d1 = itemRand.nextGaussian() * 0.02D;
|
||||
double d2 = itemRand.nextGaussian() * 0.02D;
|
||||
worldIn.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, (double) ((float) pos.getX() + itemRand.nextFloat()), (double) pos.getY() + (double) itemRand.nextFloat(), (double) ((float) pos.getZ() + itemRand.nextFloat()), d0, d1, d2, new int[0]);
|
||||
}
|
||||
} else
|
||||
{
|
||||
for (int i1 = 0; i1 < amount; ++i1)
|
||||
{
|
||||
} else {
|
||||
for (int i1 = 0; i1 < amount; ++i1) {
|
||||
double d0 = itemRand.nextGaussian() * 0.02D;
|
||||
double d1 = itemRand.nextGaussian() * 0.02D;
|
||||
double d2 = itemRand.nextGaussian() * 0.02D;
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ritual.EnumRitualReaderState;
|
||||
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -18,27 +23,18 @@ import net.minecraft.util.text.TextComponentTranslation;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ritual.EnumRitualReaderState;
|
||||
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemRitualReader extends Item implements IVariantProvider
|
||||
{
|
||||
public class ItemRitualReader extends Item implements IVariantProvider {
|
||||
public static final String tooltipBase = "tooltip.bloodmagic.ritualReader.";
|
||||
|
||||
public ItemRitualReader()
|
||||
{
|
||||
public ItemRitualReader() {
|
||||
super();
|
||||
setUnlocalizedName(BloodMagic.MODID + ".ritualReader");
|
||||
setMaxStackSize(1);
|
||||
|
@ -46,8 +42,7 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag tooltipFlag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag tooltipFlag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
@ -58,11 +53,9 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
|
||||
boolean sneaking = Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT);
|
||||
|
||||
if (sneaking)
|
||||
{
|
||||
if (sneaking) {
|
||||
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(tooltipBase + "desc." + state.toString().toLowerCase()))));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.extraInfo"));
|
||||
}
|
||||
|
||||
|
@ -70,19 +63,15 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
RayTraceResult ray = this.rayTrace(world, player, false);
|
||||
if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
if (ray != null && ray.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
|
||||
}
|
||||
|
||||
if (player.isSneaking())
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (player.isSneaking()) {
|
||||
if (!world.isRemote) {
|
||||
cycleReader(stack, player);
|
||||
}
|
||||
|
||||
|
@ -93,80 +82,65 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
EnumRitualReaderState state = this.getState(stack);
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof IMasterRitualStone)
|
||||
{
|
||||
if (tile instanceof IMasterRitualStone) {
|
||||
IMasterRitualStone master = (IMasterRitualStone) tile;
|
||||
this.setMasterBlockPos(stack, pos);
|
||||
this.setBlockPos(stack, BlockPos.ORIGIN);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case INFORMATION:
|
||||
master.provideInformationOfRitualToPlayer(player);
|
||||
break;
|
||||
case SET_AREA:
|
||||
String range = this.getCurrentBlockRange(stack);
|
||||
if (player.isSneaking())
|
||||
{
|
||||
String newRange = master.getNextBlockRange(range);
|
||||
range = newRange;
|
||||
this.setCurrentBlockRange(stack, newRange);
|
||||
}
|
||||
|
||||
master.provideInformationOfRangeToPlayer(player, range);
|
||||
break;
|
||||
case SET_WILL_TYPES:
|
||||
List<EnumDemonWillType> typeList = new ArrayList<EnumDemonWillType>();
|
||||
NonNullList<ItemStack> inv = player.inventory.mainInventory;
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
ItemStack testStack = inv.get(i);
|
||||
if (testStack.isEmpty())
|
||||
{
|
||||
continue;
|
||||
switch (state) {
|
||||
case INFORMATION:
|
||||
master.provideInformationOfRitualToPlayer(player);
|
||||
break;
|
||||
case SET_AREA:
|
||||
String range = this.getCurrentBlockRange(stack);
|
||||
if (player.isSneaking()) {
|
||||
String newRange = master.getNextBlockRange(range);
|
||||
range = newRange;
|
||||
this.setCurrentBlockRange(stack, newRange);
|
||||
}
|
||||
|
||||
if (testStack.getItem() instanceof IDiscreteDemonWill)
|
||||
{
|
||||
EnumDemonWillType type = ((IDiscreteDemonWill) testStack.getItem()).getType(testStack);
|
||||
if (!typeList.contains(type))
|
||||
{
|
||||
typeList.add(type);
|
||||
master.provideInformationOfRangeToPlayer(player, range);
|
||||
break;
|
||||
case SET_WILL_TYPES:
|
||||
List<EnumDemonWillType> typeList = new ArrayList<EnumDemonWillType>();
|
||||
NonNullList<ItemStack> inv = player.inventory.mainInventory;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
ItemStack testStack = inv.get(i);
|
||||
if (testStack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (testStack.getItem() instanceof IDiscreteDemonWill) {
|
||||
EnumDemonWillType type = ((IDiscreteDemonWill) testStack.getItem()).getType(testStack);
|
||||
if (!typeList.contains(type)) {
|
||||
typeList.add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
master.setActiveWillConfig(player, typeList);
|
||||
master.provideInformationOfWillConfigToPlayer(player, typeList);
|
||||
break;
|
||||
master.setActiveWillConfig(player, typeList);
|
||||
master.provideInformationOfWillConfigToPlayer(player, typeList);
|
||||
break;
|
||||
}
|
||||
|
||||
return EnumActionResult.FAIL;
|
||||
} else
|
||||
{
|
||||
if (state == EnumRitualReaderState.SET_AREA)
|
||||
{
|
||||
} else {
|
||||
if (state == EnumRitualReaderState.SET_AREA) {
|
||||
BlockPos masterPos = this.getMasterBlockPos(stack);
|
||||
if (!masterPos.equals(BlockPos.ORIGIN))
|
||||
{
|
||||
if (!masterPos.equals(BlockPos.ORIGIN)) {
|
||||
BlockPos containedPos = getBlockPos(stack);
|
||||
if (containedPos.equals(BlockPos.ORIGIN))
|
||||
{
|
||||
if (containedPos.equals(BlockPos.ORIGIN)) {
|
||||
this.setBlockPos(stack, pos.subtract(masterPos));
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.bloodmagic.blockRange.firstBlock"));
|
||||
//TODO: Notify player.
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
tile = world.getTileEntity(masterPos);
|
||||
if (tile instanceof IMasterRitualStone)
|
||||
{
|
||||
if (tile instanceof IMasterRitualStone) {
|
||||
IMasterRitualStone master = (IMasterRitualStone) tile;
|
||||
master.setBlockRangeByBounds(player, this.getCurrentBlockRange(stack), containedPos, pos.subtract(masterPos));
|
||||
}
|
||||
|
@ -181,14 +155,12 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos(ItemStack stack)
|
||||
{
|
||||
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, BlockPos pos)
|
||||
{
|
||||
public ItemStack setBlockPos(ItemStack stack, BlockPos pos) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound itemTag = stack.getTagCompound();
|
||||
itemTag.setInteger(Constants.NBT.X_COORD, pos.getX());
|
||||
|
@ -197,14 +169,12 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
return stack;
|
||||
}
|
||||
|
||||
public BlockPos getMasterBlockPos(ItemStack stack)
|
||||
{
|
||||
public BlockPos getMasterBlockPos(ItemStack stack) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
return new BlockPos(stack.getTagCompound().getInteger(Constants.NBT.X_COORD + "master"), stack.getTagCompound().getInteger(Constants.NBT.Y_COORD + "master"), stack.getTagCompound().getInteger(Constants.NBT.Z_COORD + "master"));
|
||||
}
|
||||
|
||||
public ItemStack setMasterBlockPos(ItemStack stack, BlockPos pos)
|
||||
{
|
||||
public ItemStack setMasterBlockPos(ItemStack stack, BlockPos pos) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound itemTag = stack.getTagCompound();
|
||||
itemTag.setInteger(Constants.NBT.X_COORD + "master", pos.getX());
|
||||
|
@ -213,8 +183,7 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
return stack;
|
||||
}
|
||||
|
||||
public String getCurrentBlockRange(ItemStack stack)
|
||||
{
|
||||
public String getCurrentBlockRange(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -222,8 +191,7 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
return tag.getString("range");
|
||||
}
|
||||
|
||||
public void setCurrentBlockRange(ItemStack stack, String range)
|
||||
{
|
||||
public void setCurrentBlockRange(ItemStack stack, String range) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -231,8 +199,7 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
tag.setString("range", range);
|
||||
}
|
||||
|
||||
public void cycleReader(ItemStack stack, EntityPlayer player)
|
||||
{
|
||||
public void cycleReader(ItemStack stack, EntityPlayer player) {
|
||||
EnumRitualReaderState prevState = getState(stack);
|
||||
int val = prevState.ordinal();
|
||||
int nextVal = val + 1 >= EnumRitualReaderState.values().length ? 0 : val + 1;
|
||||
|
@ -242,13 +209,11 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
notifyPlayerOfStateChange(nextState, player);
|
||||
}
|
||||
|
||||
public void notifyPlayerOfStateChange(EnumRitualReaderState state, EntityPlayer player)
|
||||
{
|
||||
public void notifyPlayerOfStateChange(EnumRitualReaderState state, EntityPlayer player) {
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentState", new TextComponentTranslation(tooltipBase + state.toString().toLowerCase())));
|
||||
}
|
||||
|
||||
public void setState(ItemStack stack, EnumRitualReaderState state)
|
||||
{
|
||||
public void setState(ItemStack stack, EnumRitualReaderState state) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -256,10 +221,8 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
tag.setInteger(Constants.NBT.RITUAL_READER, state.ordinal());
|
||||
}
|
||||
|
||||
public EnumRitualReaderState getState(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
public EnumRitualReaderState getState(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
return EnumRitualReaderState.INFORMATION;
|
||||
}
|
||||
|
@ -270,8 +233,7 @@ public class ItemRitualReader extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=normal"));
|
||||
return ret;
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
@ -25,24 +30,15 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.event.SacrificeKnifeUsedEvent;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerSacrificeHelper;
|
||||
import WayofTime.bloodmagic.tile.TileAltar;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSacrificialDagger extends Item implements IMeshProvider
|
||||
{
|
||||
public static String[] names = { "normal", "creative" };
|
||||
public class ItemSacrificialDagger extends Item implements IMeshProvider {
|
||||
public static String[] names = {"normal", "creative"};
|
||||
|
||||
public ItemSacrificialDagger()
|
||||
{
|
||||
public ItemSacrificialDagger() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".sacrificialDagger.");
|
||||
|
@ -53,15 +49,13 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -70,8 +64,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag) {
|
||||
list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.sacrificialDagger.desc"))));
|
||||
|
||||
if (stack.getItemDamage() == 1)
|
||||
|
@ -79,33 +72,28 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft)
|
||||
{
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) {
|
||||
if (entityLiving instanceof EntityPlayer && !entityLiving.getEntityWorld().isRemote)
|
||||
PlayerSacrificeHelper.sacrificePlayerHealth((EntityPlayer) entityLiving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack stack)
|
||||
{
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (this.canUseForSacrifice(stack))
|
||||
{
|
||||
if (this.canUseForSacrifice(stack)) {
|
||||
player.setActiveHand(hand);
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
@ -113,27 +101,23 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider
|
|||
int lpAdded = ConfigHandler.sacrificialDaggerConversion * ConfigHandler.sacrificialDaggerDamage;
|
||||
|
||||
RayTraceResult rayTrace = rayTrace(world, player, false);
|
||||
if (rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
if (rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
TileEntity tile = world.getTileEntity(rayTrace.getBlockPos());
|
||||
|
||||
if (tile != null && tile instanceof TileAltar && stack.getItemDamage() == 1)
|
||||
lpAdded = ((TileAltar) tile).getCapacity();
|
||||
}
|
||||
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, ConfigHandler.sacrificialDaggerDamage, lpAdded);
|
||||
if (MinecraftForge.EVENT_BUS.post(evt))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (evt.shouldDrainHealth)
|
||||
{
|
||||
if (evt.shouldDrainHealth) {
|
||||
player.hurtResistantTime = 0;
|
||||
player.attackEntityFrom(BloodMagicAPI.damageSource, 0.001F);
|
||||
player.setHealth(Math.max(player.getHealth() - ConfigHandler.sacrificialDaggerDamage, 0.0001f));
|
||||
if (player.getHealth() <= 0.001f)
|
||||
{
|
||||
if (player.getHealth() <= 0.001f) {
|
||||
player.onDeath(BloodMagicAPI.damageSource);
|
||||
player.setHealth(0);
|
||||
}
|
||||
|
@ -164,38 +148,31 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5)
|
||||
{
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5) {
|
||||
if (!world.isRemote && entity instanceof EntityPlayer)
|
||||
this.setUseForSacrifice(stack, this.isPlayerPreparedForSacrifice(world, (EntityPlayer) entity));
|
||||
}
|
||||
|
||||
public boolean isPlayerPreparedForSacrifice(World world, EntityPlayer player)
|
||||
{
|
||||
public boolean isPlayerPreparedForSacrifice(World world, EntityPlayer player) {
|
||||
return !world.isRemote && (PlayerSacrificeHelper.getPlayerIncense(player) > 0);
|
||||
}
|
||||
|
||||
public boolean canUseForSacrifice(ItemStack stack)
|
||||
{
|
||||
public boolean canUseForSacrifice(ItemStack stack) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
return stack.getTagCompound().getBoolean(Constants.NBT.SACRIFICE);
|
||||
}
|
||||
|
||||
public void setUseForSacrifice(ItemStack stack, boolean sacrifice)
|
||||
{
|
||||
public void setUseForSacrifice(ItemStack stack, boolean sacrifice) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
stack.getTagCompound().setBoolean(Constants.NBT.SACRIFICE, sacrifice);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
return new ItemMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new ItemMeshDefinition() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
{
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
String variant = "type=normal";
|
||||
if (stack.getItemDamage() != 0)
|
||||
variant = "type=creative";
|
||||
|
@ -209,8 +186,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> variants = new ArrayList<String>();
|
||||
variants.add("type=normal");
|
||||
variants.add("type=creative");
|
||||
|
@ -220,8 +196,7 @@ public class ItemSacrificialDagger extends Item implements IMeshProvider
|
|||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -33,33 +33,27 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSanguineBook extends Item implements IVariantProvider, IAltarManipulator
|
||||
{
|
||||
public class ItemSanguineBook extends Item implements IVariantProvider, IAltarManipulator {
|
||||
private EnumAltarTier currentDisplayedTier = EnumAltarTier.ONE;
|
||||
|
||||
public ItemSanguineBook()
|
||||
{
|
||||
public ItemSanguineBook() {
|
||||
setUnlocalizedName(BloodMagic.MODID + ".sanguineBook");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
if (world.isRemote)
|
||||
return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
|
||||
IBlockState hitState = world.getBlockState(pos);
|
||||
if (player.isSneaking())
|
||||
{
|
||||
if (hitState.getBlock() instanceof IDocumentedBlock)
|
||||
{
|
||||
if (player.isSneaking()) {
|
||||
if (hitState.getBlock() instanceof IDocumentedBlock) {
|
||||
trySetDisplayedTier(world, pos);
|
||||
IDocumentedBlock documentedBlock = (IDocumentedBlock) hitState.getBlock();
|
||||
List<ITextComponent> docs = documentedBlock.getDocumentation(player, world, pos, hitState);
|
||||
if (!docs.isEmpty())
|
||||
{
|
||||
if (!docs.isEmpty()) {
|
||||
ChatUtil.sendNoSpam(player, docs.toArray(new ITextComponent[docs.size()]));
|
||||
return super.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ);
|
||||
}
|
||||
|
@ -70,8 +64,7 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (world.isRemote)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
@ -79,8 +72,7 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa
|
|||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
RayTraceResult rayTrace = rayTrace(world, player, false);
|
||||
if (rayTrace == null || rayTrace.typeOfHit == RayTraceResult.Type.MISS || rayTrace.typeOfHit == RayTraceResult.Type.ENTITY)
|
||||
{
|
||||
if (rayTrace == null || rayTrace.typeOfHit == RayTraceResult.Type.MISS || rayTrace.typeOfHit == RayTraceResult.Type.ENTITY) {
|
||||
if (stack.getTagCompound().getInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER) >= EnumAltarTier.MAXTIERS - 1)
|
||||
stack.getTagCompound().setInteger(Constants.NBT.ALTARMAKER_CURRENT_TIER, 0);
|
||||
else
|
||||
|
@ -95,11 +87,9 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa
|
|||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
public boolean trySetDisplayedTier(World world, BlockPos pos)
|
||||
{
|
||||
public boolean trySetDisplayedTier(World world, BlockPos pos) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileAltar)
|
||||
{
|
||||
if (tile instanceof TileAltar) {
|
||||
return !((TileAltar) tile).setCurrentTierDisplayed(currentDisplayedTier);
|
||||
}
|
||||
|
||||
|
@ -108,8 +98,7 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.book.shifting"));
|
||||
|
@ -120,8 +109,7 @@ public class ItemSanguineBook extends Item implements IVariantProvider, IAltarMa
|
|||
// IVariantProvider
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
return Collections.singletonList(Pair.of(0, "type=normal"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import WayofTime.bloodmagic.client.IVariantProvider;
|
|||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
@ -19,12 +18,10 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSlate extends Item implements IVariantProvider
|
||||
{
|
||||
public String[] names = { "blank", "reinforced", "imbued", "demonic", "ethereal" };
|
||||
public class ItemSlate extends Item implements IVariantProvider {
|
||||
public String[] names = {"blank", "reinforced", "imbued", "demonic", "ethereal"};
|
||||
|
||||
public ItemSlate()
|
||||
{
|
||||
public ItemSlate() {
|
||||
super();
|
||||
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -34,8 +31,7 @@ public class ItemSlate extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -44,21 +40,18 @@ public class ItemSlate extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag) {
|
||||
list.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.slate.desc"))));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=blank"));
|
||||
ret.add(new ImmutablePair<Integer, String>(1, "type=reinforced"));
|
||||
|
|
|
@ -8,7 +8,6 @@ import WayofTime.bloodmagic.util.helper.TextHelper;
|
|||
import net.minecraft.client.util.ITooltipFlag;
|
||||
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.ActionResult;
|
||||
|
@ -27,12 +26,10 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemTelepositionFocus extends ItemBindableBase implements IVariantProvider
|
||||
{
|
||||
public static String[] names = { "weak", "enhanced", "reinforced", "demonic" };
|
||||
public class ItemTelepositionFocus extends ItemBindableBase implements IVariantProvider {
|
||||
public static String[] names = {"weak", "enhanced", "reinforced", "demonic"};
|
||||
|
||||
public ItemTelepositionFocus()
|
||||
{
|
||||
public ItemTelepositionFocus() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".focus.");
|
||||
|
@ -42,15 +39,13 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -59,14 +54,11 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
if (player.isSneaking()) {
|
||||
RayTraceResult mop = rayTrace(world, player, false);
|
||||
|
||||
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
setBlockPos(player.getHeldItem(hand), world, mop.getBlockPos());
|
||||
}
|
||||
}
|
||||
|
@ -76,8 +68,7 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localize("tooltip.bloodmagic.telepositionFocus." + names[stack.getItemDamage()]))));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
|
@ -89,16 +80,14 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP
|
|||
NBTTagCompound tag = stack.getTagCompound();
|
||||
BlockPos coords = getBlockPos(stack);
|
||||
|
||||
if (coords != null && tag != null)
|
||||
{
|
||||
if (coords != null && tag != null) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", coords.getX(), coords.getY(), coords.getZ()));
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.dimension", tag.getInteger(Constants.NBT.DIMENSION_ID)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=weak"));
|
||||
ret.add(new ImmutablePair<Integer, String>(1, "type=enhanced"));
|
||||
|
@ -107,20 +96,17 @@ public class ItemTelepositionFocus extends ItemBindableBase implements IVariantP
|
|||
return ret;
|
||||
}
|
||||
|
||||
public World getWorld(ItemStack stack)
|
||||
{
|
||||
public World getWorld(ItemStack stack) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
return DimensionManager.getWorld(stack.getTagCompound().getInteger(Constants.NBT.DIMENSION_ID));
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos(ItemStack stack)
|
||||
{
|
||||
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)
|
||||
{
|
||||
public ItemStack setBlockPos(ItemStack stack, World world, BlockPos pos) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound itemTag = stack.getTagCompound();
|
||||
itemTag.setInteger(Constants.NBT.X_COORD, pos.getX());
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package WayofTime.bloodmagic.item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -16,23 +20,15 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.util.helper.ItemHelper.LivingUpgrades;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class ItemUpgradeTome extends Item implements IVariantProvider
|
||||
{
|
||||
public ItemUpgradeTome()
|
||||
{
|
||||
public class ItemUpgradeTome extends Item implements IVariantProvider {
|
||||
public ItemUpgradeTome() {
|
||||
super();
|
||||
|
||||
setCreativeTab(BloodMagic.TAB_TOMES);
|
||||
|
@ -42,31 +38,25 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (world.isRemote)
|
||||
{
|
||||
if (world.isRemote) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
|
||||
if (upgrade == null)
|
||||
{
|
||||
if (upgrade == null) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
if (chestStack.getItem() instanceof ItemLivingArmour)
|
||||
{
|
||||
if (chestStack.getItem() instanceof ItemLivingArmour) {
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(chestStack);
|
||||
if (armour == null)
|
||||
{
|
||||
if (armour == null) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
if (armour.upgradeArmour(player, upgrade))
|
||||
{
|
||||
if (armour.upgradeArmour(player, upgrade)) {
|
||||
ItemLivingArmour.setLivingArmour(chestStack, armour);
|
||||
// ((ItemLivingArmour) chestStack.getItem()).setLivingArmour(stack, armour, false);
|
||||
stack.shrink(1);
|
||||
|
@ -89,17 +79,14 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
for (Entry<String, Integer> entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet())
|
||||
{
|
||||
for (Entry<String, Integer> entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
int maxLevel = entry.getValue();
|
||||
for (int i = 0; i < maxLevel; i++)
|
||||
{
|
||||
for (int i = 0; i < maxLevel; i++) {
|
||||
ItemStack stack = new ItemStack(this);
|
||||
LivingUpgrades.setKey(stack, key);
|
||||
LivingUpgrades.setLevel(stack, i);
|
||||
|
@ -109,8 +96,7 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=upgradetome"));
|
||||
return ret;
|
||||
|
@ -118,13 +104,11 @@ public class ItemUpgradeTome extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
|
||||
if (upgrade != null)
|
||||
{
|
||||
if (upgrade != null) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import WayofTime.bloodmagic.client.IVariantProvider;
|
|||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.NonNullList;
|
||||
|
@ -23,10 +22,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVariantProvider
|
||||
{
|
||||
public ItemUpgradeTrainer()
|
||||
{
|
||||
public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVariantProvider {
|
||||
public ItemUpgradeTrainer() {
|
||||
super();
|
||||
|
||||
setCreativeTab(BloodMagic.TAB_TOMES);
|
||||
|
@ -37,14 +34,12 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
list.add(new ItemStack(this));
|
||||
for (Entry<String, Integer> entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet())
|
||||
{
|
||||
for (Entry<String, Integer> entry : LivingArmourHandler.upgradeMaxLevelMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
ItemStack stack = new ItemStack(this);
|
||||
LivingUpgrades.setKey(stack, key);
|
||||
|
@ -54,26 +49,22 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour"))));
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
LivingArmourUpgrade upgrade = LivingUpgrades.getUpgrade(stack);
|
||||
if (upgrade != null)
|
||||
{
|
||||
if (upgrade != null) {
|
||||
tooltip.add(TextHelper.localize(upgrade.getUnlocalizedName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTrainedUpgrades(ItemStack stack)
|
||||
{
|
||||
public List<String> getTrainedUpgrades(ItemStack stack) {
|
||||
List<String> keyList = new ArrayList<String>();
|
||||
String key = LivingUpgrades.getKey(stack);
|
||||
|
||||
if (!key.isEmpty())
|
||||
{
|
||||
if (!key.isEmpty()) {
|
||||
keyList.add(key);
|
||||
}
|
||||
|
||||
|
@ -81,10 +72,8 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setTrainedUpgrades(ItemStack stack, List<String> keys)
|
||||
{
|
||||
if (keys.isEmpty())
|
||||
{
|
||||
public boolean setTrainedUpgrades(ItemStack stack, List<String> keys) {
|
||||
if (keys.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -93,8 +82,7 @@ public class ItemUpgradeTrainer extends Item implements IUpgradeTrainer, IVarian
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=upgradetrainer"));
|
||||
return ret;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package WayofTime.bloodmagic.item.alchemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -12,26 +15,18 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.iface.ICustomAlchemyConsumable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ItemCuttingFluid extends Item implements IVariantProvider, ICustomAlchemyConsumable
|
||||
{
|
||||
private static ArrayList<String> names = new ArrayList<String>();
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemCuttingFluid extends Item implements IVariantProvider, ICustomAlchemyConsumable {
|
||||
public static final String BASIC = "basicCuttingFluid";
|
||||
public static final String EXPLOSIVE = "explosive";
|
||||
private static ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
public ItemCuttingFluid()
|
||||
{
|
||||
public ItemCuttingFluid() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".cuttingFluid.");
|
||||
|
@ -44,30 +39,26 @@ public class ItemCuttingFluid extends Item implements IVariantProvider, ICustomA
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
int max = getMaxUsesForFluid(stack);
|
||||
tooltip.add(TextHelper.localize("tooltip.bloodmagic.cuttingFluidRatio", max - getDamageOfFluid(stack), max));
|
||||
}
|
||||
|
||||
private void buildItemList()
|
||||
{
|
||||
private void buildItemList() {
|
||||
names.add(0, BASIC);
|
||||
names.add(1, EXPLOSIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names.get(stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -75,73 +66,63 @@ public class ItemCuttingFluid extends Item implements IVariantProvider, ICustomA
|
|||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String name)
|
||||
{
|
||||
return new ItemStack(RegistrarBloodMagicItems.CUTTING_FLUID, 1, names.indexOf(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
for (String name : names)
|
||||
ret.add(new ImmutablePair<Integer, String>(names.indexOf(name), "type=" + name));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getDamageOfFluid(ItemStack stack)
|
||||
{
|
||||
public int getDamageOfFluid(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getInteger("used");
|
||||
}
|
||||
|
||||
public void applyDamageToFluid(ItemStack stack)
|
||||
{
|
||||
public void applyDamageToFluid(ItemStack stack) {
|
||||
int damage = Math.min(getDamageOfFluid(stack) + 1, getMaxUsesForFluid(stack));
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setInteger("used", damage);
|
||||
}
|
||||
|
||||
public int getMaxUsesForFluid(ItemStack stack)
|
||||
{
|
||||
switch (stack.getMetadata())
|
||||
{
|
||||
case 0:
|
||||
return 16;
|
||||
case 1:
|
||||
return 64;
|
||||
default:
|
||||
return 1;
|
||||
public int getMaxUsesForFluid(ItemStack stack) {
|
||||
switch (stack.getMetadata()) {
|
||||
case 0:
|
||||
return 16;
|
||||
case 1:
|
||||
return 64;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
return (double) (getDamageOfFluid(stack)) / (double) (getMaxUsesForFluid(stack));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack)
|
||||
{
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
return getDamageOfFluid(stack) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack drainUseOnAlchemyCraft(ItemStack stack)
|
||||
{
|
||||
public ItemStack drainUseOnAlchemyCraft(ItemStack stack) {
|
||||
applyDamageToFluid(stack);
|
||||
if (getDamageOfFluid(stack) >= getMaxUsesForFluid(stack))
|
||||
{
|
||||
if (getDamageOfFluid(stack) >= getMaxUsesForFluid(stack)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String name) {
|
||||
return new ItemStack(RegistrarBloodMagicItems.CUTTING_FLUID, 1, names.indexOf(name));
|
||||
}
|
||||
|
||||
public static ArrayList<String> getNames() {
|
||||
return names;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package WayofTime.bloodmagic.item.alchemy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.collect.Iterables;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -20,27 +23,18 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvider
|
||||
{
|
||||
public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvider {
|
||||
public static final String DRAFT_ANGELUS = "draftAngelus";
|
||||
private static ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
public static final String DRAFT_ANGELUS = "draftAngelus";
|
||||
|
||||
public ItemLivingArmourPointsUpgrade()
|
||||
{
|
||||
public ItemLivingArmourPointsUpgrade() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".livingPointUpgrade.");
|
||||
|
@ -52,8 +46,7 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
@ -61,29 +54,23 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
|
||||
{
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) {
|
||||
EntityPlayer player = entityLiving instanceof EntityPlayer ? (EntityPlayer) entityLiving : null;
|
||||
|
||||
if (player == null || !player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (player == null || !player.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
if (!worldIn.isRemote)
|
||||
{
|
||||
if (!worldIn.isRemote) {
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.WITHER, 300, 5));
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.POISON, 300, 5));
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 400, 1));
|
||||
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = Iterables.toArray(player.getArmorInventoryList(), ItemStack.class)[2];
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour.maxUpgradePoints < 200)
|
||||
{
|
||||
if (armour != null) {
|
||||
if (armour.maxUpgradePoints < 200) {
|
||||
armour.maxUpgradePoints = 200;
|
||||
((ItemLivingArmour) chestStack.getItem()).setLivingArmour(chestStack, armour, true);
|
||||
ItemLivingArmour.setLivingArmour(chestStack, armour);
|
||||
|
@ -96,39 +83,33 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack stack)
|
||||
{
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack)
|
||||
{
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.DRINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
||||
playerIn.setActiveHand(hand);
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
|
||||
}
|
||||
|
||||
private void buildItemList()
|
||||
{
|
||||
private void buildItemList() {
|
||||
names.add(0, DRAFT_ANGELUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names.get(stack.getItemDamage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -136,22 +117,19 @@ public class ItemLivingArmourPointsUpgrade extends Item implements IVariantProvi
|
|||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String name)
|
||||
{
|
||||
return new ItemStack(RegistrarBloodMagicItems.POINTS_UPGRADE, 1, names.indexOf(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
for (String name : names)
|
||||
ret.add(new ImmutablePair<Integer, String>(names.indexOf(name), "type=" + name));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String key, int stackSize)
|
||||
{
|
||||
public static ItemStack getStack(String name) {
|
||||
return new ItemStack(RegistrarBloodMagicItems.POINTS_UPGRADE, 1, names.indexOf(name));
|
||||
}
|
||||
|
||||
public static ItemStack getStack(String key, int stackSize) {
|
||||
ItemStack stack = getStack(key);
|
||||
stack.setCount(stackSize);
|
||||
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
package WayofTime.bloodmagic.item.armour;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
|
||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.item.ItemComponent;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerRepairing;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeElytra;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.PlayerFallDistancePacketProcessor;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
|
@ -29,46 +40,22 @@ import net.minecraftforge.common.ISpecialArmor;
|
|||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
|
||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.item.ItemComponent;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerRepairing;
|
||||
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeElytra;
|
||||
import WayofTime.bloodmagic.network.BloodMagicPacketHandler;
|
||||
import WayofTime.bloodmagic.network.PlayerFallDistancePacketProcessor;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider
|
||||
{
|
||||
private static Field _FLAGS = ReflectionHelper.findField(Entity.class, "FLAGS", "field_184240_ax");
|
||||
|
||||
private static DataParameter<Byte> FLAGS = null;
|
||||
public static String[] names = { "helmet", "chest", "legs", "boots" };
|
||||
|
||||
public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshProvider {
|
||||
public static final boolean useSpecialArmourCalculation = true;
|
||||
|
||||
public static String[] names = {"helmet", "chest", "legs", "boots"};
|
||||
//TODO: Save/delete cache periodically.
|
||||
public static Map<UUID, LivingArmour> armourMap = new HashMap<UUID, LivingArmour>();
|
||||
private static Field _FLAGS = ReflectionHelper.findField(Entity.class, "FLAGS", "field_184240_ax");
|
||||
private static DataParameter<Byte> FLAGS = null;
|
||||
|
||||
public ItemLivingArmour(EntityEquipmentSlot armorType)
|
||||
{
|
||||
public ItemLivingArmour(EntityEquipmentSlot armorType) {
|
||||
super(ItemArmor.ArmorMaterial.IRON, 0, armorType);
|
||||
setUnlocalizedName(BloodMagic.MODID + ".livingArmour.");
|
||||
// setMaxDamage(250);
|
||||
|
@ -77,27 +64,21 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (stack != null && !world.isRemote && stack.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
public void onCreated(ItemStack stack, World world, EntityPlayer player) {
|
||||
if (stack != null && !world.isRemote && stack.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
Utils.setUUID(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET || this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS)
|
||||
{
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET || this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS) {
|
||||
return "bloodmagic:models/armor/livingArmour_layer_1.png";
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) {
|
||||
return "bloodmagic:models/armor/livingArmour_layer_2.png";
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -115,25 +96,20 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
// }
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
|
||||
return ItemStack.areItemsEqual(repair, ItemComponent.getStack(ItemComponent.REAGENT_BINDING));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot)
|
||||
{
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) {
|
||||
double armourReduction = 0.0;
|
||||
double damageAmount = 0.25;
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) {
|
||||
damageAmount = 3d / 20d * 0.6;
|
||||
} else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS)
|
||||
{
|
||||
} else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) {
|
||||
damageAmount = 6d / 20d * 0.6;
|
||||
} else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
} else if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
damageAmount = 0.64;
|
||||
}
|
||||
|
||||
|
@ -141,42 +117,34 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
|
||||
int maxAbsorption = 100000;
|
||||
|
||||
if (source.equals(DamageSource.DROWN))
|
||||
{
|
||||
if (source.equals(DamageSource.DROWN)) {
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (source.equals(DamageSource.OUT_OF_WORLD))
|
||||
{
|
||||
if (source.equals(DamageSource.OUT_OF_WORLD)) {
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
armourReduction = 0.24 / 0.64; // This values puts it at iron level
|
||||
|
||||
ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||
ItemStack leggings = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
|
||||
ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
||||
|
||||
if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty())
|
||||
{
|
||||
if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) {
|
||||
damageAmount *= (armourReduction);
|
||||
|
||||
return new ArmorProperties(-1, damageAmount, maxAbsorption);
|
||||
}
|
||||
|
||||
if (helmet.getItem() instanceof ItemLivingArmour && leggings.getItem() instanceof ItemLivingArmour && boots.getItem() instanceof ItemLivingArmour)
|
||||
{
|
||||
if (helmet.getItem() instanceof ItemLivingArmour && leggings.getItem() instanceof ItemLivingArmour && boots.getItem() instanceof ItemLivingArmour) {
|
||||
double remainder = 1; // Multiply this number by the armour upgrades for protection
|
||||
|
||||
if (hasLivingArmour(stack))
|
||||
{
|
||||
if (hasLivingArmour(stack)) {
|
||||
LivingArmour armour = getLivingArmour(stack);
|
||||
if (armour != null && isEnabled(stack))
|
||||
{
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
|
||||
{
|
||||
if (armour != null && isEnabled(stack)) {
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
|
||||
LivingArmourUpgrade upgrade = entry.getValue();
|
||||
remainder *= (1 - upgrade.getArmourProtection(player, source));
|
||||
}
|
||||
|
@ -193,10 +161,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
|
||||
return new ArmorProperties(-1, source.isUnblockable() ? 1 - remainder : damageAmount, maxAbsorption);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (source.isUnblockable())
|
||||
{
|
||||
} else {
|
||||
if (source.isUnblockable()) {
|
||||
return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
|
||||
}
|
||||
|
||||
|
@ -207,25 +173,20 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET)
|
||||
{
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_LEGS) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_BOOTS) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -233,21 +194,16 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
int preDamage = stack.getItemDamage();
|
||||
if (source.isUnblockable())
|
||||
{
|
||||
if (source.isUnblockable()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (damage > this.getMaxDamage(stack) - this.getDamage(stack))
|
||||
{
|
||||
if (damage > this.getMaxDamage(stack) - this.getDamage(stack)) {
|
||||
//TODO: Syphon a load of LP.
|
||||
if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer)
|
||||
{
|
||||
if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(player);
|
||||
network.syphonAndDamage(player, damage * 100);
|
||||
|
@ -259,21 +215,17 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
stack.damageItem(damage, entity);
|
||||
|
||||
int receivedDamage = stack.getItemDamage() - preDamage;
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(stack);
|
||||
if (armour != null)
|
||||
{
|
||||
if (armour != null) {
|
||||
StatTrackerRepairing.incrementCounter(armour, receivedDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
stack.damageItem(damage, entity);
|
||||
}
|
||||
|
||||
|
@ -282,46 +234,36 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
LivingArmour armour = getLivingArmourFromStack(stack);
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
|
||||
{
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
|
||||
LivingArmourUpgrade upgrade = entry.getValue();
|
||||
if (upgrade != null)
|
||||
{
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M))
|
||||
{
|
||||
if (upgrade != null) {
|
||||
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M)) {
|
||||
StatTracker tracker = null;
|
||||
for (StatTracker searchTracker : armour.trackerMap.values())
|
||||
{
|
||||
if (searchTracker != null && searchTracker.providesUpgrade(upgrade.getUniqueIdentifier()))
|
||||
{
|
||||
for (StatTracker searchTracker : armour.trackerMap.values()) {
|
||||
if (searchTracker != null && searchTracker.providesUpgrade(upgrade.getUniqueIdentifier())) {
|
||||
tracker = searchTracker;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tracker != null)
|
||||
{
|
||||
if (tracker != null) {
|
||||
double progress = tracker.getProgress(armour, upgrade.getUpgradeLevel());
|
||||
tooltip.add(TextHelper.localize("tooltip.bloodmagic.livingArmour.upgrade.progress", TextHelper.localize(upgrade.getUnlocalizedName()), MathHelper.clamp((int) (progress * 100D), 0, 100)));
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
tooltip.add(TextHelper.localize("tooltip.bloodmagic.livingArmour.upgrade.level", TextHelper.localize(upgrade.getUnlocalizedName()), upgrade.getUpgradeLevel() + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.upgrade.points", armour.totalUpgradePoints, armour.maxUpgradePoints));
|
||||
if (!(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M)))
|
||||
{
|
||||
if (!(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && Keyboard.isKeyDown(Keyboard.KEY_M))) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.livingArmour.extraExtraInfo"));
|
||||
}
|
||||
}
|
||||
|
@ -330,52 +272,39 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
|
||||
super.onArmorTick(world, player, stack);
|
||||
|
||||
if (world.isRemote && this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (world.isRemote && this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
if (player instanceof EntityPlayerSP) //Sanity check
|
||||
{
|
||||
EntityPlayerSP spPlayer = (EntityPlayerSP) player;
|
||||
|
||||
if (FLAGS == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (FLAGS == null) {
|
||||
try {
|
||||
FLAGS = (DataParameter<Byte>) _FLAGS.get(null);
|
||||
} catch (IllegalArgumentException e)
|
||||
{
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e)
|
||||
{
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (FLAGS != null)
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (FLAGS != null) {
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.elytra", chestStack);
|
||||
if (upgrade instanceof LivingArmourUpgradeElytra)
|
||||
{
|
||||
if (spPlayer.movementInput.jump && !spPlayer.onGround && spPlayer.motionY < 0.0D && !spPlayer.capabilities.isFlying)
|
||||
{
|
||||
if (spPlayer.motionY > -0.5D)
|
||||
{
|
||||
if (upgrade instanceof LivingArmourUpgradeElytra) {
|
||||
if (spPlayer.movementInput.jump && !spPlayer.onGround && spPlayer.motionY < 0.0D && !spPlayer.capabilities.isFlying) {
|
||||
if (spPlayer.motionY > -0.5D) {
|
||||
BloodMagicPacketHandler.INSTANCE.sendToServer(new PlayerFallDistancePacketProcessor(1));
|
||||
}
|
||||
|
||||
if (!spPlayer.isElytraFlying())
|
||||
{
|
||||
if (!spPlayer.isElytraFlying()) {
|
||||
byte b0 = player.getDataManager().get(FLAGS);
|
||||
player.getDataManager().set(FLAGS, (byte) (b0 | 1 << 7));
|
||||
}
|
||||
} else if (spPlayer.isElytraFlying() && !spPlayer.movementInput.jump && !spPlayer.onGround)
|
||||
{
|
||||
} else if (spPlayer.isElytraFlying() && !spPlayer.movementInput.jump && !spPlayer.onGround) {
|
||||
byte b0 = player.getDataManager().get(FLAGS);
|
||||
player.getDataManager().set(FLAGS, (byte) (b0 & ~(1 << 7)));
|
||||
}
|
||||
|
@ -385,16 +314,13 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST)
|
||||
{
|
||||
if (!hasLivingArmour(stack))
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
|
||||
if (!hasLivingArmour(stack)) {
|
||||
setLivingArmour(stack, getLivingArmourFromStack(stack));
|
||||
}
|
||||
|
||||
LivingArmour armour = getLivingArmour(stack);
|
||||
if (LivingArmour.hasFullSet(player))
|
||||
{
|
||||
if (LivingArmour.hasFullSet(player)) {
|
||||
this.setIsEnabled(stack, true);
|
||||
armour.onTick(world, player);
|
||||
}
|
||||
|
@ -404,10 +330,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST && isEnabled(stack) && slot == EntityEquipmentSlot.CHEST)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST && isEnabled(stack) && slot == EntityEquipmentSlot.CHEST) {
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmourFromStack(stack);
|
||||
|
||||
return armour.getAttributeModifiers();
|
||||
|
@ -417,20 +341,16 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[3 - armorType.getIndex()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
return new ItemMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new ItemMeshDefinition() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
{
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
assert getCustomLocation() != null;
|
||||
if (stack.getItem() == RegistrarBloodMagicItems.LIVING_ARMOUR_HELMET)
|
||||
return new ModelResourceLocation(getCustomLocation(), "armour=head");
|
||||
|
@ -445,14 +365,12 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return new ResourceLocation(BloodMagic.MODID, "item/ItemLivingArmour");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("armour=head");
|
||||
ret.add("armour=body");
|
||||
|
@ -461,48 +379,21 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LivingArmour getLivingArmourFromStack(ItemStack stack)
|
||||
{
|
||||
NBTTagCompound livingTag = getArmourTag(stack);
|
||||
|
||||
LivingArmour livingArmour = new LivingArmour();
|
||||
livingArmour.readFromNBT(livingTag);
|
||||
|
||||
return livingArmour;
|
||||
}
|
||||
|
||||
public void setLivingArmour(ItemStack stack, LivingArmour armour, boolean forceWrite)
|
||||
{
|
||||
public void setLivingArmour(ItemStack stack, LivingArmour armour, boolean forceWrite) {
|
||||
NBTTagCompound livingTag = new NBTTagCompound();
|
||||
|
||||
if (!forceWrite)
|
||||
{
|
||||
if (!forceWrite) {
|
||||
livingTag = getArmourTag(stack);
|
||||
armour.writeDirtyToNBT(livingTag);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
armour.writeToNBT(livingTag);
|
||||
}
|
||||
|
||||
setArmourTag(stack, livingTag);
|
||||
}
|
||||
|
||||
public static NBTTagCompound getArmourTag(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getCompoundTag(Constants.NBT.LIVING_ARMOUR);
|
||||
}
|
||||
|
||||
public void setArmourTag(ItemStack stack, NBTTagCompound livingTag)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
public void setArmourTag(ItemStack stack, NBTTagCompound livingTag) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
|
@ -511,20 +402,59 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
tag.setTag(Constants.NBT.LIVING_ARMOUR, livingTag);
|
||||
}
|
||||
|
||||
public void setIsEnabled(ItemStack stack, boolean bool) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
tag.setBoolean("enabled", bool);
|
||||
}
|
||||
|
||||
public boolean isEnabled(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getBoolean("enabled");
|
||||
}
|
||||
|
||||
public void setIsElytra(ItemStack stack, boolean bool) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
tag.setBoolean("elytra", bool);
|
||||
}
|
||||
|
||||
public boolean isElytra(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getBoolean("elytra");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LivingArmour getLivingArmourFromStack(ItemStack stack) {
|
||||
NBTTagCompound livingTag = getArmourTag(stack);
|
||||
|
||||
LivingArmour livingArmour = new LivingArmour();
|
||||
livingArmour.readFromNBT(livingTag);
|
||||
|
||||
return livingArmour;
|
||||
}
|
||||
|
||||
public static NBTTagCompound getArmourTag(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getCompoundTag(Constants.NBT.LIVING_ARMOUR);
|
||||
}
|
||||
|
||||
//TODO: Add the ability to have the armour give an upgrade with a higher level
|
||||
public static LivingArmourUpgrade getUpgrade(String uniqueIdentifier, ItemStack stack)
|
||||
{
|
||||
if (!hasLivingArmour(stack))
|
||||
{
|
||||
public static LivingArmourUpgrade getUpgrade(String uniqueIdentifier, ItemStack stack) {
|
||||
if (!hasLivingArmour(stack)) {
|
||||
setLivingArmour(stack, getLivingArmourFromStack(stack));
|
||||
}
|
||||
|
||||
LivingArmour armour = getLivingArmour(stack);
|
||||
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
|
||||
{
|
||||
if (entry.getKey().equals(uniqueIdentifier))
|
||||
{
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
|
||||
if (entry.getKey().equals(uniqueIdentifier)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -532,14 +462,11 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
return null;
|
||||
}
|
||||
|
||||
public static LivingArmourUpgrade getUpgradeFromNBT(String uniqueIdentifier, ItemStack stack)
|
||||
{
|
||||
public static LivingArmourUpgrade getUpgradeFromNBT(String uniqueIdentifier, ItemStack stack) {
|
||||
LivingArmour armour = getLivingArmourFromStack(stack);
|
||||
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet())
|
||||
{
|
||||
if (entry.getKey().equals(uniqueIdentifier))
|
||||
{
|
||||
for (Entry<String, LivingArmourUpgrade> entry : armour.upgradeMap.entrySet()) {
|
||||
if (entry.getKey().equals(uniqueIdentifier)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
|
@ -547,24 +474,20 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
return null;
|
||||
}
|
||||
|
||||
public static boolean hasLivingArmour(ItemStack stack)
|
||||
{
|
||||
public static boolean hasLivingArmour(ItemStack stack) {
|
||||
UUID uuid = Utils.getUUID(stack);
|
||||
return uuid != null && armourMap.containsKey(uuid);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static LivingArmour getLivingArmour(ItemStack stack)
|
||||
{
|
||||
public static LivingArmour getLivingArmour(ItemStack stack) {
|
||||
UUID uuid = Utils.getUUID(stack);
|
||||
|
||||
return armourMap.get(uuid);
|
||||
}
|
||||
|
||||
public static void setLivingArmour(ItemStack stack, LivingArmour armour)
|
||||
{
|
||||
if (!Utils.hasUUID(stack))
|
||||
{
|
||||
public static void setLivingArmour(ItemStack stack, LivingArmour armour) {
|
||||
if (!Utils.hasUUID(stack)) {
|
||||
Utils.setUUID(stack);
|
||||
}
|
||||
|
||||
|
@ -573,10 +496,8 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
armourMap.put(uuid, armour);
|
||||
}
|
||||
|
||||
public static boolean hasUpgrade(String id, ItemStack stack)
|
||||
{
|
||||
if (!hasLivingArmour(stack))
|
||||
{
|
||||
public static boolean hasUpgrade(String id, ItemStack stack) {
|
||||
if (!hasLivingArmour(stack)) {
|
||||
setLivingArmour(stack, getLivingArmourFromStack(stack));
|
||||
}
|
||||
|
||||
|
@ -584,32 +505,4 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
|
|||
|
||||
return armour.upgradeMap.containsKey(id);
|
||||
}
|
||||
|
||||
public void setIsEnabled(ItemStack stack, boolean bool)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
tag.setBoolean("enabled", bool);
|
||||
}
|
||||
|
||||
public boolean isEnabled(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getBoolean("enabled");
|
||||
}
|
||||
|
||||
public void setIsElytra(ItemStack stack, boolean bool)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
tag.setBoolean("elytra", bool);
|
||||
}
|
||||
|
||||
public boolean isElytra(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getBoolean("elytra");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
package WayofTime.bloodmagic.item.armour;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
|
@ -24,37 +32,26 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.common.ISpecialArmor;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMeshProvider, IMultiWillTool
|
||||
{
|
||||
public static String[] names = { "helmet", "chest", "legs", "boots" };
|
||||
public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMeshProvider, IMultiWillTool {
|
||||
public static String[] names = {"helmet", "chest", "legs", "boots"};
|
||||
|
||||
public static double[] willBracket = new double[] { 30, 200, 600, 1500, 4000, 6000, 8000, 16000 };
|
||||
public static double[] consumptionPerHit = new double[] { 0.1, 0.12, 0.15, 0.2, 0.3, 0.35, 0.4, 0.5 };
|
||||
public static double[] extraProtectionLevel = new double[] { 0, 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9 };
|
||||
public static double[] steadfastProtectionLevel = new double[] { 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9, 0.95 };
|
||||
public static double[] willBracket = new double[]{30, 200, 600, 1500, 4000, 6000, 8000, 16000};
|
||||
public static double[] consumptionPerHit = new double[]{0.1, 0.12, 0.15, 0.2, 0.3, 0.35, 0.4, 0.5};
|
||||
public static double[] extraProtectionLevel = new double[]{0, 0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9};
|
||||
public static double[] steadfastProtectionLevel = new double[]{0.25, 0.5, 0.6, 0.7, 0.75, 0.85, 0.9, 0.95};
|
||||
|
||||
//public static double[] healthBonus = new double[] { 3, 6, 9, 12, 15, 20, 25, 30 };
|
||||
public static double[] knockbackBonus = new double[] { 0.2, 0.4, 0.6, 0.8, 1, 1, 1, 1 };
|
||||
public static double[] knockbackBonus = new double[]{0.2, 0.4, 0.6, 0.8, 1, 1, 1, 1};
|
||||
|
||||
public static double[] damageBoost = new double[] { 0.03, 0.06, 0.09, 0.12, 0.15, 0.18, 0.22, 0.25 };
|
||||
public static double[] attackSpeed = new double[] { -0.02, -0.04, -0.06, -0.08, -0.1, -0.12, -0.14, -0.16 };
|
||||
public static double[] damageBoost = new double[]{0.03, 0.06, 0.09, 0.12, 0.15, 0.18, 0.22, 0.25};
|
||||
public static double[] attackSpeed = new double[]{-0.02, -0.04, -0.06, -0.08, -0.1, -0.12, -0.14, -0.16};
|
||||
|
||||
public static double[] speedBonus = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4 };
|
||||
public static double[] speedBonus = new double[]{0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4};
|
||||
|
||||
public ItemSentientArmour(EntityEquipmentSlot armorType)
|
||||
{
|
||||
public ItemSentientArmour(EntityEquipmentSlot armorType) {
|
||||
super(ItemArmor.ArmorMaterial.IRON, 0, armorType);
|
||||
setUnlocalizedName(BloodMagic.MODID + ".sentientArmour.");
|
||||
setMaxDamage(250);
|
||||
|
@ -62,111 +59,92 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS)
|
||||
{
|
||||
switch (this.getCurrentType(stack))
|
||||
{
|
||||
case DEFAULT:
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_1.png";
|
||||
case CORROSIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_corrosive_layer_1.png";
|
||||
case VENGEFUL:
|
||||
return "bloodmagic:models/armor/sentientArmour_vengeful_layer_1.png";
|
||||
case DESTRUCTIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_destructive_layer_1.png";
|
||||
case STEADFAST:
|
||||
return "bloodmagic:models/armor/sentientArmour_steadfast_layer_1.png";
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) {
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS) {
|
||||
switch (this.getCurrentType(stack)) {
|
||||
case DEFAULT:
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_1.png";
|
||||
case CORROSIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_corrosive_layer_1.png";
|
||||
case VENGEFUL:
|
||||
return "bloodmagic:models/armor/sentientArmour_vengeful_layer_1.png";
|
||||
case DESTRUCTIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_destructive_layer_1.png";
|
||||
case STEADFAST:
|
||||
return "bloodmagic:models/armor/sentientArmour_steadfast_layer_1.png";
|
||||
}
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_1.png";
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS)
|
||||
{
|
||||
switch (this.getCurrentType(stack))
|
||||
{
|
||||
case DEFAULT:
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_2.png";
|
||||
case CORROSIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_corrosive_layer_2.png";
|
||||
case VENGEFUL:
|
||||
return "bloodmagic:models/armor/sentientArmour_vengeful_layer_2.png";
|
||||
case DESTRUCTIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_destructive_layer_2.png";
|
||||
case STEADFAST:
|
||||
return "bloodmagic:models/armor/sentientArmour_steadfast_layer_2.png";
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) {
|
||||
switch (this.getCurrentType(stack)) {
|
||||
case DEFAULT:
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_2.png";
|
||||
case CORROSIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_corrosive_layer_2.png";
|
||||
case VENGEFUL:
|
||||
return "bloodmagic:models/armor/sentientArmour_vengeful_layer_2.png";
|
||||
case DESTRUCTIVE:
|
||||
return "bloodmagic:models/armor/sentientArmour_destructive_layer_2.png";
|
||||
case STEADFAST:
|
||||
return "bloodmagic:models/armor/sentientArmour_steadfast_layer_2.png";
|
||||
}
|
||||
return "bloodmagic:models/armor/sentientArmour_layer_1.png";
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
if (this.armorType == EntityEquipmentSlot.CHEST)
|
||||
{
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
|
||||
if (this.armorType == EntityEquipmentSlot.CHEST) {
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
if (player.isPotionActive(MobEffects.POISON))
|
||||
{
|
||||
player.removeActivePotionEffect(MobEffects.POISON);
|
||||
}
|
||||
if (player.isPotionActive(MobEffects.WITHER))
|
||||
{
|
||||
player.removeActivePotionEffect(MobEffects.WITHER);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
if (player.isPotionActive(MobEffects.POISON)) {
|
||||
player.removeActivePotionEffect(MobEffects.POISON);
|
||||
}
|
||||
if (player.isPotionActive(MobEffects.WITHER)) {
|
||||
player.removeActivePotionEffect(MobEffects.WITHER);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPlayerAttacked(ItemStack stack, DamageSource source, EntityPlayer attackedPlayer)
|
||||
{
|
||||
if (source.getTrueSource() instanceof EntityLivingBase)
|
||||
{
|
||||
public void onPlayerAttacked(ItemStack stack, DamageSource source, EntityPlayer attackedPlayer) {
|
||||
if (source.getTrueSource() instanceof EntityLivingBase) {
|
||||
EntityLivingBase attacker = (EntityLivingBase) source.getTrueSource();
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
if (!source.isProjectile())
|
||||
{
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.POISON, 100)); //TODO: customize duration
|
||||
}
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
if (!source.isProjectile()) {
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.POISON, 100)); //TODO: customize duration
|
||||
}
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot)
|
||||
{
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack stack, DamageSource source, double damage, int slot) {
|
||||
double armourReduction = 0.0;
|
||||
double damageAmount = 0.25;
|
||||
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS || this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET) {
|
||||
damageAmount = 3d / 20d * 0.6;
|
||||
} else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS)
|
||||
{
|
||||
} else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) {
|
||||
damageAmount = 6d / 20d * 0.6;
|
||||
} else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST)
|
||||
{
|
||||
} else if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) {
|
||||
damageAmount = 0.64;
|
||||
}
|
||||
|
||||
|
@ -174,50 +152,42 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
|
||||
int maxAbsorption = 100000;
|
||||
|
||||
if (source.equals(DamageSource.DROWN))
|
||||
{
|
||||
if (source.equals(DamageSource.DROWN)) {
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (source.equals(DamageSource.OUT_OF_WORLD))
|
||||
{
|
||||
if (source.equals(DamageSource.OUT_OF_WORLD)) {
|
||||
return new ArmorProperties(-1, 0, 0);
|
||||
}
|
||||
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST)
|
||||
{
|
||||
if (this == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) {
|
||||
armourReduction = 0.24 / 0.64; // This values puts it at iron level
|
||||
|
||||
ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
|
||||
ItemStack leggings = player.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
|
||||
ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
|
||||
|
||||
if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty())
|
||||
{
|
||||
if (helmet.isEmpty() || leggings.isEmpty() || boots.isEmpty()) {
|
||||
damageAmount *= (armourReduction);
|
||||
|
||||
return new ArmorProperties(-1, damageAmount, maxAbsorption);
|
||||
}
|
||||
|
||||
if (helmet.getItem() instanceof ItemSentientArmour && leggings.getItem() instanceof ItemSentientArmour && boots.getItem() instanceof ItemSentientArmour)
|
||||
{
|
||||
if (helmet.getItem() instanceof ItemSentientArmour && leggings.getItem() instanceof ItemSentientArmour && boots.getItem() instanceof ItemSentientArmour) {
|
||||
double remainder = 1; // Multiply this number by the armour upgrades for protection
|
||||
remainder *= (1 - this.getArmourModifier(stack));
|
||||
|
||||
armourReduction = armourReduction + (1 - remainder) * (1 - armourReduction);
|
||||
damageAmount *= (armourReduction);
|
||||
|
||||
if (source.isUnblockable())
|
||||
{
|
||||
if (source.isUnblockable()) {
|
||||
return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
|
||||
}
|
||||
|
||||
return new ArmorProperties(-1, damageAmount, maxAbsorption);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (source.isUnblockable())
|
||||
{
|
||||
} else {
|
||||
if (source.isUnblockable()) {
|
||||
return new ArmorProperties(-1, damageAmount * armourPenetrationReduction, maxAbsorption);
|
||||
}
|
||||
|
||||
|
@ -228,25 +198,20 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET)
|
||||
{
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_CHEST) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_LEGS) {
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS)
|
||||
{
|
||||
if (armor.getItem() == RegistrarBloodMagicItems.SENTIENT_ARMOUR_BOOTS) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@ -254,53 +219,45 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot)
|
||||
{
|
||||
if (entity instanceof EntityPlayer)
|
||||
{
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
|
||||
EnumDemonWillType type = getCurrentType(stack);
|
||||
|
||||
double willRequired = this.getCostModifier(stack) * damage;
|
||||
double willLeft = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
if (willLeft >= willRequired && canSustainArmour(type, willLeft))
|
||||
{
|
||||
if (willLeft >= willRequired && canSustainArmour(type, willLeft)) {
|
||||
this.setAbilitiesOfArmour(type, willLeft - willRequired, stack);
|
||||
PlayerDemonWillHandler.consumeDemonWill(type, player, willRequired);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.revertArmour(player, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getCostModifier(ItemStack stack)
|
||||
{
|
||||
public double getCostModifier(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getDouble("costModifier");
|
||||
}
|
||||
|
||||
public void setCostModifier(ItemStack stack, double modifier)
|
||||
{
|
||||
public void setCostModifier(ItemStack stack, double modifier) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("costModifier", modifier);
|
||||
}
|
||||
|
||||
public double getArmourModifier(ItemStack stack)
|
||||
{
|
||||
public double getArmourModifier(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
return tag.getDouble("armourModifier");
|
||||
}
|
||||
|
||||
public void setArmourModifier(ItemStack stack, double modifier)
|
||||
{
|
||||
public void setArmourModifier(ItemStack stack, double modifier) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
|
@ -308,26 +265,21 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[3 - armorType.getIndex()];
|
||||
}
|
||||
|
||||
public void revertArmour(EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
public void revertArmour(EntityPlayer player, ItemStack itemStack) {
|
||||
ItemStack stack = this.getContainedArmourStack(itemStack);
|
||||
player.setItemStackToSlot(armorType, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
return new ItemMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new ItemMeshDefinition() {
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack)
|
||||
{
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
assert getCustomLocation() != null;
|
||||
EnumDemonWillType type = ((ItemSentientArmour) RegistrarBloodMagicItems.SENTIENT_ARMOUR_HELMET).getCurrentType(stack);
|
||||
String additional = "_" + type.getName().toLowerCase();
|
||||
|
@ -344,17 +296,14 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return new ResourceLocation(BloodMagic.MODID, "item/ItemSentientArmour");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
String additional = "_" + type.getName().toLowerCase();
|
||||
|
||||
ret.add("armour=head" + additional);
|
||||
|
@ -367,11 +316,9 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
|
||||
if (slot == EntityEquipmentSlot.CHEST)
|
||||
{
|
||||
if (slot == EntityEquipmentSlot.CHEST) {
|
||||
multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 318145), "Armor modifier", this.getHealthBonus(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(new UUID(0, 8145), "Armor modifier", this.getKnockbackResistance(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getName(), new AttributeModifier(new UUID(0, 94021), "Armor modifier", this.getSpeedBoost(stack), 2));
|
||||
|
@ -381,22 +328,8 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
return multimap;
|
||||
}
|
||||
|
||||
public static void revertAllArmour(EntityPlayer player)
|
||||
{
|
||||
NonNullList<ItemStack> armourInventory = player.inventory.armorInventory;
|
||||
for (ItemStack stack : armourInventory)
|
||||
{
|
||||
if (stack != null && stack.getItem() instanceof ItemSentientArmour)
|
||||
{
|
||||
((ItemSentientArmour) stack.getItem()).revertArmour(player, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setContainedArmourStack(ItemStack newArmour, ItemStack previousArmour)
|
||||
{
|
||||
if (newArmour == null || previousArmour == null)
|
||||
{
|
||||
public void setContainedArmourStack(ItemStack newArmour, ItemStack previousArmour) {
|
||||
if (newArmour == null || previousArmour == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -404,8 +337,7 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
previousArmour.writeToNBT(tag);
|
||||
|
||||
NBTTagCompound omegaTag = newArmour.getTagCompound();
|
||||
if (omegaTag == null)
|
||||
{
|
||||
if (omegaTag == null) {
|
||||
omegaTag = new NBTTagCompound();
|
||||
newArmour.setTagCompound(omegaTag);
|
||||
}
|
||||
|
@ -415,11 +347,9 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
EnchantmentHelper.setEnchantments(enchantmentMap, newArmour);
|
||||
}
|
||||
|
||||
public ItemStack getContainedArmourStack(ItemStack newArmour)
|
||||
{
|
||||
public ItemStack getContainedArmourStack(ItemStack newArmour) {
|
||||
NBTTagCompound omegaTag = newArmour.getTagCompound();
|
||||
if (omegaTag == null)
|
||||
{
|
||||
if (omegaTag == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -427,10 +357,195 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
return new ItemStack(tag);
|
||||
}
|
||||
|
||||
public static boolean convertPlayerArmour(EnumDemonWillType type, double will, EntityPlayer player)
|
||||
{
|
||||
if (!canSustainArmour(type, will))
|
||||
{
|
||||
public ItemStack getSubstituteStack(EnumDemonWillType type, double will, ItemStack previousArmour) {
|
||||
ItemStack newArmour = new ItemStack(this);
|
||||
|
||||
this.setContainedArmourStack(newArmour, previousArmour);
|
||||
this.setAbilitiesOfArmour(type, will, newArmour);
|
||||
|
||||
return newArmour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(EnumDemonWillType type, ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
}
|
||||
|
||||
public void setAbilitiesOfArmour(EnumDemonWillType type, double willValue, ItemStack armourStack) {
|
||||
int willBracket = getWillBracket(willValue);
|
||||
if (willBracket >= 0) {
|
||||
double recurringCost = consumptionPerHit[willBracket];
|
||||
|
||||
this.setCostModifier(armourStack, recurringCost);
|
||||
this.setCurrentType(type, armourStack);
|
||||
|
||||
if (this.armorType == EntityEquipmentSlot.CHEST) {
|
||||
this.setArmourModifier(armourStack, getArmourModifier(type, willBracket));
|
||||
this.setHealthBonus(armourStack, this.getHealthModifier(type, willBracket));
|
||||
this.setKnockbackResistance(armourStack, getKnockbackModifier(type, willBracket));
|
||||
this.setSpeedBoost(armourStack, getSpeedModifier(type, willBracket));
|
||||
this.setDamageBoost(armourStack, getDamageModifier(type, willBracket));
|
||||
this.setAttackSpeedBoost(armourStack, getAttackSpeedModifier(type, willBracket));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getArmourModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
return steadfastProtectionLevel[willBracket];
|
||||
default:
|
||||
return extraProtectionLevel[willBracket];
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
//return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getKnockbackModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
return knockbackBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getSpeedModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return speedBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDamageModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case DESTRUCTIVE:
|
||||
return damageBoost[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getAttackSpeedModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case DESTRUCTIVE:
|
||||
return attackSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthBonus(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
|
||||
}
|
||||
|
||||
public void setHealthBonus(ItemStack stack, double hp) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
|
||||
}
|
||||
|
||||
public double getKnockbackResistance(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("knockback");
|
||||
}
|
||||
|
||||
public void setKnockbackResistance(ItemStack stack, double kb) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("knockback", kb);
|
||||
}
|
||||
|
||||
public double getSpeedBoost(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("speed");
|
||||
}
|
||||
|
||||
public void setSpeedBoost(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("speed", speed);
|
||||
}
|
||||
|
||||
public double getDamageBoost(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("damage");
|
||||
}
|
||||
|
||||
public void setDamageBoost(ItemStack stack, double damage) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("damage", damage);
|
||||
}
|
||||
|
||||
public double getAttackSpeedBoost(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("attackSpeed");
|
||||
}
|
||||
|
||||
public void setAttackSpeedBoost(ItemStack stack, double attackSpeed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("attackSpeed", attackSpeed);
|
||||
}
|
||||
|
||||
public static void revertAllArmour(EntityPlayer player) {
|
||||
NonNullList<ItemStack> armourInventory = player.inventory.armorInventory;
|
||||
for (ItemStack stack : armourInventory) {
|
||||
if (stack != null && stack.getItem() instanceof ItemSentientArmour) {
|
||||
((ItemSentientArmour) stack.getItem()).revertArmour(player, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean convertPlayerArmour(EnumDemonWillType type, double will, EntityPlayer player) {
|
||||
if (!canSustainArmour(type, will)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -454,230 +569,19 @@ public class ItemSentientArmour extends ItemArmor implements ISpecialArmor, IMes
|
|||
}
|
||||
}
|
||||
|
||||
public ItemStack getSubstituteStack(EnumDemonWillType type, double will, ItemStack previousArmour)
|
||||
{
|
||||
ItemStack newArmour = new ItemStack(this);
|
||||
|
||||
this.setContainedArmourStack(newArmour, previousArmour);
|
||||
this.setAbilitiesOfArmour(type, will, newArmour);
|
||||
|
||||
return newArmour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(EnumDemonWillType type, ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
}
|
||||
|
||||
public void setAbilitiesOfArmour(EnumDemonWillType type, double willValue, ItemStack armourStack)
|
||||
{
|
||||
int willBracket = getWillBracket(willValue);
|
||||
if (willBracket >= 0)
|
||||
{
|
||||
double recurringCost = consumptionPerHit[willBracket];
|
||||
|
||||
this.setCostModifier(armourStack, recurringCost);
|
||||
this.setCurrentType(type, armourStack);
|
||||
|
||||
if (this.armorType == EntityEquipmentSlot.CHEST)
|
||||
{
|
||||
this.setArmourModifier(armourStack, getArmourModifier(type, willBracket));
|
||||
this.setHealthBonus(armourStack, this.getHealthModifier(type, willBracket));
|
||||
this.setKnockbackResistance(armourStack, getKnockbackModifier(type, willBracket));
|
||||
this.setSpeedBoost(armourStack, getSpeedModifier(type, willBracket));
|
||||
this.setDamageBoost(armourStack, getDamageModifier(type, willBracket));
|
||||
this.setAttackSpeedBoost(armourStack, getAttackSpeedModifier(type, willBracket));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getArmourModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
return steadfastProtectionLevel[willBracket];
|
||||
default:
|
||||
return extraProtectionLevel[willBracket];
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
//return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getKnockbackModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
return knockbackBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getSpeedModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return speedBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDamageModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DESTRUCTIVE:
|
||||
return damageBoost[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getAttackSpeedModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DESTRUCTIVE:
|
||||
return attackSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canSustainArmour(EnumDemonWillType type, double willValue)
|
||||
{
|
||||
public static boolean canSustainArmour(EnumDemonWillType type, double willValue) {
|
||||
return getWillBracket(willValue) >= 0;
|
||||
}
|
||||
|
||||
public static int getWillBracket(double will)
|
||||
{
|
||||
public static int getWillBracket(double will) {
|
||||
int bracket = -1;
|
||||
|
||||
for (int i = 0; i < willBracket.length; i++)
|
||||
{
|
||||
if (will >= willBracket[i])
|
||||
{
|
||||
for (int i = 0; i < willBracket.length; i++) {
|
||||
if (will >= willBracket[i]) {
|
||||
bracket = i;
|
||||
}
|
||||
}
|
||||
|
||||
return bracket;
|
||||
}
|
||||
|
||||
public double getHealthBonus(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
|
||||
}
|
||||
|
||||
public void setHealthBonus(ItemStack stack, double hp)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
|
||||
}
|
||||
|
||||
public double getKnockbackResistance(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("knockback");
|
||||
}
|
||||
|
||||
public void setKnockbackResistance(ItemStack stack, double kb)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("knockback", kb);
|
||||
}
|
||||
|
||||
public double getSpeedBoost(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("speed");
|
||||
}
|
||||
|
||||
public void setSpeedBoost(ItemStack stack, double speed)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("speed", speed);
|
||||
}
|
||||
|
||||
public double getDamageBoost(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("damage");
|
||||
}
|
||||
|
||||
public void setDamageBoost(ItemStack stack, double damage)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("damage", damage);
|
||||
}
|
||||
|
||||
public double getAttackSpeedBoost(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble("attackSpeed");
|
||||
}
|
||||
|
||||
public void setAttackSpeedBoost(ItemStack stack, double attackSpeed)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
tag.setDouble("attackSpeed", attackSpeed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,64 +1,53 @@
|
|||
package WayofTime.bloodmagic.item.block;
|
||||
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyTable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.tile.TileAlchemyTable;
|
||||
|
||||
public class ItemBlockAlchemyTable extends ItemBlock
|
||||
{
|
||||
public ItemBlockAlchemyTable(Block block)
|
||||
{
|
||||
public class ItemBlockAlchemyTable extends ItemBlock {
|
||||
public ItemBlockAlchemyTable(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState)
|
||||
{
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
|
||||
float yaw = player.rotationYaw;
|
||||
EnumFacing direction = EnumFacing.fromAngle(yaw);
|
||||
|
||||
if (direction.getFrontOffsetY() != 0)
|
||||
{
|
||||
if (direction.getFrontOffsetY() != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.isAirBlock(pos.offset(direction)))
|
||||
{
|
||||
if (!world.isAirBlock(pos.offset(direction))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// newState = block.getDefaultState().withProperty(BlockAlchemyTable.DIRECTION, direction).withProperty(BlockAlchemyTable.INVISIBLE, true);
|
||||
|
||||
if (!world.setBlockState(pos, newState, 3))
|
||||
{
|
||||
if (!world.setBlockState(pos, newState, 3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!world.setBlockState(pos.offset(direction), newState, 3))
|
||||
{
|
||||
if (!world.setBlockState(pos.offset(direction), newState, 3)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() == this.block)
|
||||
{
|
||||
if (state.getBlock() == this.block) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileAlchemyTable)
|
||||
{
|
||||
if (tile instanceof TileAlchemyTable) {
|
||||
((TileAlchemyTable) tile).setInitialTableParameters(direction, false, pos.offset(direction));
|
||||
}
|
||||
|
||||
TileEntity slaveTile = world.getTileEntity(pos.offset(direction));
|
||||
if (slaveTile instanceof TileAlchemyTable)
|
||||
{
|
||||
if (slaveTile instanceof TileAlchemyTable) {
|
||||
((TileAlchemyTable) slaveTile).setInitialTableParameters(direction, true, pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,6 @@ import WayofTime.bloodmagic.util.helper.TextHelper;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -15,53 +13,44 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.capabilities.ICapabilityProvider;
|
||||
import net.minecraftforge.fluids.*;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemBlockBloodTank extends ItemBlock
|
||||
{
|
||||
public ItemBlockBloodTank(Block block)
|
||||
{
|
||||
public class ItemBlockBloodTank extends ItemBlock {
|
||||
public ItemBlockBloodTank(Block block) {
|
||||
super(block);
|
||||
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta)
|
||||
{
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
{
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(stack.getTagCompound());
|
||||
if (fluidStack != null)
|
||||
{
|
||||
if (fluidStack != null) {
|
||||
return super.getItemStackDisplayName(stack) + " " + TextHelper.localizeEffect("tooltip.bloodmagic.tier", stack.getItemDamage() + 1) + " (" + fluidStack.getLocalizedName() + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return super.getItemStackDisplayName(stack) + " " + TextHelper.localizeEffect("tooltip.bloodmagic.tier", stack.getItemDamage() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.tier", stack.getItemDamage() + 1));
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.capacity", getCapacity(stack)));
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tag);
|
||||
if (fluidStack != null)
|
||||
{
|
||||
if (fluidStack != null) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.type", fluidStack.getLocalizedName()));
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.fluid.amount", fluidStack.amount, getCapacity(stack)));
|
||||
}
|
||||
|
@ -70,23 +59,20 @@ public class ItemBlockBloodTank extends ItemBlock
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
|
||||
for (int i = 0; i < TileBloodTank.CAPACITIES.length; i++)
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
for (int i = 0; i < TileBloodTank.CAPACITIES.length; i++)
|
||||
list.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
public int getCapacity(ItemStack container)
|
||||
{
|
||||
public int getCapacity(ItemStack container) {
|
||||
int meta = MathHelper.clamp(container.getItemDamage(), 0, TileBloodTank.CAPACITIES.length - 1);
|
||||
return !container.isEmpty() && Block.getBlockFromItem(container.getItem()) instanceof BlockBloodTank ? TileBloodTank.CAPACITIES[meta] * Fluid.BUCKET_VOLUME : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt)
|
||||
{
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
|
||||
return new FluidHandlerItemStack(stack, getCapacity(stack));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,34 +14,27 @@ import net.minecraft.world.World;
|
|||
|
||||
import java.util.Locale;
|
||||
|
||||
public class ItemBlockDemonCrystal extends ItemBlock
|
||||
{
|
||||
public ItemBlockDemonCrystal(Block block)
|
||||
{
|
||||
public class ItemBlockDemonCrystal extends ItemBlock {
|
||||
public ItemBlockDemonCrystal(Block block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + EnumDemonWillType.values()[stack.getItemDamage()].toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int meta)
|
||||
{
|
||||
public int getMetadata(int meta) {
|
||||
return meta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState)
|
||||
{
|
||||
if (super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState))
|
||||
{
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
|
||||
if (super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState)) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileDemonCrystal)
|
||||
{
|
||||
if (tile instanceof TileDemonCrystal) {
|
||||
((TileDemonCrystal) tile).setPlacement(side);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,9 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.IStringSerializable;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class ItemBlockEnum<E extends Enum<E> & IStringSerializable> extends ItemBlock
|
||||
{
|
||||
public class ItemBlockEnum<E extends Enum<E> & IStringSerializable> extends ItemBlock {
|
||||
|
||||
public ItemBlockEnum(BlockEnum<E> block)
|
||||
{
|
||||
public ItemBlockEnum(BlockEnum<E> block) {
|
||||
super(block);
|
||||
|
||||
if (block.getTypes().length > 1)
|
||||
|
@ -19,20 +17,17 @@ public class ItemBlockEnum<E extends Enum<E> & IStringSerializable> extends Item
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public BlockEnum<E> getBlock()
|
||||
{
|
||||
public BlockEnum<E> getBlock() {
|
||||
return (BlockEnum<E>) super.getBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return getBlock().getUnlocalizedName() + getBlock().getTypes()[MathHelper.clamp(stack.getItemDamage(), 0, 15)].getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int damage)
|
||||
{
|
||||
public int getMetadata(int damage) {
|
||||
return damage;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class ItemBlockString extends ItemBlock {
|
|||
public ItemBlockString(BlockString block) {
|
||||
super(block);
|
||||
|
||||
if (block.getTypes().length> 1)
|
||||
if (block.getTypes().length > 1)
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,12 +26,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider
|
||||
{
|
||||
public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider {
|
||||
public final int CAPACITY = 10000; // Max LP storage
|
||||
|
||||
public ItemPackSacrifice()
|
||||
{
|
||||
public ItemPackSacrifice() {
|
||||
super(ArmorMaterial.CHAIN, 0, EntityEquipmentSlot.CHEST);
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".pack.sacrifice");
|
||||
|
@ -39,21 +37,17 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (world.isRemote)
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
RayTraceResult rayTrace = this.rayTrace(world, player, false);
|
||||
|
||||
if (rayTrace == null)
|
||||
{
|
||||
if (rayTrace == null) {
|
||||
return super.onItemRightClick(world, player, EnumHand.MAIN_HAND);
|
||||
} else
|
||||
{
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
} else {
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
TileEntity tile = world.getTileEntity(rayTrace.getBlockPos());
|
||||
|
||||
if (!(tile instanceof IBloodAltar))
|
||||
|
@ -67,15 +61,13 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
|
||||
if (getStoredLP(stack) > CAPACITY)
|
||||
setStoredLP(stack, CAPACITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
@ -84,8 +76,7 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=normal"));
|
||||
return ret;
|
||||
|
@ -94,22 +85,18 @@ public class ItemPackSacrifice extends ItemArmor implements IAltarManipulator, I
|
|||
// IFillable
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
public int getCapacity() {
|
||||
return this.CAPACITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredLP(ItemStack stack)
|
||||
{
|
||||
public int getStoredLP(ItemStack stack) {
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.STORED_LP) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredLP(ItemStack stack, int lp)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
public void setStoredLP(ItemStack stack, int lp) {
|
||||
if (stack != null) {
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider
|
||||
{
|
||||
public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulator, IItemLPContainer, IVariantProvider {
|
||||
/**
|
||||
* How much LP per half heart
|
||||
*/
|
||||
|
@ -46,8 +45,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
*/
|
||||
public final float HEALTHREQ = 0.5f;
|
||||
|
||||
public ItemPackSelfSacrifice()
|
||||
{
|
||||
public ItemPackSelfSacrifice() {
|
||||
super(ArmorMaterial.CHAIN, 0, EntityEquipmentSlot.CHEST);
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".pack.selfSacrifice");
|
||||
|
@ -55,21 +53,17 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (world.isRemote)
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
RayTraceResult position = this.rayTrace(world, player, false);
|
||||
|
||||
if (position == null)
|
||||
{
|
||||
if (position == null) {
|
||||
return super.onItemRightClick(world, player, EnumHand.MAIN_HAND);
|
||||
} else
|
||||
{
|
||||
if (position.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
} else {
|
||||
if (position.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
||||
|
||||
if (!(tile instanceof IBloodAltar))
|
||||
|
@ -83,15 +77,13 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
|
||||
if (world.isRemote || player.capabilities.isCreativeMode)
|
||||
return;
|
||||
|
||||
boolean shouldSyphon = player.getHealth() / player.getMaxHealth() > HEALTHREQ && getStoredLP(stack) < CAPACITY;
|
||||
|
||||
if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0)
|
||||
{
|
||||
if (shouldSyphon & world.getTotalWorldTime() % INTERVAL == 0) {
|
||||
NetworkHelper.getSoulNetwork(player).hurtPlayer(player, 1.0F);
|
||||
LPContainer.addLPToItem(stack, CONVERSION, CAPACITY);
|
||||
}
|
||||
|
@ -101,8 +93,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> list, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
list.add(TextHelper.localize("tooltip.bloodmagic.pack.selfSacrifice.desc"));
|
||||
|
@ -110,8 +101,7 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=normal"));
|
||||
return ret;
|
||||
|
@ -120,22 +110,18 @@ public class ItemPackSelfSacrifice extends ItemArmor implements IAltarManipulato
|
|||
// IFillable
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
public int getCapacity() {
|
||||
return this.CAPACITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStoredLP(ItemStack stack)
|
||||
{
|
||||
public int getStoredLP(ItemStack stack) {
|
||||
return stack != null ? NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.STORED_LP) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStoredLP(ItemStack stack, int lp)
|
||||
{
|
||||
if (stack != null)
|
||||
{
|
||||
public void setStoredLP(ItemStack stack, int lp) {
|
||||
if (stack != null) {
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.STORED_LP, lp);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,121 +9,94 @@ import net.minecraft.inventory.Slot;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class ContainerHolding extends Container
|
||||
{
|
||||
public class ContainerHolding extends Container {
|
||||
public final InventoryHolding inventoryHolding;
|
||||
private final int PLAYER_INVENTORY_ROWS = 3;
|
||||
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
||||
|
||||
private final EntityPlayer player;
|
||||
public final InventoryHolding inventoryHolding;
|
||||
|
||||
public ContainerHolding(EntityPlayer player, InventoryHolding inventoryHolding)
|
||||
{
|
||||
public ContainerHolding(EntityPlayer player, InventoryHolding inventoryHolding) {
|
||||
this.player = player;
|
||||
this.inventoryHolding = inventoryHolding;
|
||||
int currentSlotHeldIn = player.inventory.currentItem;
|
||||
|
||||
for (int columnIndex = 0; columnIndex < ItemSigilHolding.inventorySize; ++columnIndex)
|
||||
{
|
||||
for (int columnIndex = 0; columnIndex < ItemSigilHolding.inventorySize; ++columnIndex) {
|
||||
this.addSlotToContainer(new SlotHolding(this, inventoryHolding, player, columnIndex, 8 + columnIndex * 36, 17));
|
||||
}
|
||||
|
||||
for (int rowIndex = 0; rowIndex < PLAYER_INVENTORY_ROWS; ++rowIndex)
|
||||
{
|
||||
for (int columnIndex = 0; columnIndex < PLAYER_INVENTORY_COLUMNS; ++columnIndex)
|
||||
{
|
||||
for (int rowIndex = 0; rowIndex < PLAYER_INVENTORY_ROWS; ++rowIndex) {
|
||||
for (int columnIndex = 0; columnIndex < PLAYER_INVENTORY_COLUMNS; ++columnIndex) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, columnIndex + rowIndex * 9 + 9, 8 + columnIndex * 18, 41 + rowIndex * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int actionBarIndex = 0; actionBarIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarIndex)
|
||||
{
|
||||
if (actionBarIndex == currentSlotHeldIn)
|
||||
{
|
||||
for (int actionBarIndex = 0; actionBarIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarIndex) {
|
||||
if (actionBarIndex == currentSlotHeldIn) {
|
||||
this.addSlotToContainer(new SlotDisabled(player.inventory, actionBarIndex, 8 + actionBarIndex * 18, 99));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.addSlotToContainer(new Slot(player.inventory, actionBarIndex, 8 + actionBarIndex * 18, 99));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityPlayer)
|
||||
{
|
||||
public boolean canInteractWith(EntityPlayer entityPlayer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityPlayer)
|
||||
{
|
||||
public void onContainerClosed(EntityPlayer entityPlayer) {
|
||||
super.onContainerClosed(entityPlayer);
|
||||
|
||||
if (!entityPlayer.getEntityWorld().isRemote)
|
||||
{
|
||||
if (!entityPlayer.getEntityWorld().isRemote) {
|
||||
saveInventory(entityPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
if (!player.getEntityWorld().isRemote)
|
||||
{
|
||||
if (!player.getEntityWorld().isRemote) {
|
||||
saveInventory(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
||||
{
|
||||
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) {
|
||||
ItemStack stack = ItemStack.EMPTY;
|
||||
Slot slotObject = inventorySlots.get(slotIndex);
|
||||
int slots = inventorySlots.size();
|
||||
|
||||
if (slotObject != null && slotObject.getHasStack())
|
||||
{
|
||||
if (slotObject != null && slotObject.getHasStack()) {
|
||||
ItemStack stackInSlot = slotObject.getStack();
|
||||
stack = stackInSlot.copy();
|
||||
|
||||
if (stack.getItem() instanceof ISigil)
|
||||
{
|
||||
if (slotIndex < ItemSigilHolding.inventorySize)
|
||||
{
|
||||
if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, slots, false))
|
||||
{
|
||||
if (stack.getItem() instanceof ISigil) {
|
||||
if (slotIndex < ItemSigilHolding.inventorySize) {
|
||||
if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, slots, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(stackInSlot, 0, ItemSigilHolding.inventorySize, false))
|
||||
{
|
||||
} else if (!this.mergeItemStack(stackInSlot, 0, ItemSigilHolding.inventorySize, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (stack.getItem() instanceof ItemSigilHolding)
|
||||
{
|
||||
if (slotIndex < ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS))
|
||||
{
|
||||
if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), inventorySlots.size(), false))
|
||||
{
|
||||
} else if (stack.getItem() instanceof ItemSigilHolding) {
|
||||
if (slotIndex < ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS)) {
|
||||
if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), inventorySlots.size(), false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), false))
|
||||
{
|
||||
} else if (!this.mergeItemStack(stackInSlot, ItemSigilHolding.inventorySize, ItemSigilHolding.inventorySize + (PLAYER_INVENTORY_ROWS * PLAYER_INVENTORY_COLUMNS), false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
if (stackInSlot.isEmpty())
|
||||
{
|
||||
if (stackInSlot.isEmpty()) {
|
||||
slotObject.putStack(ItemStack.EMPTY);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
slotObject.onSlotChanged();
|
||||
}
|
||||
|
||||
if (stackInSlot.getCount() == stack.getCount())
|
||||
{
|
||||
if (stackInSlot.getCount() == stack.getCount()) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
|
@ -133,57 +106,47 @@ public class ContainerHolding extends Container
|
|||
return stack;
|
||||
}
|
||||
|
||||
public void saveInventory(EntityPlayer entityPlayer)
|
||||
{
|
||||
public void saveInventory(EntityPlayer entityPlayer) {
|
||||
inventoryHolding.onGuiSaved(entityPlayer);
|
||||
}
|
||||
|
||||
private class SlotHolding extends Slot
|
||||
{
|
||||
private class SlotHolding extends Slot {
|
||||
private final EntityPlayer player;
|
||||
private ContainerHolding containerHolding;
|
||||
|
||||
public SlotHolding(ContainerHolding containerHolding, IInventory inventory, EntityPlayer player, int slotIndex, int x, int y)
|
||||
{
|
||||
public SlotHolding(ContainerHolding containerHolding, IInventory inventory, EntityPlayer player, int slotIndex, int x, int y) {
|
||||
super(inventory, slotIndex, x, y);
|
||||
this.player = player;
|
||||
this.containerHolding = containerHolding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChanged()
|
||||
{
|
||||
public void onSlotChanged() {
|
||||
super.onSlotChanged();
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer())
|
||||
{
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
containerHolding.saveInventory(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof ISigil && !(itemStack.getItem() instanceof ItemSigilHolding);
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotDisabled extends Slot
|
||||
{
|
||||
public SlotDisabled(IInventory inventory, int slotIndex, int x, int y)
|
||||
{
|
||||
private class SlotDisabled extends Slot {
|
||||
public SlotDisabled(IInventory inventory, int slotIndex, int x, int y) {
|
||||
super(inventory, slotIndex, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack itemStack)
|
||||
{
|
||||
public boolean isItemValid(ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer player)
|
||||
{
|
||||
public boolean canTakeStack(EntityPlayer player) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +1,38 @@
|
|||
package WayofTime.bloodmagic.item.inventory;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.item.sigil.ItemSigilHolding;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class InventoryHolding extends ItemInventory
|
||||
{
|
||||
import java.util.UUID;
|
||||
|
||||
public class InventoryHolding extends ItemInventory {
|
||||
protected ItemStack[] inventory;
|
||||
|
||||
public InventoryHolding(ItemStack itemStack)
|
||||
{
|
||||
public InventoryHolding(ItemStack itemStack) {
|
||||
super(itemStack, ItemSigilHolding.inventorySize, "SigilOfHolding");
|
||||
}
|
||||
|
||||
public void onGuiSaved(EntityPlayer entityPlayer)
|
||||
{
|
||||
public void onGuiSaved(EntityPlayer entityPlayer) {
|
||||
masterStack = findParentStack(entityPlayer);
|
||||
|
||||
if (!masterStack.isEmpty())
|
||||
{
|
||||
if (!masterStack.isEmpty()) {
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack findParentStack(EntityPlayer entityPlayer)
|
||||
{
|
||||
if (Utils.hasUUID(masterStack))
|
||||
{
|
||||
public ItemStack findParentStack(EntityPlayer entityPlayer) {
|
||||
if (Utils.hasUUID(masterStack)) {
|
||||
UUID parentStackUUID = new UUID(masterStack.getTagCompound().getLong(Constants.NBT.MOST_SIG), masterStack.getTagCompound().getLong(Constants.NBT.LEAST_SIG));
|
||||
for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++)
|
||||
{
|
||||
for (int i = 0; i < entityPlayer.inventory.getSizeInventory(); i++) {
|
||||
ItemStack itemStack = entityPlayer.inventory.getStackInSlot(i);
|
||||
|
||||
if (!itemStack.isEmpty() && Utils.hasUUID(itemStack))
|
||||
{
|
||||
if (itemStack.getTagCompound().getLong(Constants.NBT.MOST_SIG) == parentStackUUID.getMostSignificantBits() && itemStack.getTagCompound().getLong(Constants.NBT.LEAST_SIG) == parentStackUUID.getLeastSignificantBits())
|
||||
{
|
||||
if (!itemStack.isEmpty() && Utils.hasUUID(itemStack)) {
|
||||
if (itemStack.getTagCompound().getLong(Constants.NBT.MOST_SIG) == parentStackUUID.getMostSignificantBits() && itemStack.getTagCompound().getLong(Constants.NBT.LEAST_SIG) == parentStackUUID.getLeastSignificantBits()) {
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
@ -51,12 +42,10 @@ public class InventoryHolding extends ItemInventory
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
public void save() {
|
||||
NBTTagCompound nbtTagCompound = masterStack.getTagCompound();
|
||||
|
||||
if (nbtTagCompound == null)
|
||||
{
|
||||
if (nbtTagCompound == null) {
|
||||
nbtTagCompound = new NBTTagCompound();
|
||||
|
||||
UUID uuid = UUID.randomUUID();
|
||||
|
@ -69,14 +58,12 @@ public class InventoryHolding extends ItemInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack)
|
||||
{
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
return itemStack.getItem() instanceof ISigil && !(itemStack.getItem() instanceof ItemSigilHolding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,16 +11,14 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
public class ItemInventory implements IInventory
|
||||
{
|
||||
public class ItemInventory implements IInventory {
|
||||
protected int[] syncedSlots = new int[0];
|
||||
protected ItemStack masterStack;
|
||||
private NonNullList<ItemStack> inventory;
|
||||
private int size;
|
||||
private String name;
|
||||
protected ItemStack masterStack;
|
||||
|
||||
public ItemInventory(ItemStack masterStack, int size, String name)
|
||||
{
|
||||
public ItemInventory(ItemStack masterStack, int size, String name) {
|
||||
this.inventory = NonNullList.withSize(size, ItemStack.EMPTY);
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
|
@ -30,53 +28,42 @@ public class ItemInventory implements IInventory
|
|||
this.readFromStack(masterStack);
|
||||
}
|
||||
|
||||
public void initializeInventory(ItemStack masterStack)
|
||||
{
|
||||
public void initializeInventory(ItemStack masterStack) {
|
||||
this.masterStack = masterStack;
|
||||
this.clear();
|
||||
this.readFromStack(masterStack);
|
||||
}
|
||||
|
||||
private boolean isSyncedSlot(int slot)
|
||||
{
|
||||
for (int s : this.syncedSlots)
|
||||
{
|
||||
if (s == slot)
|
||||
{
|
||||
private boolean isSyncedSlot(int slot) {
|
||||
for (int s : this.syncedSlots) {
|
||||
if (s == slot) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
NBTTagList tags = tagCompound.getTagList(Constants.NBT.ITEMS, 10);
|
||||
inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
|
||||
for (int i = 0; i < tags.tagCount(); i++)
|
||||
{
|
||||
if (!isSyncedSlot(i))
|
||||
{
|
||||
for (int i = 0; i < tags.tagCount(); i++) {
|
||||
if (!isSyncedSlot(i)) {
|
||||
NBTTagCompound data = tags.getCompoundTagAt(i);
|
||||
byte j = data.getByte(Constants.NBT.SLOT);
|
||||
|
||||
if (j >= 0 && j < inventory.size())
|
||||
{
|
||||
if (j >= 0 && j < inventory.size()) {
|
||||
inventory.set(i, new ItemStack(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
NBTTagList tags = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < inventory.size(); i++)
|
||||
{
|
||||
if ((!inventory.get(i).isEmpty()) && !isSyncedSlot(i))
|
||||
{
|
||||
for (int i = 0; i < inventory.size(); i++) {
|
||||
if ((!inventory.get(i).isEmpty()) && !isSyncedSlot(i)) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setByte(Constants.NBT.SLOT, (byte) i);
|
||||
inventory.get(i).writeToNBT(data);
|
||||
|
@ -87,20 +74,16 @@ public class ItemInventory implements IInventory
|
|||
tagCompound.setTag(Constants.NBT.ITEMS, tags);
|
||||
}
|
||||
|
||||
public void readFromStack(ItemStack masterStack)
|
||||
{
|
||||
if (masterStack != null)
|
||||
{
|
||||
public void readFromStack(ItemStack masterStack) {
|
||||
if (masterStack != null) {
|
||||
NBTHelper.checkNBT(masterStack);
|
||||
NBTTagCompound tag = masterStack.getTagCompound();
|
||||
readFromNBT(tag.getCompoundTag(Constants.NBT.ITEM_INVENTORY));
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToStack(ItemStack masterStack)
|
||||
{
|
||||
if (masterStack != null)
|
||||
{
|
||||
public void writeToStack(ItemStack masterStack) {
|
||||
if (masterStack != null) {
|
||||
NBTHelper.checkNBT(masterStack);
|
||||
NBTTagCompound tag = masterStack.getTagCompound();
|
||||
NBTTagCompound invTag = new NBTTagCompound();
|
||||
|
@ -110,27 +93,22 @@ public class ItemInventory implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
public int getSizeInventory() {
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int index)
|
||||
{
|
||||
public ItemStack getStackInSlot(int index) {
|
||||
return inventory.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count)
|
||||
{
|
||||
if (!inventory.get(index).isEmpty())
|
||||
{
|
||||
public ItemStack decrStackSize(int index, int count) {
|
||||
if (!inventory.get(index).isEmpty()) {
|
||||
// if (!worldObj.isRemote)
|
||||
// worldObj.markBlockForUpdate(this.pos);
|
||||
|
||||
if (inventory.get(index).getCount() <= count)
|
||||
{
|
||||
if (inventory.get(index).getCount() <= count) {
|
||||
ItemStack itemStack = inventory.get(index);
|
||||
inventory.set(index, ItemStack.EMPTY);
|
||||
markDirty();
|
||||
|
@ -149,10 +127,8 @@ public class ItemInventory implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot(int slot)
|
||||
{
|
||||
if (!inventory.get(slot).isEmpty())
|
||||
{
|
||||
public ItemStack removeStackFromSlot(int slot) {
|
||||
if (!inventory.get(slot).isEmpty()) {
|
||||
ItemStack itemStack = inventory.get(slot);
|
||||
setInventorySlotContents(slot, ItemStack.EMPTY);
|
||||
return itemStack;
|
||||
|
@ -161,8 +137,7 @@ public class ItemInventory implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slot, ItemStack stack)
|
||||
{
|
||||
public void setInventorySlotContents(int slot, ItemStack stack) {
|
||||
inventory.set(slot, stack);
|
||||
if (stack.getCount() > getInventoryStackLimit())
|
||||
stack.setCount(getInventoryStackLimit());
|
||||
|
@ -172,82 +147,68 @@ public class ItemInventory implements IInventory
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsableByPlayer(EntityPlayer player)
|
||||
{
|
||||
public boolean isUsableByPlayer(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(EntityPlayer player)
|
||||
{
|
||||
public void openInventory(EntityPlayer player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory(EntityPlayer player)
|
||||
{
|
||||
public void closeInventory(EntityPlayer player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack)
|
||||
{
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField(int id)
|
||||
{
|
||||
public int getField(int id) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField(int id, int value)
|
||||
{
|
||||
public void setField(int id, int value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
public int getFieldCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
public void clear() {
|
||||
this.inventory = NonNullList.withSize(getSizeInventory(), ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
public boolean hasCustomName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
public ITextComponent getDisplayName() {
|
||||
return new TextComponentString(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
if (masterStack != null)
|
||||
{
|
||||
public void markDirty() {
|
||||
if (masterStack != null) {
|
||||
this.writeToStack(masterStack);
|
||||
}
|
||||
}
|
||||
|
@ -257,8 +218,7 @@ public class ItemInventory implements IInventory
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean canInventoryBeManipulated()
|
||||
{
|
||||
public boolean canInventoryBeManipulated() {
|
||||
return masterStack != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package WayofTime.bloodmagic.item.routing;
|
||||
|
||||
import WayofTime.bloodmagic.routing.IFluidFilter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import WayofTime.bloodmagic.routing.IFluidFilter;
|
||||
|
||||
public interface IFluidFilterProvider extends IRoutingFilterProvider
|
||||
{
|
||||
public interface IFluidFilterProvider extends IRoutingFilterProvider {
|
||||
IFluidFilter getInputFluidFilter(ItemStack stack, TileEntity tile, IFluidHandler handler);
|
||||
|
||||
IFluidFilter getOutputFluidFilter(ItemStack stack, TileEntity tile, IFluidHandler handler);
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package WayofTime.bloodmagic.item.routing;
|
||||
|
||||
import WayofTime.bloodmagic.routing.IItemFilter;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import WayofTime.bloodmagic.routing.IItemFilter;
|
||||
|
||||
public interface IItemFilterProvider extends IRoutingFilterProvider
|
||||
{
|
||||
public interface IItemFilterProvider extends IRoutingFilterProvider {
|
||||
IItemFilter getInputItemFilter(ItemStack stack, TileEntity tile, IItemHandler handler);
|
||||
|
||||
IItemFilter getOutputItemFilter(ItemStack stack, TileEntity tile, IItemHandler handler);
|
||||
|
|
|
@ -2,11 +2,10 @@ package WayofTime.bloodmagic.item.routing;
|
|||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IRoutingFilterProvider
|
||||
{
|
||||
public interface IRoutingFilterProvider {
|
||||
/**
|
||||
* Translates the inputed keyStack into the proper filtered key
|
||||
*
|
||||
*
|
||||
* @param filterStack
|
||||
* @param keyStack
|
||||
* @return A new ItemStack which modifies the keyStack
|
||||
|
|
|
@ -1,23 +1,5 @@
|
|||
package WayofTime.bloodmagic.item.routing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.inventory.ItemInventory;
|
||||
|
@ -25,13 +7,26 @@ import WayofTime.bloodmagic.routing.IFluidFilter;
|
|||
import WayofTime.bloodmagic.routing.RoutingFluidFilter;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider, IVariantProvider
|
||||
{
|
||||
public static String[] names = { "exact" };
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public ItemFluidRouterFilter()
|
||||
{
|
||||
public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider, IVariantProvider {
|
||||
public static String[] names = {"exact"};
|
||||
|
||||
public ItemFluidRouterFilter() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".fluidFilter.");
|
||||
|
@ -40,15 +35,13 @@ public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider,
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -58,35 +51,30 @@ public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider,
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(TextHelper.localize("tooltip.BloodMagic.fluidFilter." + names[stack.getItemDamage()]));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFluidFilter getInputFluidFilter(ItemStack filterStack, TileEntity tile, IFluidHandler handler)
|
||||
{
|
||||
public IFluidFilter getInputFluidFilter(ItemStack filterStack, TileEntity tile, IFluidHandler handler) {
|
||||
IFluidFilter testFilter;
|
||||
|
||||
switch (filterStack.getMetadata())
|
||||
{
|
||||
case 0:
|
||||
testFilter = new RoutingFluidFilter();
|
||||
break;
|
||||
switch (filterStack.getMetadata()) {
|
||||
case 0:
|
||||
testFilter = new RoutingFluidFilter();
|
||||
break;
|
||||
|
||||
default:
|
||||
testFilter = new RoutingFluidFilter();
|
||||
default:
|
||||
testFilter = new RoutingFluidFilter();
|
||||
}
|
||||
|
||||
List<ItemStack> filteredList = new ArrayList<ItemStack>();
|
||||
ItemInventory inv = new ItemInventory(filterStack, 9, "");
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
{
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -100,33 +88,28 @@ public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider,
|
|||
}
|
||||
|
||||
@Override
|
||||
public IFluidFilter getOutputFluidFilter(ItemStack filterStack, TileEntity tile, IFluidHandler handler)
|
||||
{
|
||||
public IFluidFilter getOutputFluidFilter(ItemStack filterStack, TileEntity tile, IFluidHandler handler) {
|
||||
IFluidFilter testFilter = new RoutingFluidFilter();
|
||||
|
||||
switch (filterStack.getMetadata())
|
||||
{
|
||||
case 0:
|
||||
testFilter = new RoutingFluidFilter();
|
||||
break;
|
||||
switch (filterStack.getMetadata()) {
|
||||
case 0:
|
||||
testFilter = new RoutingFluidFilter();
|
||||
break;
|
||||
|
||||
default:
|
||||
testFilter = new RoutingFluidFilter();
|
||||
default:
|
||||
testFilter = new RoutingFluidFilter();
|
||||
}
|
||||
|
||||
List<ItemStack> filteredList = new ArrayList<ItemStack>();
|
||||
ItemInventory inv = new ItemInventory(filterStack, 9, ""); //TODO: Change to grab the filter from the Item later.
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
{
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack ghostStack = GhostItemHelper.getStackFromGhost(stack);
|
||||
if (ghostStack.isEmpty())
|
||||
{
|
||||
if (ghostStack.isEmpty()) {
|
||||
ghostStack.setCount(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
@ -138,16 +121,14 @@ public class ItemFluidRouterFilter extends Item implements IFluidFilterProvider,
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=exact"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainedStackForItem(ItemStack filterStack, ItemStack keyStack)
|
||||
{
|
||||
public ItemStack getContainedStackForItem(ItemStack filterStack, ItemStack keyStack) {
|
||||
ItemStack copyStack = keyStack.copy();
|
||||
GhostItemHelper.setItemGhostAmount(copyStack, 0);
|
||||
copyStack.setCount(1);
|
||||
|
|
|
@ -29,10 +29,8 @@ import java.util.ArrayList;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvider
|
||||
{
|
||||
public ItemNodeRouter()
|
||||
{
|
||||
public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvider {
|
||||
public ItemNodeRouter() {
|
||||
setUnlocalizedName(BloodMagic.MODID + ".nodeRouter");
|
||||
setMaxStackSize(1);
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -40,36 +38,30 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
BlockPos coords = getBlockPos(stack);
|
||||
|
||||
if (coords != null && tag != null)
|
||||
{
|
||||
if (coords != null && tag != null) {
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", coords.getX(), coords.getY(), coords.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand)
|
||||
{
|
||||
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (world.isRemote)
|
||||
{
|
||||
if (world.isRemote) {
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
|
||||
TileEntity tileHit = world.getTileEntity(pos);
|
||||
|
||||
if (!(tileHit instanceof IRoutingNode))
|
||||
{
|
||||
if (!(tileHit instanceof IRoutingNode)) {
|
||||
// TODO: Remove contained position?
|
||||
BlockPos containedPos = getBlockPos(stack);
|
||||
if (!containedPos.equals(BlockPos.ORIGIN))
|
||||
{
|
||||
if (!containedPos.equals(BlockPos.ORIGIN)) {
|
||||
this.setBlockPos(stack, BlockPos.ORIGIN);
|
||||
player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.remove"), true);
|
||||
return EnumActionResult.FAIL;
|
||||
|
@ -78,23 +70,18 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi
|
|||
}
|
||||
IRoutingNode node = (IRoutingNode) tileHit;
|
||||
BlockPos containedPos = getBlockPos(stack);
|
||||
if (containedPos.equals(BlockPos.ORIGIN))
|
||||
{
|
||||
if (containedPos.equals(BlockPos.ORIGIN)) {
|
||||
this.setBlockPos(stack, pos);
|
||||
player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.set"), true);
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
TileEntity pastTile = world.getTileEntity(containedPos);
|
||||
if (pastTile instanceof IRoutingNode)
|
||||
{
|
||||
if (pastTile instanceof IRoutingNode) {
|
||||
IRoutingNode pastNode = (IRoutingNode) pastTile;
|
||||
if (pastNode instanceof IMasterRoutingNode)
|
||||
{
|
||||
if (pastNode instanceof IMasterRoutingNode) {
|
||||
IMasterRoutingNode master = (IMasterRoutingNode) pastNode;
|
||||
|
||||
if (!node.isMaster(master))
|
||||
{
|
||||
if (!node.isMaster(master)) {
|
||||
if (node.getMasterPos().equals(BlockPos.ORIGIN)) //If the node is not the master and it is receptive
|
||||
{
|
||||
node.connectMasterToRemainingNode(world, new LinkedList<BlockPos>(), master);
|
||||
|
@ -105,8 +92,7 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi
|
|||
this.setBlockPos(stack, BlockPos.ORIGIN);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
master.addConnection(pos, containedPos);
|
||||
node.addConnection(containedPos);
|
||||
player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.link.master"), true);
|
||||
|
@ -114,12 +100,10 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi
|
|||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
} else if (node instanceof IMasterRoutingNode)
|
||||
{
|
||||
} else if (node instanceof IMasterRoutingNode) {
|
||||
IMasterRoutingNode master = (IMasterRoutingNode) node;
|
||||
|
||||
if (!pastNode.isMaster(master))
|
||||
{
|
||||
if (!pastNode.isMaster(master)) {
|
||||
if (pastNode.getMasterPos().equals(BlockPos.ORIGIN)) //TODO: This is where the issue is
|
||||
{
|
||||
pastNode.connectMasterToRemainingNode(world, new LinkedList<BlockPos>(), master);
|
||||
|
@ -130,24 +114,19 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi
|
|||
this.setBlockPos(stack, BlockPos.ORIGIN);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
master.addConnection(pos, containedPos);
|
||||
pastNode.addConnection(pos);
|
||||
player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.link.master"), true);
|
||||
this.setBlockPos(stack, BlockPos.ORIGIN);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
//Both nodes are not master nodes, so normal linking
|
||||
if (pastNode.getMasterPos().equals(node.getMasterPos()))
|
||||
{
|
||||
if (!pastNode.getMasterPos().equals(BlockPos.ORIGIN))
|
||||
{
|
||||
if (pastNode.getMasterPos().equals(node.getMasterPos())) {
|
||||
if (!pastNode.getMasterPos().equals(BlockPos.ORIGIN)) {
|
||||
TileEntity testTile = world.getTileEntity(pastNode.getMasterPos());
|
||||
if (testTile instanceof IMasterRoutingNode)
|
||||
{
|
||||
if (testTile instanceof IMasterRoutingNode) {
|
||||
IMasterRoutingNode master = (IMasterRoutingNode) testTile;
|
||||
master.addConnection(pos, containedPos);
|
||||
}
|
||||
|
@ -160,8 +139,7 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi
|
|||
} else if (pastNode.getMasterPos().equals(BlockPos.ORIGIN)) //pastNode is not connected to a master, but node is
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(node.getMasterPos());
|
||||
if (tile instanceof IMasterRoutingNode)
|
||||
{
|
||||
if (tile instanceof IMasterRoutingNode) {
|
||||
IMasterRoutingNode master = (IMasterRoutingNode) tile;
|
||||
master.addConnection(pos, containedPos);
|
||||
master.addNodeToList(pastNode);
|
||||
|
@ -175,8 +153,7 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi
|
|||
} else if (node.getMasterPos().equals(BlockPos.ORIGIN)) //node is not connected to a master, but pastNode is
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(pastNode.getMasterPos());
|
||||
if (tile instanceof IMasterRoutingNode)
|
||||
{
|
||||
if (tile instanceof IMasterRoutingNode) {
|
||||
IMasterRoutingNode master = (IMasterRoutingNode) tile;
|
||||
master.addConnection(pos, containedPos);
|
||||
master.addNodeToList(node);
|
||||
|
@ -187,8 +164,7 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi
|
|||
player.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.routing.link"), true);
|
||||
this.setBlockPos(stack, BlockPos.ORIGIN);
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
this.setBlockPos(stack, BlockPos.ORIGIN);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
@ -200,21 +176,18 @@ public class ItemNodeRouter extends Item implements INodeRenderer, IVariantProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=normal"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos(ItemStack stack)
|
||||
{
|
||||
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, BlockPos pos)
|
||||
{
|
||||
public ItemStack setBlockPos(ItemStack stack, BlockPos pos) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound itemTag = stack.getTagCompound();
|
||||
itemTag.setInteger(Constants.NBT.X_COORD, pos.getX());
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package WayofTime.bloodmagic.item.routing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.inventory.ItemInventory;
|
||||
import WayofTime.bloodmagic.routing.*;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -14,28 +16,16 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.item.inventory.ItemInventory;
|
||||
import WayofTime.bloodmagic.routing.DefaultItemFilter;
|
||||
import WayofTime.bloodmagic.routing.IItemFilter;
|
||||
import WayofTime.bloodmagic.routing.IgnoreNBTItemFilter;
|
||||
import WayofTime.bloodmagic.routing.ModIdItemFilter;
|
||||
import WayofTime.bloodmagic.routing.OreDictItemFilter;
|
||||
import WayofTime.bloodmagic.routing.TestItemFilter;
|
||||
import WayofTime.bloodmagic.util.GhostItemHelper;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemRouterFilter extends Item implements IItemFilterProvider, IVariantProvider
|
||||
{
|
||||
public static String[] names = { "exact", "ignoreNBT", "modItems", "oreDict" };
|
||||
public class ItemRouterFilter extends Item implements IItemFilterProvider, IVariantProvider {
|
||||
public static String[] names = {"exact", "ignoreNBT", "modItems", "oreDict"};
|
||||
|
||||
public ItemRouterFilter()
|
||||
{
|
||||
public ItemRouterFilter() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".itemFilter.");
|
||||
|
@ -44,15 +34,13 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -62,44 +50,39 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.add(TextHelper.localize("tooltip.bloodmagic.itemFilter." + names[stack.getItemDamage()]));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemFilter getInputItemFilter(ItemStack filterStack, TileEntity tile, IItemHandler handler)
|
||||
{
|
||||
public IItemFilter getInputItemFilter(ItemStack filterStack, TileEntity tile, IItemHandler handler) {
|
||||
IItemFilter testFilter = new TestItemFilter();
|
||||
|
||||
switch (filterStack.getMetadata())
|
||||
{
|
||||
case 0:
|
||||
testFilter = new TestItemFilter();
|
||||
break;
|
||||
case 1:
|
||||
testFilter = new IgnoreNBTItemFilter();
|
||||
break;
|
||||
case 2:
|
||||
testFilter = new ModIdItemFilter();
|
||||
break;
|
||||
case 3:
|
||||
testFilter = new OreDictItemFilter();
|
||||
break;
|
||||
switch (filterStack.getMetadata()) {
|
||||
case 0:
|
||||
testFilter = new TestItemFilter();
|
||||
break;
|
||||
case 1:
|
||||
testFilter = new IgnoreNBTItemFilter();
|
||||
break;
|
||||
case 2:
|
||||
testFilter = new ModIdItemFilter();
|
||||
break;
|
||||
case 3:
|
||||
testFilter = new OreDictItemFilter();
|
||||
break;
|
||||
|
||||
default:
|
||||
testFilter = new DefaultItemFilter();
|
||||
default:
|
||||
testFilter = new DefaultItemFilter();
|
||||
}
|
||||
|
||||
List<ItemStack> filteredList = new ArrayList<ItemStack>();
|
||||
ItemInventory inv = new ItemInventory(filterStack, 9, "");
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
{
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -113,42 +96,37 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari
|
|||
}
|
||||
|
||||
@Override
|
||||
public IItemFilter getOutputItemFilter(ItemStack filterStack, TileEntity tile, IItemHandler handler)
|
||||
{
|
||||
public IItemFilter getOutputItemFilter(ItemStack filterStack, TileEntity tile, IItemHandler handler) {
|
||||
IItemFilter testFilter;
|
||||
|
||||
switch (filterStack.getMetadata())
|
||||
{
|
||||
case 0:
|
||||
testFilter = new TestItemFilter();
|
||||
break;
|
||||
case 1:
|
||||
testFilter = new IgnoreNBTItemFilter();
|
||||
break;
|
||||
case 2:
|
||||
testFilter = new ModIdItemFilter();
|
||||
break;
|
||||
case 3:
|
||||
testFilter = new OreDictItemFilter();
|
||||
break;
|
||||
switch (filterStack.getMetadata()) {
|
||||
case 0:
|
||||
testFilter = new TestItemFilter();
|
||||
break;
|
||||
case 1:
|
||||
testFilter = new IgnoreNBTItemFilter();
|
||||
break;
|
||||
case 2:
|
||||
testFilter = new ModIdItemFilter();
|
||||
break;
|
||||
case 3:
|
||||
testFilter = new OreDictItemFilter();
|
||||
break;
|
||||
|
||||
default:
|
||||
testFilter = new DefaultItemFilter();
|
||||
default:
|
||||
testFilter = new DefaultItemFilter();
|
||||
}
|
||||
|
||||
List<ItemStack> filteredList = new ArrayList<ItemStack>();
|
||||
ItemInventory inv = new ItemInventory(filterStack, 9, ""); //TODO: Change to grab the filter from the Item later.
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++)
|
||||
{
|
||||
for (int i = 0; i < inv.getSizeInventory(); i++) {
|
||||
ItemStack stack = inv.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
{
|
||||
if (stack == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack ghostStack = GhostItemHelper.getStackFromGhost(stack);
|
||||
if (ghostStack.isEmpty())
|
||||
{
|
||||
if (ghostStack.isEmpty()) {
|
||||
ghostStack.setCount(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
@ -160,8 +138,7 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=exact"));
|
||||
ret.add(new ImmutablePair<Integer, String>(1, "type=ignorenbt"));
|
||||
|
@ -171,8 +148,7 @@ public class ItemRouterFilter extends Item implements IItemFilterProvider, IVari
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getContainedStackForItem(ItemStack filterStack, ItemStack keyStack)
|
||||
{
|
||||
public ItemStack getContainedStackForItem(ItemStack filterStack, ItemStack keyStack) {
|
||||
ItemStack copyStack = keyStack.copy();
|
||||
GhostItemHelper.setItemGhostAmount(copyStack, 0);
|
||||
copyStack.setCount(1);
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
|
@ -15,20 +18,14 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
|
||||
public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectProvider
|
||||
{
|
||||
public ItemSigilAir()
|
||||
{
|
||||
public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectProvider {
|
||||
public ItemSigilAir() {
|
||||
super("air", 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
|
@ -36,14 +33,12 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP
|
|||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
boolean unusable = isUnusable(stack);
|
||||
if (world.isRemote && !unusable)
|
||||
{
|
||||
if (world.isRemote && !unusable) {
|
||||
Vec3d vec = player.getLookVec();
|
||||
double wantedVelocity = 1.7;
|
||||
|
||||
// TODO - Revisit after potions
|
||||
if (player.isPotionActive(RegistrarBloodMagic.BOOST))
|
||||
{
|
||||
if (player.isPotionActive(RegistrarBloodMagic.BOOST)) {
|
||||
int amplifier = player.getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier();
|
||||
wantedVelocity += (1 + amplifier) * (0.35);
|
||||
}
|
||||
|
@ -54,8 +49,7 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP
|
|||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()));
|
||||
|
||||
|
@ -67,15 +61,13 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target)
|
||||
{
|
||||
public boolean applyOnHitEffect(EnumDemonWillType type, ItemStack swordStack, ItemStack providerStack, EntityLivingBase attacker, EntityLivingBase target) {
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.LEVITATION, 200, 0));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean providesEffectForWill(EnumDemonWillType type)
|
||||
{
|
||||
public boolean providesEffectForWill(EnumDemonWillType type) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,27 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.impl.ItemSigil;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.client.IVariantProvider;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilBase extends ItemSigil implements IVariantProvider
|
||||
{
|
||||
public class ItemSigilBase extends ItemSigil implements IVariantProvider {
|
||||
protected final String tooltipBase;
|
||||
private final String name;
|
||||
|
||||
public ItemSigilBase(String name, int lpUsed)
|
||||
{
|
||||
public ItemSigilBase(String name, int lpUsed) {
|
||||
super(lpUsed);
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".sigil." + name);
|
||||
|
@ -35,15 +31,13 @@ public class ItemSigilBase extends ItemSigil implements IVariantProvider
|
|||
this.tooltipBase = "tooltip.bloodmagic.sigil." + name + ".";
|
||||
}
|
||||
|
||||
public ItemSigilBase(String name)
|
||||
{
|
||||
public ItemSigilBase(String name) {
|
||||
this(name, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (TextHelper.canTranslate(tooltipBase + "desc"))
|
||||
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect(tooltipBase + "desc"))));
|
||||
|
||||
|
@ -57,8 +51,7 @@ public class ItemSigilBase extends ItemSigil implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(Pair.of(0, "type=normal"));
|
||||
return ret;
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -11,29 +16,20 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
|
||||
public class ItemSigilBloodLight extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilBloodLight()
|
||||
{
|
||||
public class ItemSigilBloodLight extends ItemSigilBase {
|
||||
public ItemSigilBloodLight() {
|
||||
super("bloodLight", 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
|
||||
if (getCooldownRemainder(stack) > 0)
|
||||
reduceCooldown(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
|
@ -45,12 +41,10 @@ public class ItemSigilBloodLight extends ItemSigilBase
|
|||
if (getCooldownRemainder(stack) > 0)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
|
||||
|
||||
if (world.isAirBlock(blockPos))
|
||||
{
|
||||
if (world.isAirBlock(blockPos)) {
|
||||
world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
|
||||
if (!world.isRemote)
|
||||
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed());
|
||||
|
@ -58,10 +52,8 @@ public class ItemSigilBloodLight extends ItemSigilBase
|
|||
player.swingArm(hand);
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
} else {
|
||||
if (!world.isRemote) {
|
||||
world.spawnEntity(new EntityBloodLight(world, player));
|
||||
NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed());
|
||||
}
|
||||
|
@ -72,23 +64,19 @@ public class ItemSigilBloodLight extends ItemSigilBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
public int getCooldownRemainder(ItemStack stack)
|
||||
{
|
||||
public int getCooldownRemainder(ItemStack stack) {
|
||||
return NBTHelper.checkNBT(stack).getTagCompound().getInteger(Constants.NBT.TICKS_REMAINING);
|
||||
}
|
||||
|
||||
public void reduceCooldown(ItemStack stack)
|
||||
{
|
||||
public void reduceCooldown(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, getCooldownRemainder(stack) - 1);
|
||||
}
|
||||
|
||||
public void resetCooldown(ItemStack stack)
|
||||
{
|
||||
public void resetCooldown(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack).getTagCompound().setInteger(Constants.NBT.TICKS_REMAINING, 10);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilBounce extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilBounce()
|
||||
{
|
||||
public class ItemSigilBounce extends ItemSigilToggleableBase {
|
||||
public ItemSigilBounce() {
|
||||
super("bounce", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
|
|
|
@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilClaw extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilClaw()
|
||||
{
|
||||
public class ItemSigilClaw extends ItemSigilToggleableBase {
|
||||
public ItemSigilClaw() {
|
||||
super("claw", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
|
|
|
@ -7,10 +7,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilCompression extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilCompression()
|
||||
{
|
||||
public class ItemSigilCompression extends ItemSigilToggleableBase {
|
||||
public ItemSigilCompression() {
|
||||
super("compression", 200);
|
||||
}
|
||||
|
||||
|
@ -18,8 +16,7 @@ public class ItemSigilCompression extends ItemSigilToggleableBase
|
|||
// TODO for now, there is a semi-working system in place
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (true)
|
||||
return; // TODO - Rewrite compression system
|
||||
|
||||
|
@ -28,8 +25,7 @@ public class ItemSigilCompression extends ItemSigilToggleableBase
|
|||
|
||||
ItemStack compressedStack = CompressionRegistry.compressInventory(player.inventory.mainInventory.toArray(new ItemStack[player.inventory.mainInventory.size()]), world);
|
||||
|
||||
if (compressedStack != null)
|
||||
{
|
||||
if (compressedStack != null) {
|
||||
EntityItem entityItem = new EntityItem(world, player.posX, player.posY, player.posZ, compressedStack);
|
||||
world.spawnEntity(entityItem);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.tile.TileIncenseAltar;
|
||||
import WayofTime.bloodmagic.tile.TileInversionPillar;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -14,25 +19,17 @@ import net.minecraft.util.math.RayTraceResult;
|
|||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.tile.TileIncenseAltar;
|
||||
import WayofTime.bloodmagic.tile.TileInversionPillar;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
||||
|
||||
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
|
||||
{
|
||||
public ItemSigilDivination()
|
||||
{
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader {
|
||||
public ItemSigilDivination() {
|
||||
super("divination");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
// if (world instanceof WorldServer)
|
||||
// {
|
||||
// System.out.println("Testing...");
|
||||
|
@ -54,42 +51,35 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
|
|||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
super.onItemRightClick(world, player, hand);
|
||||
|
||||
RayTraceResult position = rayTrace(world, player, false);
|
||||
|
||||
if (position == null)
|
||||
{
|
||||
if (position == null) {
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
|
||||
List<ITextComponent> toSend = new ArrayList<ITextComponent>();
|
||||
if (!getOwnerName(stack).equals(PlayerHelper.getUsernameFromPlayer(player)))
|
||||
toSend.add(new TextComponentTranslation(tooltipBase + "otherNetwork", getOwnerName(stack)));
|
||||
toSend.add(new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
|
||||
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
|
||||
} else
|
||||
{
|
||||
if (position.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
} else {
|
||||
if (position.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
TileEntity tile = world.getTileEntity(position.getBlockPos());
|
||||
|
||||
if (tile != null && tile instanceof IBloodAltar)
|
||||
{
|
||||
if (tile != null && tile instanceof IBloodAltar) {
|
||||
IBloodAltar altar = (IBloodAltar) tile;
|
||||
int tier = altar.getTier().ordinal() + 1;
|
||||
int currentEssence = altar.getCurrentBlood();
|
||||
int capacity = altar.getCapacity();
|
||||
altar.checkTier();
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity));
|
||||
} else if (tile != null && tile instanceof TileIncenseAltar)
|
||||
{
|
||||
} else if (tile != null && tile instanceof TileIncenseAltar) {
|
||||
TileIncenseAltar altar = (TileIncenseAltar) tile;
|
||||
altar.recheckConstruction();
|
||||
double tranquility = altar.tranquility;
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentTranquility", (int) ((100D * (int) (100 * tranquility)) / 100d)), new TextComponentTranslation(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition)));
|
||||
} else if (tile != null && tile instanceof TileInversionPillar)
|
||||
{
|
||||
} else if (tile != null && tile instanceof TileInversionPillar) {
|
||||
TileInversionPillar pillar = (TileInversionPillar) tile;
|
||||
double inversion = pillar.getCurrentInversion();
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentInversion", ((int) (10 * inversion)) / 10d));
|
||||
|
|
|
@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilElementalAffinity extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilElementalAffinity()
|
||||
{
|
||||
public class ItemSigilElementalAffinity extends ItemSigilToggleableBase {
|
||||
public ItemSigilElementalAffinity() {
|
||||
super("elementalAffinity", 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -11,22 +9,20 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilEnderSeverance extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilEnderSeverance()
|
||||
{
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilEnderSeverance extends ItemSigilToggleableBase {
|
||||
public ItemSigilEnderSeverance() {
|
||||
super("enderSeverance", 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
List<Entity> entityList = world.getEntitiesWithinAABB(Entity.class, new net.minecraft.util.math.AxisAlignedBB(player.posX - 4.5, player.posY - 4.5, player.posZ - 4.5, player.posX + 4.5, player.posY + 4.5, player.posZ + 4.5));
|
||||
for (Entity entity : entityList)
|
||||
{
|
||||
for (Entity entity : entityList) {
|
||||
if (entity instanceof EntityEnderman)
|
||||
((EntityEnderman) entity).addPotionEffect(new PotionEffect(RegistrarBloodMagic.PLANAR_BINDING, 40, 0));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -12,37 +10,32 @@ import net.minecraft.util.math.AxisAlignedBB;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilFastMiner extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilFastMiner()
|
||||
{
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilFastMiner extends ItemSigilToggleableBase {
|
||||
public ItemSigilFastMiner() {
|
||||
super("fastMiner", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, 2, 0, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performArrayEffect(World world, BlockPos pos)
|
||||
{
|
||||
public boolean performArrayEffect(World world, BlockPos pos) {
|
||||
double radius = 10;
|
||||
int ticks = 600;
|
||||
int potionPotency = 2;
|
||||
|
||||
AxisAlignedBB bb = new AxisAlignedBB(pos).grow(radius);
|
||||
List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, bb);
|
||||
for (EntityPlayer player : playerList)
|
||||
{
|
||||
if (!player.isPotionActive(MobEffects.HASTE) || (player.isPotionActive(MobEffects.HASTE) && player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() < potionPotency))
|
||||
{
|
||||
for (EntityPlayer player : playerList) {
|
||||
if (!player.isPotionActive(MobEffects.HASTE) || (player.isPotionActive(MobEffects.HASTE) && player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() < potionPotency)) {
|
||||
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, ticks, potionPotency));
|
||||
if (!player.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
player.hurtResistantTime = 0;
|
||||
player.attackEntityFrom(BloodMagicAPI.damageSource, 1.0F);
|
||||
}
|
||||
|
@ -53,8 +46,7 @@ public class ItemSigilFastMiner extends ItemSigilToggleableBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArrayEffect()
|
||||
{
|
||||
public boolean hasArrayEffect() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,18 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.util.handler.event.GenericHandler;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.util.handler.event.GenericHandler;
|
||||
|
||||
public class ItemSigilFilledHand extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilFilledHand()
|
||||
{
|
||||
public class ItemSigilFilledHand extends ItemSigilToggleableBase {
|
||||
public ItemSigilFilledHand() {
|
||||
super("hand", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
GenericHandler.filledHandMap.put(player, 4);
|
||||
|
|
|
@ -6,16 +6,13 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilFrost extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilFrost()
|
||||
{
|
||||
public class ItemSigilFrost extends ItemSigilToggleableBase {
|
||||
public ItemSigilFrost() {
|
||||
super("frost", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
|
|
|
@ -14,23 +14,18 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
import net.minecraftforge.event.entity.player.BonemealEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||
|
||||
public class ItemSigilGreenGrove extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilGreenGrove()
|
||||
{
|
||||
public class ItemSigilGreenGrove extends ItemSigilToggleableBase {
|
||||
public ItemSigilGreenGrove() {
|
||||
super("greenGrove", 150);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSigilUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public boolean onSigilUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return false;
|
||||
|
||||
if (applyBonemeal(world, blockPos, player, stack))
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (applyBonemeal(world, blockPos, player, stack)) {
|
||||
if (!world.isRemote) {
|
||||
world.playEvent(2005, blockPos, 0);
|
||||
}
|
||||
return true;
|
||||
|
@ -40,8 +35,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World worldIn, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World worldIn, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
|
@ -51,21 +45,15 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
|
|||
int posY = (int) player.posY;
|
||||
int posZ = (int) Math.round(player.posZ - 0.5f);
|
||||
|
||||
for (int ix = posX - range; ix <= posX + range; ix++)
|
||||
{
|
||||
for (int iz = posZ - range; iz <= posZ + range; iz++)
|
||||
{
|
||||
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++)
|
||||
{
|
||||
for (int ix = posX - range; ix <= posX + range; ix++) {
|
||||
for (int iz = posZ - range; iz <= posZ + range; iz++) {
|
||||
for (int iy = posY - verticalRange; iy <= posY + verticalRange; iy++) {
|
||||
BlockPos blockPos = new BlockPos(ix, iy, iz);
|
||||
IBlockState state = worldIn.getBlockState(blockPos);
|
||||
|
||||
if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state))
|
||||
{
|
||||
if (state.getBlock() instanceof IGrowable)
|
||||
{
|
||||
if (worldIn.rand.nextInt(50) == 0)
|
||||
{
|
||||
if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) {
|
||||
if (state.getBlock() instanceof IGrowable) {
|
||||
if (worldIn.rand.nextInt(50) == 0) {
|
||||
IBlockState preBlockState = worldIn.getBlockState(blockPos);
|
||||
state.getBlock().updateTick(worldIn, blockPos, state, worldIn.rand);
|
||||
|
||||
|
@ -80,8 +68,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
|
|||
}
|
||||
}
|
||||
|
||||
private boolean applyBonemeal(World worldIn, BlockPos target, EntityPlayer player, ItemStack sigilStack)
|
||||
{
|
||||
private boolean applyBonemeal(World worldIn, BlockPos target, EntityPlayer player, ItemStack sigilStack) {
|
||||
IBlockState iblockstate = worldIn.getBlockState(target);
|
||||
|
||||
BonemealEvent event = new BonemealEvent(player, worldIn, target, iblockstate, EnumHand.MAIN_HAND, sigilStack);
|
||||
|
@ -90,14 +77,11 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase
|
|||
else if (event.getResult() == Result.ALLOW)
|
||||
return true;
|
||||
|
||||
if (iblockstate.getBlock() instanceof IGrowable)
|
||||
{
|
||||
if (iblockstate.getBlock() instanceof IGrowable) {
|
||||
IGrowable igrowable = (IGrowable) iblockstate.getBlock();
|
||||
|
||||
if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote))
|
||||
{
|
||||
if (!worldIn.isRemote)
|
||||
{
|
||||
if (igrowable.canGrow(worldIn, target, iblockstate, worldIn.isRemote)) {
|
||||
if (!worldIn.isRemote) {
|
||||
if (igrowable.canUseBonemeal(worldIn, worldIn.rand, target, iblockstate))
|
||||
igrowable.grow(worldIn, worldIn.rand, target, iblockstate);
|
||||
}
|
||||
|
|
|
@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilHaste extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilHaste()
|
||||
{
|
||||
public class ItemSigilHaste extends ItemSigilToggleableBase {
|
||||
public ItemSigilHaste() {
|
||||
super("haste", 250);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.client.key.IKeybindable;
|
||||
import WayofTime.bloodmagic.client.key.KeyBindings;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -18,44 +24,29 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.api.iface.IBindable;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import WayofTime.bloodmagic.client.key.IKeybindable;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader, ISigil.Holding
|
||||
{
|
||||
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader, ISigil.Holding {
|
||||
public static final int inventorySize = 5;
|
||||
|
||||
public ItemSigilHolding()
|
||||
{
|
||||
public ItemSigilHolding() {
|
||||
super("holding");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyPressed(ItemStack stack, EntityPlayer player, KeyBindings key, boolean showInChat)
|
||||
{
|
||||
if (stack == player.getHeldItemMainhand() && stack.getItem() instanceof ItemSigilHolding && key.equals(KeyBindings.OPEN_HOLDING))
|
||||
{
|
||||
public void onKeyPressed(ItemStack stack, EntityPlayer player, KeyBindings key, boolean showInChat) {
|
||||
if (stack == player.getHeldItemMainhand() && stack.getItem() instanceof ItemSigilHolding && key.equals(KeyBindings.OPEN_HOLDING)) {
|
||||
Utils.setUUID(stack);
|
||||
player.openGui(BloodMagic.instance, Constants.Gui.SIGIL_HOLDING_GUI, player.getEntityWorld(), (int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHighlightTip(ItemStack stack, String displayName)
|
||||
{
|
||||
public String getHighlightTip(ItemStack stack, String displayName) {
|
||||
List<ItemStack> inv = getInternalInventory(stack);
|
||||
int currentSlot = getCurrentItemOrdinal(stack);
|
||||
ItemStack item = inv.get(currentSlot);
|
||||
|
@ -68,8 +59,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.sigil.holding.press", KeyBindings.OPEN_HOLDING.getKey().getDisplayName()));
|
||||
|
||||
|
@ -80,8 +70,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
int currentSlot = getCurrentItemOrdinal(stack);
|
||||
ItemStack item = inv.get(currentSlot);
|
||||
|
||||
for (int i = 0; i < inventorySize; i++)
|
||||
{
|
||||
for (int i = 0; i < inventorySize; i++) {
|
||||
ItemStack invStack = inv.get(i);
|
||||
if (!invStack.isEmpty())
|
||||
if (!item.isEmpty() && invStack == item)
|
||||
|
@ -92,8 +81,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return EnumActionResult.FAIL;
|
||||
|
@ -112,8 +100,7 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
@ -134,26 +121,21 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player)
|
||||
{
|
||||
public ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player) {
|
||||
return getInternalInventory(holdingStack).get(getCurrentItemOrdinal(holdingStack));
|
||||
}
|
||||
|
||||
public void saveInventory(ItemStack itemStack, List<ItemStack> inventory)
|
||||
{
|
||||
public void saveInventory(ItemStack itemStack, List<ItemStack> inventory) {
|
||||
NBTTagCompound itemTag = itemStack.getTagCompound();
|
||||
|
||||
if (itemTag == null)
|
||||
{
|
||||
if (itemTag == null) {
|
||||
itemStack.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagList itemList = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < inventorySize; i++)
|
||||
{
|
||||
if (!inventory.get(i).isEmpty())
|
||||
{
|
||||
for (int i = 0; i < inventorySize; i++) {
|
||||
if (!inventory.get(i).isEmpty()) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setByte(Constants.NBT.SLOT, (byte) i);
|
||||
inventory.get(i).writeToNBT(tag);
|
||||
|
@ -165,23 +147,18 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (itemStack.getTagCompound() != null)
|
||||
{
|
||||
public void onUpdate(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
if (itemStack.getTagCompound() != null) {
|
||||
this.tickInternalInventory(itemStack, world, entity, itemSlot, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
public void tickInternalInventory(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void tickInternalInventory(ItemStack itemStack, World world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
List<ItemStack> inv = getInternalInventory(itemStack);
|
||||
|
||||
for (int i = 0; i < inventorySize; i++)
|
||||
{
|
||||
for (int i = 0; i < inventorySize; i++) {
|
||||
ItemStack stack = inv.get(i);
|
||||
if (stack.isEmpty())
|
||||
{
|
||||
if (stack.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -189,43 +166,40 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
}
|
||||
}
|
||||
|
||||
public static int next(int mode)
|
||||
{
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static int next(int mode) {
|
||||
int index = mode + 1;
|
||||
|
||||
if (index >= inventorySize)
|
||||
{
|
||||
if (index >= inventorySize) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
public static int prev(int mode)
|
||||
{
|
||||
public static int prev(int mode) {
|
||||
int index = mode - 1;
|
||||
|
||||
if (index < 0)
|
||||
{
|
||||
if (index < 0) {
|
||||
index = inventorySize;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
private static void initModeTag(ItemStack stack)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
{
|
||||
private static void initModeTag(ItemStack stack) {
|
||||
if (!stack.hasTagCompound()) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
stack.getTagCompound().setInteger(Constants.NBT.CURRENT_SIGIL, inventorySize);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getItemStackInSlot(ItemStack itemStack, int slot)
|
||||
{
|
||||
if (itemStack.getItem() instanceof ItemSigilHolding)
|
||||
{
|
||||
public static ItemStack getItemStackInSlot(ItemStack itemStack, int slot) {
|
||||
if (itemStack.getItem() instanceof ItemSigilHolding) {
|
||||
List<ItemStack> inv = getInternalInventory(itemStack);
|
||||
if (inv != null)
|
||||
return inv.get(slot == 5 ? 4 : slot);
|
||||
|
@ -236,10 +210,8 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
public static int getCurrentItemOrdinal(ItemStack stack)
|
||||
{
|
||||
if (stack.getItem() instanceof ItemSigilHolding)
|
||||
{
|
||||
public static int getCurrentItemOrdinal(ItemStack stack) {
|
||||
if (stack.getItem() instanceof ItemSigilHolding) {
|
||||
initModeTag(stack);
|
||||
int currentSigil = stack.getTagCompound().getInteger(Constants.NBT.CURRENT_SIGIL);
|
||||
currentSigil = MathHelper.clamp(currentSigil, 0, inventorySize - 1);
|
||||
|
@ -249,32 +221,27 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static List<ItemStack> getInternalInventory(ItemStack stack)
|
||||
{
|
||||
public static List<ItemStack> getInternalInventory(ItemStack stack) {
|
||||
initModeTag(stack);
|
||||
NBTTagCompound tagCompound = stack.getTagCompound();
|
||||
|
||||
if (tagCompound == null)
|
||||
{
|
||||
if (tagCompound == null) {
|
||||
return NonNullList.withSize(inventorySize, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
NBTTagList tagList = tagCompound.getTagList(Constants.NBT.ITEMS, 10);
|
||||
|
||||
if (tagList.hasNoTags())
|
||||
{
|
||||
if (tagList.hasNoTags()) {
|
||||
return NonNullList.withSize(inventorySize, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
List<ItemStack> inv = NonNullList.withSize(inventorySize, ItemStack.EMPTY);
|
||||
|
||||
for (int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
for (int i = 0; i < tagList.tagCount(); i++) {
|
||||
NBTTagCompound data = tagList.getCompoundTagAt(i);
|
||||
byte j = data.getByte(Constants.NBT.SLOT);
|
||||
|
||||
if (j >= 0 && j < inv.size())
|
||||
{
|
||||
if (j >= 0 && j < inv.size()) {
|
||||
inv.set(j, new ItemStack(data));
|
||||
}
|
||||
}
|
||||
|
@ -282,36 +249,29 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
return inv;
|
||||
}
|
||||
|
||||
public static void cycleToNextSigil(ItemStack itemStack, int mode)
|
||||
{
|
||||
if (itemStack.getItem() instanceof ItemSigilHolding)
|
||||
{
|
||||
public static void cycleToNextSigil(ItemStack itemStack, int mode) {
|
||||
if (itemStack.getItem() instanceof ItemSigilHolding) {
|
||||
initModeTag(itemStack);
|
||||
|
||||
int index = mode;
|
||||
if (mode == 120 || mode == -120)
|
||||
{
|
||||
if (mode == 120 || mode == -120) {
|
||||
int currentIndex = getCurrentItemOrdinal(itemStack);
|
||||
ItemStack currentItemStack = getItemStackInSlot(itemStack, currentIndex);
|
||||
if (currentItemStack.isEmpty())
|
||||
return;
|
||||
if (mode < 0)
|
||||
{
|
||||
if (mode < 0) {
|
||||
index = next(currentIndex);
|
||||
currentItemStack = getItemStackInSlot(itemStack, index);
|
||||
|
||||
while (currentItemStack.isEmpty())
|
||||
{
|
||||
while (currentItemStack.isEmpty()) {
|
||||
index = next(index);
|
||||
currentItemStack = getItemStackInSlot(itemStack, index);
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
index = prev(currentIndex);
|
||||
currentItemStack = getItemStackInSlot(itemStack, index);
|
||||
|
||||
while (currentItemStack.isEmpty())
|
||||
{
|
||||
while (currentItemStack.isEmpty()) {
|
||||
index = prev(index);
|
||||
currentItemStack = getItemStackInSlot(itemStack, index);
|
||||
}
|
||||
|
@ -321,10 +281,4 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
|||
itemStack.getTagCompound().setInteger(Constants.NBT.CURRENT_SIGIL, index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,55 +21,45 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
public class ItemSigilLava extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilLava()
|
||||
{
|
||||
public class ItemSigilLava extends ItemSigilBase {
|
||||
public ItemSigilLava() {
|
||||
super("lava", 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
if (!world.isRemote && !isUnusable(stack)) {
|
||||
RayTraceResult rayTrace = this.rayTrace(world, player, false);
|
||||
|
||||
if (rayTrace != null)
|
||||
{
|
||||
if (rayTrace != null) {
|
||||
ActionResult<ItemStack> ret = ForgeEventFactory.onBucketUse(player, world, stack, rayTrace);
|
||||
if (ret != null)
|
||||
return ret;
|
||||
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
BlockPos blockpos = rayTrace.getBlockPos();
|
||||
|
||||
if (!world.isBlockModifiable(player, blockpos))
|
||||
{
|
||||
if (!world.isBlockModifiable(player, blockpos)) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack))
|
||||
{
|
||||
if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack)) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
BlockPos blockpos1 = blockpos.offset(rayTrace.sideHit);
|
||||
|
||||
if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack))
|
||||
{
|
||||
if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack)) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1))
|
||||
{
|
||||
if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1)) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
||||
|
@ -80,27 +70,22 @@ public class ItemSigilLava extends ItemSigilBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (world.isRemote || player.isSneaking() || isUnusable(stack))
|
||||
{
|
||||
if (world.isRemote || player.isSneaking() || isUnusable(stack)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
if (!world.canMineBlockBody(player, blockPos))
|
||||
{
|
||||
if (!world.canMineBlockBody(player, blockPos)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side))
|
||||
{
|
||||
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
|
||||
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
|
||||
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
|
||||
int amount = handler.fill(fluid, false);
|
||||
|
||||
if (amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()))
|
||||
{
|
||||
if (amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) {
|
||||
handler.fill(fluid, true);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
@ -111,23 +96,18 @@ public class ItemSigilLava extends ItemSigilBase
|
|||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
public boolean canPlaceLava(World world, BlockPos blockPos)
|
||||
{
|
||||
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isSolid())
|
||||
{
|
||||
public boolean canPlaceLava(World world, BlockPos blockPos) {
|
||||
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).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.FLOWING_LAVA.getBlockState().getBaseState(), 3);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean tryPlaceLava(World world, BlockPos pos)
|
||||
{
|
||||
public boolean tryPlaceLava(World world, BlockPos pos) {
|
||||
Material material = world.getBlockState(pos).getBlock().getMaterial(world.getBlockState(pos));
|
||||
|
||||
return world.isAirBlock(pos) && !material.isSolid();
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityXPOrb;
|
||||
|
@ -10,16 +8,15 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilMagnetism extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilMagnetism()
|
||||
{
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilMagnetism extends ItemSigilToggleableBase {
|
||||
public ItemSigilMagnetism() {
|
||||
super("magnetism", 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
|
@ -31,18 +28,14 @@ public class ItemSigilMagnetism extends ItemSigilToggleableBase
|
|||
List<EntityItem> entities = player.getEntityWorld().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
|
||||
List<EntityXPOrb> xpOrbs = player.getEntityWorld().getEntitiesWithinAABB(EntityXPOrb.class, new AxisAlignedBB(posX - 0.5f, posY - 0.5f, posZ - 0.5f, posX + 0.5f, posY + 0.5f, posZ + 0.5f).expand(range, verticalRange, range));
|
||||
|
||||
for (EntityItem entity : entities)
|
||||
{
|
||||
if (entity != null && !world.isRemote && !entity.isDead)
|
||||
{
|
||||
for (EntityItem entity : entities) {
|
||||
if (entity != null && !world.isRemote && !entity.isDead) {
|
||||
entity.onCollideWithPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
for (EntityXPOrb xpOrb : xpOrbs)
|
||||
{
|
||||
if (xpOrb != null && !world.isRemote)
|
||||
{
|
||||
for (EntityXPOrb xpOrb : xpOrbs) {
|
||||
if (xpOrb != null && !world.isRemote) {
|
||||
xpOrb.onCollideWithPlayer(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,35 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
|
||||
{
|
||||
public class ItemSigilPhantomBridge extends ItemSigilToggleableBase {
|
||||
private Map<EntityPlayer, Pair<Double, Double>> prevPositionMap = new HashMap<EntityPlayer, Pair<Double, Double>>();
|
||||
private double expansionFactor = 2;
|
||||
private int range = 3;
|
||||
|
||||
public ItemSigilPhantomBridge()
|
||||
{
|
||||
public ItemSigilPhantomBridge() {
|
||||
super("phantomBridge", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
if (!prevPositionMap.containsKey(player))
|
||||
{
|
||||
if (!prevPositionMap.containsKey(player)) {
|
||||
prevPositionMap.put(player, Pair.of(player.posX, player.posZ));
|
||||
}
|
||||
|
||||
if ((!player.onGround && !player.isRiding()) && !player.isSneaking())
|
||||
{
|
||||
if ((!player.onGround && !player.isRiding()) && !player.isSneaking()) {
|
||||
prevPositionMap.put(player, Pair.of(player.posX, player.posZ));
|
||||
return;
|
||||
}
|
||||
|
@ -52,8 +45,7 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
|
|||
double playerVelZ = player.posZ - prevPosition.getRight();
|
||||
|
||||
double totalVel = Math.sqrt(playerVelX * playerVelX + playerVelZ * playerVelZ);
|
||||
if (totalVel > 2)
|
||||
{
|
||||
if (totalVel > 2) {
|
||||
//I am SURE you are teleporting!
|
||||
playerVelX = 0;
|
||||
playerVelZ = 0;
|
||||
|
@ -74,12 +66,9 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
|
|||
int truncC = (int) C;
|
||||
|
||||
//TODO: Make this for-loop better.
|
||||
for (int ix = -truncC; ix <= truncC; ix++)
|
||||
{
|
||||
for (int iz = -truncC; iz <= truncC; iz++)
|
||||
{
|
||||
if (computeEllipse(ix + avgX, iz + avgZ, posX, posZ, offsetPosX, offsetPosZ) > C)
|
||||
{
|
||||
for (int ix = -truncC; ix <= truncC; ix++) {
|
||||
for (int iz = -truncC; iz <= truncC; iz++) {
|
||||
if (computeEllipse(ix + avgX, iz + avgZ, posX, posZ, offsetPosX, offsetPosZ) > C) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -93,8 +82,7 @@ public class ItemSigilPhantomBridge extends ItemSigilToggleableBase
|
|||
prevPositionMap.put(player, Pair.of(player.posX, player.posZ));
|
||||
}
|
||||
|
||||
public static double computeEllipse(double x, double z, double focusX1, double focusZ1, double focusX2, double focusZ2)
|
||||
{
|
||||
public static double computeEllipse(double x, double z, double focusX1, double focusZ1, double focusX2, double focusZ2) {
|
||||
return Math.sqrt((x - focusX1) * (x - focusX1) + (z - focusZ1) * (z - focusZ1)) + Math.sqrt((x - focusX2) * (x - focusX2) + (z - focusZ2) * (z - focusZ2));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.tile.TileIncenseAltar;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
@ -16,36 +19,28 @@ import net.minecraft.util.math.RayTraceResult;
|
|||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||
import WayofTime.bloodmagic.api.iface.IAltarReader;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.tile.TileIncenseAltar;
|
||||
import WayofTime.bloodmagic.util.ChatUtil;
|
||||
|
||||
public class ItemSigilSeer extends ItemSigilBase implements IAltarReader
|
||||
{
|
||||
public ItemSigilSeer()
|
||||
{
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilSeer extends ItemSigilBase implements IAltarReader {
|
||||
public ItemSigilSeer() {
|
||||
super("seer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
super.onItemRightClick(world, player, hand);
|
||||
RayTraceResult rayTrace = rayTrace(world, player, false);
|
||||
|
||||
if (rayTrace == null)
|
||||
{
|
||||
if (rayTrace == null) {
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
|
||||
|
||||
List<ITextComponent> toSend = new ArrayList<ITextComponent>();
|
||||
|
@ -53,42 +48,34 @@ public class ItemSigilSeer extends ItemSigilBase implements IAltarReader
|
|||
toSend.add(new TextComponentTranslation(tooltipBase + "otherNetwork", getOwnerName(stack)));
|
||||
toSend.add(new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
|
||||
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
|
||||
} else
|
||||
{
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
} else {
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
|
||||
TileEntity tile = world.getTileEntity(rayTrace.getBlockPos());
|
||||
|
||||
if (tile != null && tile instanceof IBloodAltar)
|
||||
{
|
||||
if (tile != null && tile instanceof IBloodAltar) {
|
||||
IBloodAltar altar = (IBloodAltar) tile;
|
||||
int tier = altar.getTier().ordinal() + 1;
|
||||
int currentEssence = altar.getCurrentBlood();
|
||||
int capacity = altar.getCapacity();
|
||||
int charge = altar.getTotalCharge();
|
||||
altar.checkTier();
|
||||
if (tile instanceof IInventory)
|
||||
{
|
||||
if (!((IInventory) tile).getStackInSlot(0).isEmpty())
|
||||
{
|
||||
if (tile instanceof IInventory) {
|
||||
if (!((IInventory) tile).getStackInSlot(0).isEmpty()) {
|
||||
int progress = altar.getProgress();
|
||||
int totalLiquidRequired = altar.getLiquidRequired() * ((IInventory) tile).getStackInSlot(0).getCount();
|
||||
int consumptionRate = (int) (altar.getConsumptionRate() * (altar.getConsumptionMultiplier() + 1));
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarProgress", progress, totalLiquidRequired), new TextComponentTranslation(tooltipBase + "currentAltarConsumptionRate", consumptionRate), new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity), new TextComponentTranslation(tooltipBase + "currentCharge", charge));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentAltarTier", NumeralHelper.toRoman(tier)), new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence), new TextComponentTranslation(tooltipBase + "currentAltarCapacity", capacity), new TextComponentTranslation(tooltipBase + "currentCharge", charge));
|
||||
}
|
||||
}
|
||||
} else if (tile != null && tile instanceof TileIncenseAltar)
|
||||
{
|
||||
} else if (tile != null && tile instanceof TileIncenseAltar) {
|
||||
TileIncenseAltar altar = (TileIncenseAltar) tile;
|
||||
altar.recheckConstruction();
|
||||
double tranquility = altar.tranquility;
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentTranquility", (int) ((100D * (int) (100 * tranquility)) / 100d)), new TextComponentTranslation(tooltipBase + "currentBonus", (int) (100 * altar.incenseAddition)));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).getCurrentEssence();
|
||||
ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentEssence", currentEssence));
|
||||
}
|
||||
|
|
|
@ -1,30 +1,22 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.tile.TileSpectralBlock;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
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.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilSuppression extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilSuppression()
|
||||
{
|
||||
public class ItemSigilSuppression extends ItemSigilToggleableBase {
|
||||
public ItemSigilSuppression() {
|
||||
super("suppression", 400);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
|
@ -34,14 +26,10 @@ public class ItemSigilSuppression extends ItemSigilToggleableBase
|
|||
final int radius = 5;
|
||||
final int refresh = 100;
|
||||
|
||||
for (int i = -radius; i <= radius; i++)
|
||||
{
|
||||
for (int j = -radius; j <= radius; j++)
|
||||
{
|
||||
for (int k = -radius; k <= radius; k++)
|
||||
{
|
||||
if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f))
|
||||
{
|
||||
for (int i = -radius; i <= radius; i++) {
|
||||
for (int j = -radius; j <= radius; j++) {
|
||||
for (int k = -radius; k <= radius; k++) {
|
||||
if (i * i + j * j + k * k >= (radius + 0.50f) * (radius + 0.50f)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -49,9 +37,8 @@ public class ItemSigilSuppression extends ItemSigilToggleableBase
|
|||
IBlockState state = world.getBlockState(blockPos);
|
||||
|
||||
if (Utils.isBlockLiquid(state) && world.getTileEntity(blockPos) == null)
|
||||
TileSpectralBlock.createSpectralBlock(world, blockPos, refresh);
|
||||
else
|
||||
{
|
||||
TileSpectralBlock.createSpectralBlock(world, blockPos, refresh);
|
||||
else {
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile instanceof TileSpectralBlock)
|
||||
((TileSpectralBlock) tile).resetDuration(refresh);
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.api.teleport.TeleportQueue;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.ritual.portal.Teleports;
|
||||
import WayofTime.bloodmagic.tile.TileTeleposer;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -16,32 +20,24 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.teleport.TeleportQueue;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.ritual.portal.Teleports;
|
||||
import WayofTime.bloodmagic.tile.TileTeleposer;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ItemSigilTeleposition extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilTeleposition()
|
||||
{
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilTeleposition extends ItemSigilBase {
|
||||
public ItemSigilTeleposition() {
|
||||
super("teleposition");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (tag != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD))
|
||||
{
|
||||
if (tag != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD)) {
|
||||
tooltip.add(" ");
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.coords", getValue(tag, Constants.NBT.X_COORD), getValue(tag, Constants.NBT.Y_COORD), getValue(tag, Constants.NBT.Z_COORD)));
|
||||
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.telepositionFocus.dimension", getValue(tag, Constants.NBT.DIMENSION_ID)));
|
||||
|
@ -49,22 +45,18 @@ public class ItemSigilTeleposition extends ItemSigilBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
if (!world.isRemote && NBTHelper.checkNBT(stack) != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD))
|
||||
{
|
||||
if (!world.isRemote && NBTHelper.checkNBT(stack) != null && stack.getTagCompound().hasKey(Constants.NBT.DIMENSION_ID) && stack.getTagCompound().hasKey(Constants.NBT.X_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Y_COORD) && stack.getTagCompound().hasKey(Constants.NBT.Z_COORD)) {
|
||||
BlockPos blockPos = new BlockPos(getValue(stack.getTagCompound(), Constants.NBT.X_COORD), getValue(stack.getTagCompound(), Constants.NBT.Y_COORD), getValue(stack.getTagCompound(), Constants.NBT.Z_COORD)).up();
|
||||
if (world.provider.getDimension() == getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID))
|
||||
{
|
||||
if (world.provider.getDimension() == getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID)) {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportSameDim(blockPos, player, getOwnerUUID(stack), true));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
TeleportQueue.getInstance().addITeleport(new Teleports.TeleportToDim(blockPos, player, getOwnerUUID(stack), world, getValue(stack.getTagCompound(), Constants.NBT.DIMENSION_ID), true));
|
||||
}
|
||||
}
|
||||
|
@ -72,18 +64,15 @@ public class ItemSigilTeleposition extends ItemSigilBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return EnumActionResult.FAIL;
|
||||
|
||||
if (!world.isRemote && player.isSneaking() && NBTHelper.checkNBT(stack) != null)
|
||||
{
|
||||
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileTeleposer)
|
||||
{
|
||||
if (!world.isRemote && player.isSneaking() && NBTHelper.checkNBT(stack) != null) {
|
||||
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileTeleposer) {
|
||||
stack.getTagCompound().setInteger(Constants.NBT.DIMENSION_ID, world.provider.getDimension());
|
||||
stack.getTagCompound().setInteger(Constants.NBT.X_COORD, pos.getX());
|
||||
stack.getTagCompound().setInteger(Constants.NBT.Y_COORD, pos.getY());
|
||||
|
@ -95,8 +84,7 @@ public class ItemSigilTeleposition extends ItemSigilBase
|
|||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
public int getValue(NBTTagCompound tag, String key)
|
||||
{
|
||||
public int getValue(NBTTagCompound tag, String key) {
|
||||
return tag.getInteger(key);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +1,30 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.impl.ItemSigilToggleable;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.base.Strings;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMeshProvider
|
||||
{
|
||||
public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMeshProvider {
|
||||
protected final String tooltipBase;
|
||||
private final String name;
|
||||
|
||||
public ItemSigilToggleableBase(String name, int lpUsed)
|
||||
{
|
||||
public ItemSigilToggleableBase(String name, int lpUsed) {
|
||||
super(lpUsed);
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".sigil." + name);
|
||||
|
@ -41,8 +36,7 @@ public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMes
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
@ -54,21 +48,18 @@ public class ItemSigilToggleableBase extends ItemSigilToggleable implements IMes
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionActivatable("ItemSigil" + WordUtils.capitalize(name));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add("active=false");
|
||||
ret.add("active=true");
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package WayofTime.bloodmagic.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||
import WayofTime.bloodmagic.api_impl.BloodMagicAPI;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -12,36 +14,33 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.api.BlockStack;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
|
||||
public class ItemSigilTransposition extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilTransposition()
|
||||
{
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSigilTransposition extends ItemSigilBase {
|
||||
public ItemSigilTransposition() {
|
||||
super("transposition", 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META))
|
||||
{
|
||||
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META)) {
|
||||
tooltip.add(" ");
|
||||
BlockStack blockStack = new BlockStack(Block.getBlockFromName(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME)), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META));
|
||||
tooltip.add(blockStack.getItemStack().getDisplayName());
|
||||
|
@ -49,13 +48,11 @@ public class ItemSigilTransposition extends ItemSigilBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(ItemStack stack)
|
||||
{
|
||||
public String getItemStackDisplayName(ItemStack stack) {
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META))
|
||||
{
|
||||
if (tag.hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && tag.hasKey(Constants.NBT.CONTAINED_BLOCK_META)) {
|
||||
BlockStack blockStack = new BlockStack(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString(Constants.NBT.CONTAINED_BLOCK_NAME))), tag.getByte(Constants.NBT.CONTAINED_BLOCK_META));
|
||||
if (blockStack.getItemStack() != null && blockStack.getItemStack().getItem() != null) //TODO: Figure out why it's a null item. This is a patchwork solution.
|
||||
{
|
||||
|
@ -67,8 +64,7 @@ public class ItemSigilTransposition extends ItemSigilBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
|
@ -78,28 +74,23 @@ public class ItemSigilTransposition extends ItemSigilBase
|
|||
stack = NBTHelper.checkNBT(stack);
|
||||
|
||||
IBlockState state = world.getBlockState(blockPos);
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
if (BloodMagicAPI.INSTANCE.getBlacklist().getTransposition().contains(state))
|
||||
return EnumActionResult.FAIL;
|
||||
|
||||
if (player.isSneaking() && (!stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) || !stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META)))
|
||||
{
|
||||
if (state.getPlayerRelativeBlockHardness(player, world, blockPos) >= 0 && state.getBlockHardness(world, blockPos) >= 0)
|
||||
{
|
||||
if (player.isSneaking() && (!stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) || !stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META))) {
|
||||
if (state.getPlayerRelativeBlockHardness(player, world, blockPos) >= 0 && state.getBlockHardness(world, blockPos) >= 0) {
|
||||
int cost = getLpUsed();
|
||||
|
||||
NBTTagCompound tileNBTTag = new NBTTagCompound();
|
||||
String blockName = state.getBlock().getRegistryName().toString();
|
||||
byte metadata = (byte) state.getBlock().getMetaFromState(state);
|
||||
|
||||
if (world.getTileEntity(blockPos) != null)
|
||||
{
|
||||
if (world.getTileEntity(blockPos) != null) {
|
||||
cost *= 5;
|
||||
world.getTileEntity(blockPos).writeToNBT(tileNBTTag);
|
||||
|
||||
if (world.getTileEntity(blockPos) instanceof TileEntityMobSpawner)
|
||||
{
|
||||
if (world.getTileEntity(blockPos) instanceof TileEntityMobSpawner) {
|
||||
cost *= 6;
|
||||
}
|
||||
}
|
||||
|
@ -115,26 +106,21 @@ public class ItemSigilTransposition extends ItemSigilBase
|
|||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
} else if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META))
|
||||
{
|
||||
} else if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_NAME) && stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_BLOCK_META)) {
|
||||
IBlockState iblockstate = world.getBlockState(blockPos);
|
||||
Block block = iblockstate.getBlock();
|
||||
BlockStack blockToPlace = new BlockStack(Block.getBlockFromName(stack.getTagCompound().getString(Constants.NBT.CONTAINED_BLOCK_NAME)), stack.getTagCompound().getByte(Constants.NBT.CONTAINED_BLOCK_META));
|
||||
|
||||
if (!block.isReplaceable(world, blockPos))
|
||||
{
|
||||
if (!block.isReplaceable(world, blockPos)) {
|
||||
blockPos = blockPos.offset(side);
|
||||
}
|
||||
|
||||
if (!stack.isEmpty() && player.canPlayerEdit(blockPos, side, stack) && world.mayPlace(blockToPlace.getBlock(), blockPos, false, side, player))
|
||||
{
|
||||
if (world.setBlockState(blockPos, blockToPlace.getState(), 3))
|
||||
{
|
||||
if (!stack.isEmpty() && player.canPlayerEdit(blockPos, side, stack) && world.mayPlace(blockToPlace.getBlock(), blockPos, false, side, player)) {
|
||||
if (world.setBlockState(blockPos, blockToPlace.getState(), 3)) {
|
||||
blockToPlace.getBlock().onBlockPlacedBy(world, blockPos, blockToPlace.getState(), player, blockToPlace.getItemStack());
|
||||
// world.playSound((double) ((float) blockPos.getX() + 0.5F), (double) ((float) blockPos.getY() + 0.5F), (double) ((float) blockPos.getZ() + 0.5F), blockToPlace.getBlock().getStepSound().getPlaceSound(), (blockToPlace.getBlock().getStepSound().getVolume() + 1.0F) / 2.0F, blockToPlace.getBlock().getStepSound().getPitch() * 0.8F);
|
||||
|
||||
if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_TILE_ENTITY) && blockToPlace.getBlock().hasTileEntity(blockToPlace.getState()))
|
||||
{
|
||||
if (stack.getTagCompound().hasKey(Constants.NBT.CONTAINED_TILE_ENTITY) && blockToPlace.getBlock().hasTileEntity(blockToPlace.getState())) {
|
||||
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(Constants.NBT.CONTAINED_TILE_ENTITY);
|
||||
tag.setInteger("x", blockPos.getX());
|
||||
tag.setInteger("y", blockPos.getY());
|
||||
|
|
|
@ -19,59 +19,48 @@ import net.minecraftforge.fluids.IFluidBlock;
|
|||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
public class ItemSigilVoid extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilVoid()
|
||||
{
|
||||
public class ItemSigilVoid extends ItemSigilBase {
|
||||
public ItemSigilVoid() {
|
||||
super("void", 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
if (!world.isRemote && !isUnusable(stack)) {
|
||||
RayTraceResult rayTrace = this.rayTrace(world, player, true);
|
||||
|
||||
if (rayTrace != null)
|
||||
{
|
||||
if (rayTrace != null) {
|
||||
ActionResult<ItemStack> ret = ForgeEventFactory.onBucketUse(player, world, stack, rayTrace);
|
||||
if (ret != null)
|
||||
return ret;
|
||||
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
BlockPos blockpos = rayTrace.getBlockPos();
|
||||
|
||||
if (!world.isBlockModifiable(player, blockpos))
|
||||
{
|
||||
if (!world.isBlockModifiable(player, blockpos)) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack))
|
||||
{
|
||||
if (!player.canPlayerEdit(blockpos.offset(rayTrace.sideHit), rayTrace.sideHit, stack)) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
if (!player.canPlayerEdit(blockpos, rayTrace.sideHit, stack))
|
||||
{
|
||||
if (!player.canPlayerEdit(blockpos, rayTrace.sideHit, stack)) {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
|
||||
{
|
||||
if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) {
|
||||
world.setBlockToAir(blockpos);
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
|
@ -83,30 +72,25 @@ public class ItemSigilVoid extends ItemSigilBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return EnumActionResult.FAIL;
|
||||
|
||||
if (world.isRemote || player.isSneaking() || isUnusable(stack))
|
||||
{
|
||||
if (world.isRemote || player.isSneaking() || isUnusable(stack)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (!world.canMineBlockBody(player, blockPos))
|
||||
{
|
||||
if (!world.canMineBlockBody(player, blockPos)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side))
|
||||
{
|
||||
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
|
||||
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
|
||||
FluidStack amount = handler.drain(1000, false);
|
||||
|
||||
if (amount != null && amount.amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()))
|
||||
{
|
||||
if (amount != null && amount.amount > 0 && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) {
|
||||
handler.drain(1000, true);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
@ -116,13 +100,11 @@ public class ItemSigilVoid extends ItemSigilBase
|
|||
|
||||
BlockPos newPos = blockPos.offset(side);
|
||||
|
||||
if (!player.canPlayerEdit(newPos, side, stack))
|
||||
{
|
||||
if (!player.canPlayerEdit(newPos, side, stack)) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed()))
|
||||
{
|
||||
if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && NetworkHelper.getSoulNetwork(getOwnerUUID(stack)).syphonAndDamage(player, getLpUsed())) {
|
||||
world.setBlockToAir(newPos);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
|
|
@ -10,12 +10,7 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -24,34 +19,28 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
public class ItemSigilWater extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilWater()
|
||||
{
|
||||
public class ItemSigilWater extends ItemSigilBase {
|
||||
public ItemSigilWater() {
|
||||
super("water", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
if (!world.isRemote && !isUnusable(stack)) {
|
||||
RayTraceResult rayTrace = this.rayTrace(world, player, false);
|
||||
|
||||
if (rayTrace != null)
|
||||
{
|
||||
if (rayTrace != null) {
|
||||
ActionResult<ItemStack> ret = net.minecraftforge.event.ForgeEventFactory.onBucketUse(player, world, stack, rayTrace);
|
||||
if (ret != null)
|
||||
return ret;
|
||||
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
if (rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
|
||||
BlockPos blockpos = rayTrace.getBlockPos();
|
||||
|
||||
if (!world.isBlockModifiable(player, blockpos))
|
||||
|
@ -75,8 +64,7 @@ public class ItemSigilWater extends ItemSigilBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (world.isRemote || player.isSneaking() || isUnusable(stack))
|
||||
return EnumActionResult.FAIL;
|
||||
|
@ -85,14 +73,12 @@ public class ItemSigilWater extends ItemSigilBase
|
|||
return EnumActionResult.FAIL;
|
||||
|
||||
TileEntity tile = world.getTileEntity(blockPos);
|
||||
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side))
|
||||
{
|
||||
if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
|
||||
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
|
||||
FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000);
|
||||
int amount = handler.fill(fluid, false);
|
||||
|
||||
if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
|
||||
{
|
||||
if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) {
|
||||
handler.fill(fluid, true);
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
@ -100,8 +86,7 @@ public class ItemSigilWater extends ItemSigilBase
|
|||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed()))
|
||||
{
|
||||
if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) {
|
||||
world.setBlockState(blockPos, Blocks.CAULDRON.getDefaultState().withProperty(BlockCauldron.LEVEL, 3));
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
@ -109,8 +94,7 @@ public class ItemSigilWater extends ItemSigilBase
|
|||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
public boolean canPlaceWater(World world, BlockPos blockPos)
|
||||
{
|
||||
public boolean canPlaceWater(World world, BlockPos blockPos) {
|
||||
if (!world.isAirBlock(blockPos) && world.getBlockState(blockPos).getBlock().getMaterial(world.getBlockState(blockPos)).isSolid())
|
||||
return false;
|
||||
else if ((world.getBlockState(blockPos).getBlock() == Blocks.WATER || world.getBlockState(blockPos).getBlock() == Blocks.FLOWING_WATER) && world.getBlockState(blockPos).getBlock().getMetaFromState(world.getBlockState(blockPos)) == 0)
|
||||
|
@ -119,19 +103,15 @@ public class ItemSigilWater extends ItemSigilBase
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean tryPlaceWater(World worldIn, BlockPos pos)
|
||||
{
|
||||
public boolean tryPlaceWater(World worldIn, BlockPos pos) {
|
||||
|
||||
Material material = worldIn.getBlockState(pos).getBlock().getMaterial(worldIn.getBlockState(pos));
|
||||
boolean notSolid = !material.isSolid();
|
||||
|
||||
if (!worldIn.isAirBlock(pos) && !notSolid)
|
||||
{
|
||||
if (!worldIn.isAirBlock(pos) && !notSolid) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
if (worldIn.provider.doesWaterVaporize())
|
||||
{
|
||||
} else {
|
||||
if (worldIn.provider.doesWaterVaporize()) {
|
||||
int i = pos.getX();
|
||||
int j = pos.getY();
|
||||
int k = pos.getZ();
|
||||
|
@ -139,8 +119,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 && notSolid && !material.isLiquid())
|
||||
worldIn.destroyBlock(pos, true);
|
||||
|
||||
|
|
|
@ -7,16 +7,13 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemSigilWhirlwind extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilWhirlwind()
|
||||
{
|
||||
public class ItemSigilWhirlwind extends ItemSigilToggleableBase {
|
||||
public ItemSigilWhirlwind() {
|
||||
super("whirlwind", 250);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
public void onSigilUpdate(ItemStack stack, World world, EntityPlayer player, int itemSlot, boolean isSelected) {
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ import WayofTime.bloodmagic.client.IVariantProvider;
|
|||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
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;
|
||||
|
@ -17,19 +16,16 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvider
|
||||
{
|
||||
public static String[] names = { "base", "corrosive", "destructive", "vengeful", "steadfast" };
|
||||
public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvider {
|
||||
public static String[] names = {"base", "corrosive", "destructive", "vengeful", "steadfast"};
|
||||
|
||||
public ItemMonsterSoul()
|
||||
{
|
||||
public ItemMonsterSoul() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".monsterSoul.");
|
||||
|
@ -39,14 +35,12 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -56,8 +50,7 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
tooltip.add(TextHelper.localize("tooltip.bloodmagic.will", getWill(getType(stack), stack)));
|
||||
|
@ -66,16 +59,13 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getType(ItemStack stack)
|
||||
{
|
||||
public EnumDemonWillType getType(ItemStack stack) {
|
||||
return EnumDemonWillType.values()[stack.getItemDamage() % 5];
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWill(EnumDemonWillType type, ItemStack soulStack)
|
||||
{
|
||||
if (type != this.getType(soulStack))
|
||||
{
|
||||
public double getWill(EnumDemonWillType type, ItemStack soulStack) {
|
||||
if (type != this.getType(soulStack)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -87,8 +77,7 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setWill(EnumDemonWillType type, ItemStack soulStack, double souls)
|
||||
{
|
||||
public void setWill(EnumDemonWillType type, ItemStack soulStack, double souls) {
|
||||
NBTHelper.checkNBT(soulStack);
|
||||
|
||||
NBTTagCompound tag = soulStack.getTagCompound();
|
||||
|
@ -99,8 +88,7 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public double drainWill(EnumDemonWillType type, ItemStack soulStack, double drainAmount)
|
||||
{
|
||||
public double drainWill(EnumDemonWillType type, ItemStack soulStack, double drainAmount) {
|
||||
double souls = getWill(type, soulStack);
|
||||
|
||||
double soulsDrained = Math.min(drainAmount, souls);
|
||||
|
@ -110,19 +98,16 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack createWill(int meta, double number)
|
||||
{
|
||||
public ItemStack createWill(int meta, double number) {
|
||||
ItemStack soulStack = new ItemStack(this, 1, meta % 5);
|
||||
setWill(getType(soulStack), soulStack, number);
|
||||
return soulStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
for (int i = 0; i < names.length; i++)
|
||||
{
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
String name = names[i];
|
||||
ret.add(new ImmutablePair<Integer, String>(i, "type=" + name));
|
||||
}
|
||||
|
@ -130,20 +115,17 @@ public class ItemMonsterSoul extends Item implements IDemonWill, IVariantProvide
|
|||
}
|
||||
|
||||
@Override
|
||||
public double getWill(ItemStack willStack)
|
||||
{
|
||||
public double getWill(ItemStack willStack) {
|
||||
return this.getWill(EnumDemonWillType.DEFAULT, willStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWill(ItemStack willStack, double will)
|
||||
{
|
||||
public void setWill(ItemStack willStack, double will) {
|
||||
this.setWill(EnumDemonWillType.DEFAULT, willStack, will);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double drainWill(ItemStack willStack, double drainAmount)
|
||||
{
|
||||
public double drainWill(ItemStack willStack, double drainAmount) {
|
||||
return this.drainWill(EnumDemonWillType.DEFAULT, willStack, drainAmount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package WayofTime.bloodmagic.item.soul;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -11,15 +15,9 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.item.armour.ItemSentientArmour;
|
||||
|
||||
public class ItemSentientArmourGem extends Item
|
||||
{
|
||||
public ItemSentientArmourGem()
|
||||
{
|
||||
public class ItemSentientArmourGem extends Item {
|
||||
public ItemSentientArmourGem() {
|
||||
super();
|
||||
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
|
@ -27,29 +25,23 @@ public class ItemSentientArmourGem extends Item
|
|||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||
{
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack) {
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
boolean hasSentientArmour = false;
|
||||
NonNullList<ItemStack> armourInventory = player.inventory.armorInventory;
|
||||
for (ItemStack armourStack : armourInventory)
|
||||
{
|
||||
if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour)
|
||||
{
|
||||
for (ItemStack armourStack : armourInventory) {
|
||||
if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour) {
|
||||
hasSentientArmour = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSentientArmour)
|
||||
{
|
||||
if (hasSentientArmour) {
|
||||
ItemSentientArmour.revertAllArmour(player);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player);
|
||||
double will = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
|
||||
|
@ -61,20 +53,16 @@ public class ItemSentientArmourGem extends Item
|
|||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining)
|
||||
{
|
||||
public ModelResourceLocation getModel(ItemStack stack, EntityPlayer player, int useRemaining) {
|
||||
boolean hasSentientArmour = false;
|
||||
NonNullList<ItemStack> armourInventory = player.inventory.armorInventory;
|
||||
for (ItemStack armourStack : armourInventory)
|
||||
{
|
||||
if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour)
|
||||
{
|
||||
for (ItemStack armourStack : armourInventory) {
|
||||
if (armourStack != null && armourStack.getItem() instanceof ItemSentientArmour) {
|
||||
hasSentientArmour = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasSentientArmour)
|
||||
{
|
||||
if (hasSentientArmour) {
|
||||
return new ModelResourceLocation("bloodmagic:ItemSentientArmourGem1", "inventory");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
package WayofTime.bloodmagic.item.soul;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
@ -28,55 +41,38 @@ import net.minecraft.world.EnumDifficulty;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool
|
||||
{
|
||||
public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000 };
|
||||
public static double[] defaultDamageAdded = new double[] { 1, 2, 3, 3.5, 4 };
|
||||
public static double[] destructiveDamageAdded = new double[] { 2, 3, 4, 5, 6 };
|
||||
public static double[] vengefulDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 };
|
||||
public static double[] steadfastDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 };
|
||||
public static double[] defaultDigSpeedAdded = new double[] { 1, 1.5, 2, 3, 4 };
|
||||
public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75 };
|
||||
public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13 };
|
||||
public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3 };
|
||||
public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool {
|
||||
public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000};
|
||||
public static double[] defaultDamageAdded = new double[]{1, 2, 3, 3.5, 4};
|
||||
public static double[] destructiveDamageAdded = new double[]{2, 3, 4, 5, 6};
|
||||
public static double[] vengefulDamageAdded = new double[]{0, 0.5, 1, 1.5, 2};
|
||||
public static double[] steadfastDamageAdded = new double[]{0, 0.5, 1, 1.5, 2};
|
||||
public static double[] defaultDigSpeedAdded = new double[]{1, 1.5, 2, 3, 4};
|
||||
public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75};
|
||||
public static double[] soulDrop = new double[]{2, 4, 7, 10, 13};
|
||||
public static double[] staticDrop = new double[]{1, 1, 2, 3, 3};
|
||||
|
||||
public static double[] healthBonus = new double[] { 0, 0, 0, 0, 0 }; //TODO: Think of implementing this later
|
||||
public static double[] vengefulAttackSpeed = new double[] { -3, -2.8, -2.7, -2.6, -2.5 };
|
||||
public static double[] destructiveAttackSpeed = new double[] { -3.1, -3.1, -3.2, -3.3, -3.3 };
|
||||
public static double[] healthBonus = new double[]{0, 0, 0, 0, 0}; //TODO: Think of implementing this later
|
||||
public static double[] vengefulAttackSpeed = new double[]{-3, -2.8, -2.7, -2.6, -2.5};
|
||||
public static double[] destructiveAttackSpeed = new double[]{-3.1, -3.1, -3.2, -3.3, -3.3};
|
||||
|
||||
public static int[] absorptionTime = new int[] { 200, 300, 400, 500, 600 };
|
||||
public static int[] absorptionTime = new int[]{200, 300, 400, 500, 600};
|
||||
|
||||
public static double maxAbsorptionHearts = 10;
|
||||
|
||||
public static int[] poisonTime = new int[] { 25, 50, 60, 80, 100 };
|
||||
public static int[] poisonLevel = new int[] { 0, 0, 0, 1, 1 };
|
||||
public static int[] poisonTime = new int[]{25, 50, 60, 80, 100};
|
||||
public static int[] poisonLevel = new int[]{0, 0, 0, 1, 1};
|
||||
|
||||
public static double[] movementSpeed = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25 };
|
||||
public static double[] movementSpeed = new double[]{0.05, 0.1, 0.15, 0.2, 0.25};
|
||||
|
||||
public final double baseAttackDamage = 8;
|
||||
public final double baseAttackSpeed = -3;
|
||||
|
||||
public ItemSentientAxe()
|
||||
{
|
||||
public ItemSentientAxe() {
|
||||
super(Item.ToolMaterial.IRON);
|
||||
setMaxDamage(getMaxDamage() * 2);
|
||||
// super(ModItems.soulToolMaterial);
|
||||
|
@ -86,26 +82,21 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||
{
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state) {
|
||||
float value = super.getStrVsBlock(stack, state);
|
||||
if (value > 1)
|
||||
{
|
||||
if (value > 1) {
|
||||
return (float) (value + getDigSpeedOfSword(stack));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
|
||||
return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair);
|
||||
}
|
||||
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) {
|
||||
EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT);
|
||||
|
@ -124,106 +115,89 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
setDigSpeedOfSword(stack, level >= 0 ? getDigSpeed(type, level) : 0);
|
||||
}
|
||||
|
||||
public double getExtraDamage(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
if (willBracket < 0)
|
||||
{
|
||||
public double getExtraDamage(EnumDemonWillType type, int willBracket) {
|
||||
if (willBracket < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
case DEFAULT:
|
||||
return defaultDamageAdded[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveDamageAdded[willBracket];
|
||||
case VENGEFUL:
|
||||
return vengefulDamageAdded[willBracket];
|
||||
case STEADFAST:
|
||||
return steadfastDamageAdded[willBracket];
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
case DEFAULT:
|
||||
return defaultDamageAdded[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveDamageAdded[willBracket];
|
||||
case VENGEFUL:
|
||||
return vengefulDamageAdded[willBracket];
|
||||
case STEADFAST:
|
||||
return steadfastDamageAdded[willBracket];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getAttackSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return vengefulAttackSpeed[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveAttackSpeed[willBracket];
|
||||
default:
|
||||
return -2.9;
|
||||
public double getAttackSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return vengefulAttackSpeed[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveAttackSpeed[willBracket];
|
||||
default:
|
||||
return -2.9;
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthBonus(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
public double getHealthBonus(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getMovementSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return movementSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
public double getMovementSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return movementSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDigSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
public double getDigSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
// return movementSpeed[willBracket];
|
||||
default:
|
||||
return defaultDigSpeedAdded[willBracket];
|
||||
default:
|
||||
return defaultDigSpeedAdded[willBracket];
|
||||
}
|
||||
}
|
||||
|
||||
public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket]));
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
if (!target.isEntityAlive())
|
||||
{
|
||||
float absorption = attacker.getAbsorptionAmount();
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127));
|
||||
attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts));
|
||||
}
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker) {
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket]));
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
if (!target.isEntityAlive()) {
|
||||
float absorption = attacker.getAbsorptionAmount();
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127));
|
||||
attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts));
|
||||
}
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
if (super.hitEntity(stack, target, attacker))
|
||||
{
|
||||
if (attacker instanceof EntityPlayer)
|
||||
{
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
if (super.hitEntity(stack, target, attacker)) {
|
||||
if (attacker instanceof EntityPlayer) {
|
||||
EntityPlayer attackerPlayer = (EntityPlayer) attacker;
|
||||
this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer);
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
@ -233,11 +207,9 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
applyEffectToEntity(type, willBracket, target, attackerPlayer);
|
||||
|
||||
ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
|
||||
if (offStack.getItem() instanceof ISentientSwordEffectProvider)
|
||||
{
|
||||
if (offStack.getItem() instanceof ISentientSwordEffectProvider) {
|
||||
ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem();
|
||||
if (provider.providesEffectForWill(type))
|
||||
{
|
||||
if (provider.providesEffectForWill(type)) {
|
||||
provider.applyOnHitEffect(type, stack, offStack, attacker, target);
|
||||
}
|
||||
}
|
||||
|
@ -250,22 +222,19 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||
{
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type)
|
||||
{
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -274,26 +243,21 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
recalculatePowers(player.getHeldItem(hand), world, player);
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
private int getLevel(ItemStack stack, double soulsRemaining)
|
||||
{
|
||||
private int getLevel(ItemStack stack, double soulsRemaining) {
|
||||
int lvl = -1;
|
||||
for (int i = 0; i < soulBracket.length; i++)
|
||||
{
|
||||
if (soulsRemaining >= soulBracket[i])
|
||||
{
|
||||
for (int i = 0; i < soulBracket.length; i++) {
|
||||
if (soulsRemaining >= soulBracket[i]) {
|
||||
lvl = i;
|
||||
}
|
||||
}
|
||||
|
@ -303,8 +267,7 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
@ -313,21 +276,17 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
|
||||
recalculatePowers(stack, player.getEntityWorld(), player);
|
||||
|
||||
double drain = this.getDrainOfActivatedSword(stack);
|
||||
if (drain > 0)
|
||||
{
|
||||
if (drain > 0) {
|
||||
EnumDemonWillType type = getCurrentType(stack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
|
||||
if (drain > soulsRemaining)
|
||||
{
|
||||
if (drain > soulsRemaining) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
|
||||
}
|
||||
}
|
||||
|
@ -337,24 +296,20 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionMultiWill("ItemSentientAxe");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
ret.add("type=" + type.getName().toLowerCase());
|
||||
}
|
||||
|
||||
|
@ -362,12 +317,10 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting)
|
||||
{
|
||||
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) {
|
||||
List<ItemStack> soulList = new ArrayList<ItemStack>();
|
||||
|
||||
if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob))
|
||||
{
|
||||
if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) {
|
||||
return soulList;
|
||||
}
|
||||
|
||||
|
@ -377,10 +330,8 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
for (int i = 0; i <= looting; i++)
|
||||
{
|
||||
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4)
|
||||
{
|
||||
for (int i = 0; i <= looting; i++) {
|
||||
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) {
|
||||
ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
|
@ -391,11 +342,9 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
|
||||
//TODO: Change attack speed.
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
|
||||
if (slot == EntityEquipmentSlot.MAINHAND)
|
||||
{
|
||||
if (slot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0));
|
||||
|
@ -405,16 +354,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
return multimap;
|
||||
}
|
||||
|
||||
public double getDamageOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDamageOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE);
|
||||
}
|
||||
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage)
|
||||
{
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -422,16 +369,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage);
|
||||
}
|
||||
|
||||
public double getDrainOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDrainOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN);
|
||||
}
|
||||
|
||||
public void setDrainOfActivatedSword(ItemStack stack, double drain)
|
||||
{
|
||||
public void setDrainOfActivatedSword(ItemStack stack, double drain) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -439,16 +384,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain);
|
||||
}
|
||||
|
||||
public double getStaticDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getStaticDropOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP);
|
||||
}
|
||||
|
||||
public void setStaticDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
public void setStaticDropOfActivatedSword(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -456,16 +399,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop);
|
||||
}
|
||||
|
||||
public double getDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDropOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP);
|
||||
}
|
||||
|
||||
public void setDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
public void setDropOfActivatedSword(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -473,16 +414,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_DROP, drop);
|
||||
}
|
||||
|
||||
public double getHealthBonusOfSword(ItemStack stack)
|
||||
{
|
||||
public double getHealthBonusOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
|
||||
}
|
||||
|
||||
public void setHealthBonusOfSword(ItemStack stack, double hp)
|
||||
{
|
||||
public void setHealthBonusOfSword(ItemStack stack, double hp) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -490,16 +429,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
|
||||
}
|
||||
|
||||
public double getAttackSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getAttackSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED);
|
||||
}
|
||||
|
||||
public void setAttackSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setAttackSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -507,16 +444,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed);
|
||||
}
|
||||
|
||||
public double getSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED);
|
||||
}
|
||||
|
||||
public void setSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -524,16 +459,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_SPEED, speed);
|
||||
}
|
||||
|
||||
public double getDigSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getDigSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DIG_SPEED);
|
||||
}
|
||||
|
||||
public void setDigSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setDigSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -542,17 +475,14 @@ public class ItemSentientAxe extends ItemAxe implements IDemonWillWeapon, IMeshP
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player)
|
||||
{
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) {
|
||||
World world = player.getEntityWorld();
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
this.recalculatePowers(droppedStack, world, player);
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(droppedStack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
if (soulsRemaining < 1024)
|
||||
{
|
||||
if (soulsRemaining < 1024) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
package WayofTime.bloodmagic.item.soul;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -22,81 +32,59 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentientTool//, IMeshProvider
|
||||
{
|
||||
public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000 };
|
||||
public static double[] defaultDamageAdded = new double[] { 0.25, 0.5, 0.75, 1, 1.25 };
|
||||
public static float[] velocityAdded = new float[] { 0.25f, 0.5f, 0.75f, 1, 1.25f };
|
||||
public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75 }; //TODO
|
||||
public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13 };
|
||||
public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3 };
|
||||
public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000};
|
||||
public static double[] defaultDamageAdded = new double[]{0.25, 0.5, 0.75, 1, 1.25};
|
||||
public static float[] velocityAdded = new float[]{0.25f, 0.5f, 0.75f, 1, 1.25f};
|
||||
public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75}; //TODO
|
||||
public static double[] soulDrop = new double[]{2, 4, 7, 10, 13};
|
||||
public static double[] staticDrop = new double[]{1, 1, 2, 3, 3};
|
||||
|
||||
public ItemSentientBow()
|
||||
{
|
||||
public ItemSentientBow() {
|
||||
super();
|
||||
setUnlocalizedName(BloodMagic.MODID + ".sentientBow");
|
||||
setCreativeTab(BloodMagic.TAB_BM);
|
||||
this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter()
|
||||
{
|
||||
this.addPropertyOverride(new ResourceLocation("pull"), new IItemPropertyGetter() {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float apply(ItemStack stack, World world, EntityLivingBase entityIn)
|
||||
{
|
||||
if (entityIn == null)
|
||||
{
|
||||
public float apply(ItemStack stack, World world, EntityLivingBase entityIn) {
|
||||
if (entityIn == null) {
|
||||
return 0.0F;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
ItemStack itemstack = entityIn.getActiveItemStack();
|
||||
return !itemstack.isEmpty() && itemstack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW ? (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F;
|
||||
}
|
||||
}
|
||||
});
|
||||
this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter()
|
||||
{
|
||||
this.addPropertyOverride(new ResourceLocation("pulling"), new IItemPropertyGetter() {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float apply(ItemStack stack, World world, EntityLivingBase entityIn)
|
||||
{
|
||||
public float apply(ItemStack stack, World world, EntityLivingBase entityIn) {
|
||||
return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F : 0.0F;
|
||||
}
|
||||
});
|
||||
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter()
|
||||
{
|
||||
this.addPropertyOverride(new ResourceLocation("type"), new IItemPropertyGetter() {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float apply(ItemStack stack, World world, EntityLivingBase entityIn)
|
||||
{
|
||||
public float apply(ItemStack stack, World world, EntityLivingBase entityIn) {
|
||||
return ((ItemSentientBow) RegistrarBloodMagicItems.SENTIENT_BOW).getCurrentType(stack).ordinal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
|
||||
return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair);
|
||||
}
|
||||
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) {
|
||||
EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
recalculatePowers(stack, type, soulsRemaining);
|
||||
}
|
||||
|
||||
public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will)
|
||||
{
|
||||
public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will) {
|
||||
this.setCurrentType(stack, will > 0 ? type : EnumDemonWillType.DEFAULT);
|
||||
int level = getLevel(stack, will);
|
||||
//
|
||||
|
@ -117,13 +105,10 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
setDamageAdded(stack, level >= 0 ? getDamageModifier(type, level) : 0);
|
||||
}
|
||||
|
||||
private int getLevel(ItemStack stack, double soulsRemaining)
|
||||
{
|
||||
private int getLevel(ItemStack stack, double soulsRemaining) {
|
||||
int lvl = -1;
|
||||
for (int i = 0; i < soulBracket.length; i++)
|
||||
{
|
||||
if (soulsRemaining >= soulBracket[i])
|
||||
{
|
||||
for (int i = 0; i < soulBracket.length; i++) {
|
||||
if (soulsRemaining >= soulBracket[i]) {
|
||||
lvl = i;
|
||||
}
|
||||
}
|
||||
|
@ -132,49 +117,42 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||
{
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public double getDamageModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return 0;
|
||||
case DEFAULT:
|
||||
case CORROSIVE:
|
||||
case DESTRUCTIVE:
|
||||
case STEADFAST:
|
||||
return defaultDamageAdded[willBracket];
|
||||
public double getDamageModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return 0;
|
||||
case DEFAULT:
|
||||
case CORROSIVE:
|
||||
case DESTRUCTIVE:
|
||||
case STEADFAST:
|
||||
return defaultDamageAdded[willBracket];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float getVelocityModifier(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return velocityAdded[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
public float getVelocityModifier(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return velocityAdded[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void setDamageAdded(ItemStack stack, double damage)
|
||||
{
|
||||
public void setDamageAdded(ItemStack stack, double damage) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -182,8 +160,7 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
tag.setDouble("damage", damage);
|
||||
}
|
||||
|
||||
public double getDamageAdded(ItemStack stack)
|
||||
{
|
||||
public double getDamageAdded(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -191,8 +168,7 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
return tag.getDouble("damage");
|
||||
}
|
||||
|
||||
public void setVelocityOfArrow(ItemStack stack, float velocity)
|
||||
{
|
||||
public void setVelocityOfArrow(ItemStack stack, float velocity) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -200,22 +176,19 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
tag.setFloat("velocity", velocity);
|
||||
}
|
||||
|
||||
public float getVelocityOfArrow(ItemStack stack)
|
||||
{
|
||||
public float getVelocityOfArrow(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (tag.hasKey("velocity"))
|
||||
{
|
||||
if (tag.hasKey("velocity")) {
|
||||
return tag.getFloat("velocity");
|
||||
}
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type)
|
||||
{
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -223,16 +196,14 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
tag.setString(Constants.NBT.WILL_TYPE, type.toString());
|
||||
}
|
||||
|
||||
public double getDrainOfActivatedBow(ItemStack stack)
|
||||
{
|
||||
public double getDrainOfActivatedBow(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN);
|
||||
}
|
||||
|
||||
public void setDrainOfActivatedBow(ItemStack stack, double drain)
|
||||
{
|
||||
public void setDrainOfActivatedBow(ItemStack stack, double drain) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -240,16 +211,14 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain);
|
||||
}
|
||||
|
||||
public double getStaticDropOfActivatedBow(ItemStack stack)
|
||||
{
|
||||
public double getStaticDropOfActivatedBow(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP);
|
||||
}
|
||||
|
||||
public void setStaticDropOfActivatedBow(ItemStack stack, double drop)
|
||||
{
|
||||
public void setStaticDropOfActivatedBow(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -257,16 +226,14 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop);
|
||||
}
|
||||
|
||||
public double getDropOfActivatedBow(ItemStack stack)
|
||||
{
|
||||
public double getDropOfActivatedBow(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP);
|
||||
}
|
||||
|
||||
public void setDropOfActivatedBow(ItemStack stack, double drop)
|
||||
{
|
||||
public void setDropOfActivatedBow(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -275,15 +242,13 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
this.recalculatePowers(stack, world, player);
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
public EntityTippedArrow getArrowEntity(World world, ItemStack stack, EntityLivingBase target, EntityLivingBase user, float velocity)
|
||||
{
|
||||
public EntityTippedArrow getArrowEntity(World world, ItemStack stack, EntityLivingBase target, EntityLivingBase user, float velocity) {
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
double amount = user instanceof EntityPlayer ? (this.getDropOfActivatedBow(stack) * world.rand.nextDouble() + this.getStaticDropOfActivatedBow(stack)) : 0;
|
||||
|
@ -298,14 +263,12 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
|
||||
entityArrow.setThrowableHeading(d0, d1 + d3 * 0.05, d2, newArrowVelocity, 0);
|
||||
|
||||
if (newArrowVelocity == 0)
|
||||
{
|
||||
if (newArrowVelocity == 0) {
|
||||
world.playSound(null, user.getPosition(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.NEUTRAL, 0.4F, 1.0F);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (velocity == 1.0F)
|
||||
{
|
||||
if (velocity == 1.0F) {
|
||||
entityArrow.setIsCritical(true);
|
||||
}
|
||||
|
||||
|
@ -315,13 +278,11 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
|
||||
int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
if (k > 0) {
|
||||
entityArrow.setKnockbackStrength(k);
|
||||
}
|
||||
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0)
|
||||
{
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) {
|
||||
entityArrow.setFire(100);
|
||||
}
|
||||
|
||||
|
@ -331,10 +292,8 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft)
|
||||
{
|
||||
if (entityLiving instanceof EntityPlayer)
|
||||
{
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entityLiving, int timeLeft) {
|
||||
if (entityLiving instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entityLiving;
|
||||
boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantments.INFINITY, stack) > 0;
|
||||
ItemStack itemstack = this.getFiredArrow(player);
|
||||
|
@ -344,21 +303,17 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
if (i < 0)
|
||||
return;
|
||||
|
||||
if (itemstack != null || flag)
|
||||
{
|
||||
if (itemstack == null)
|
||||
{
|
||||
if (itemstack != null || flag) {
|
||||
if (itemstack == null) {
|
||||
itemstack = new ItemStack(Items.ARROW);
|
||||
}
|
||||
|
||||
float arrowVelocity = getArrowVelocity(i);
|
||||
|
||||
if ((double) arrowVelocity >= 0.1D)
|
||||
{
|
||||
if ((double) arrowVelocity >= 0.1D) {
|
||||
boolean flag1 = flag && itemstack.getItem() == Items.ARROW; //Forge: Fix consuming custom arrows.
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
this.recalculatePowers(stack, world, player);
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
|
@ -372,14 +327,12 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
EntitySentientArrow entityArrow = new EntitySentientArrow(world, entityLiving, type, amount);
|
||||
entityArrow.setAim(player, player.rotationPitch, player.rotationYaw, 0.0F, newArrowVelocity, 1.0F);
|
||||
|
||||
if (newArrowVelocity == 0)
|
||||
{
|
||||
if (newArrowVelocity == 0) {
|
||||
world.playSound(null, player.getPosition(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.NEUTRAL, 0.4F, 1.0F);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arrowVelocity == 1.0F)
|
||||
{
|
||||
if (arrowVelocity == 1.0F) {
|
||||
entityArrow.setIsCritical(true);
|
||||
}
|
||||
|
||||
|
@ -389,20 +342,17 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
|
||||
int k = EnchantmentHelper.getEnchantmentLevel(Enchantments.PUNCH, stack);
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
if (k > 0) {
|
||||
entityArrow.setKnockbackStrength(k);
|
||||
}
|
||||
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0)
|
||||
{
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.FLAME, stack) > 0) {
|
||||
entityArrow.setFire(100);
|
||||
}
|
||||
|
||||
stack.damageItem(1, player);
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
if (flag1) {
|
||||
entityArrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
|
||||
}
|
||||
|
||||
|
@ -411,12 +361,10 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
|
||||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + arrowVelocity * 0.5F);
|
||||
|
||||
if (!flag1)
|
||||
{
|
||||
if (!flag1) {
|
||||
itemstack.shrink(1);
|
||||
|
||||
if (itemstack.isEmpty())
|
||||
{
|
||||
if (itemstack.isEmpty()) {
|
||||
player.inventory.deleteStack(itemstack);
|
||||
}
|
||||
}
|
||||
|
@ -427,22 +375,16 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
}
|
||||
}
|
||||
|
||||
protected ItemStack getFiredArrow(EntityPlayer player)
|
||||
{
|
||||
if (this.isArrow(player.getHeldItem(EnumHand.OFF_HAND)))
|
||||
{
|
||||
protected ItemStack getFiredArrow(EntityPlayer player) {
|
||||
if (this.isArrow(player.getHeldItem(EnumHand.OFF_HAND))) {
|
||||
return player.getHeldItem(EnumHand.OFF_HAND);
|
||||
} else if (this.isArrow(player.getHeldItem(EnumHand.MAIN_HAND)))
|
||||
{
|
||||
} else if (this.isArrow(player.getHeldItem(EnumHand.MAIN_HAND))) {
|
||||
return player.getHeldItem(EnumHand.MAIN_HAND);
|
||||
} else
|
||||
{
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i)
|
||||
{
|
||||
} else {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); ++i) {
|
||||
ItemStack itemstack = player.inventory.getStackInSlot(i);
|
||||
|
||||
if (this.isArrow(itemstack))
|
||||
{
|
||||
if (this.isArrow(itemstack)) {
|
||||
return itemstack;
|
||||
}
|
||||
}
|
||||
|
@ -452,17 +394,14 @@ public class ItemSentientBow extends ItemBow implements IMultiWillTool, ISentien
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player)
|
||||
{
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) {
|
||||
World world = player.getEntityWorld();
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
this.recalculatePowers(droppedStack, world, player);
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(droppedStack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
if (soulsRemaining < 1024)
|
||||
{
|
||||
if (soulsRemaining < 1024) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
package WayofTime.bloodmagic.item.soul;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
@ -28,55 +41,38 @@ import net.minecraft.world.EnumDifficulty;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool
|
||||
{
|
||||
public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000 };
|
||||
public static double[] defaultDamageAdded = new double[] { 1, 2, 3, 3.5, 4 };
|
||||
public static double[] destructiveDamageAdded = new double[] { 2, 3, 4, 5, 6 };
|
||||
public static double[] vengefulDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 };
|
||||
public static double[] steadfastDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 };
|
||||
public static double[] defaultDigSpeedAdded = new double[] { 1, 1.5, 2, 3, 4 };
|
||||
public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75 };
|
||||
public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13 };
|
||||
public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3 };
|
||||
public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool {
|
||||
public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000};
|
||||
public static double[] defaultDamageAdded = new double[]{1, 2, 3, 3.5, 4};
|
||||
public static double[] destructiveDamageAdded = new double[]{2, 3, 4, 5, 6};
|
||||
public static double[] vengefulDamageAdded = new double[]{0, 0.5, 1, 1.5, 2};
|
||||
public static double[] steadfastDamageAdded = new double[]{0, 0.5, 1, 1.5, 2};
|
||||
public static double[] defaultDigSpeedAdded = new double[]{1, 1.5, 2, 3, 4};
|
||||
public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75};
|
||||
public static double[] soulDrop = new double[]{2, 4, 7, 10, 13};
|
||||
public static double[] staticDrop = new double[]{1, 1, 2, 3, 3};
|
||||
|
||||
public static double[] healthBonus = new double[] { 0, 0, 0, 0, 0 }; //TODO: Think of implementing this later
|
||||
public static double[] vengefulAttackSpeed = new double[] { -3, -2.8, -2.7, -2.6, -2.5 };
|
||||
public static double[] destructiveAttackSpeed = new double[] { -3.1, -3.1, -3.2, -3.3, -3.3 };
|
||||
public static double[] healthBonus = new double[]{0, 0, 0, 0, 0}; //TODO: Think of implementing this later
|
||||
public static double[] vengefulAttackSpeed = new double[]{-3, -2.8, -2.7, -2.6, -2.5};
|
||||
public static double[] destructiveAttackSpeed = new double[]{-3.1, -3.1, -3.2, -3.3, -3.3};
|
||||
|
||||
public static int[] absorptionTime = new int[] { 200, 300, 400, 500, 600 };
|
||||
public static int[] absorptionTime = new int[]{200, 300, 400, 500, 600};
|
||||
|
||||
public static double maxAbsorptionHearts = 10;
|
||||
|
||||
public static int[] poisonTime = new int[] { 25, 50, 60, 80, 100 };
|
||||
public static int[] poisonLevel = new int[] { 0, 0, 0, 1, 1 };
|
||||
public static int[] poisonTime = new int[]{25, 50, 60, 80, 100};
|
||||
public static int[] poisonLevel = new int[]{0, 0, 0, 1, 1};
|
||||
|
||||
public static double[] movementSpeed = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25 };
|
||||
public static double[] movementSpeed = new double[]{0.05, 0.1, 0.15, 0.2, 0.25};
|
||||
|
||||
public final double baseAttackDamage = 3;
|
||||
public final double baseAttackSpeed = -2.8;
|
||||
|
||||
public ItemSentientPickaxe()
|
||||
{
|
||||
public ItemSentientPickaxe() {
|
||||
super(Item.ToolMaterial.IRON);
|
||||
setMaxDamage(getMaxDamage() * 2);
|
||||
// super(ModItems.soulToolMaterial);
|
||||
|
@ -86,26 +82,21 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||
{
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state) {
|
||||
float value = super.getStrVsBlock(stack, state);
|
||||
if (value > 1)
|
||||
{
|
||||
if (value > 1) {
|
||||
return (float) (value + getDigSpeedOfSword(stack));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
|
||||
return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() ? true : super.getIsRepairable(toRepair, repair);
|
||||
}
|
||||
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) {
|
||||
EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT);
|
||||
|
@ -124,106 +115,89 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
setDigSpeedOfSword(stack, level >= 0 ? getDigSpeed(type, level) : 0);
|
||||
}
|
||||
|
||||
public double getExtraDamage(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
if (willBracket < 0)
|
||||
{
|
||||
public double getExtraDamage(EnumDemonWillType type, int willBracket) {
|
||||
if (willBracket < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
case DEFAULT:
|
||||
return defaultDamageAdded[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveDamageAdded[willBracket];
|
||||
case VENGEFUL:
|
||||
return vengefulDamageAdded[willBracket];
|
||||
case STEADFAST:
|
||||
return steadfastDamageAdded[willBracket];
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
case DEFAULT:
|
||||
return defaultDamageAdded[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveDamageAdded[willBracket];
|
||||
case VENGEFUL:
|
||||
return vengefulDamageAdded[willBracket];
|
||||
case STEADFAST:
|
||||
return steadfastDamageAdded[willBracket];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getAttackSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return vengefulAttackSpeed[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveAttackSpeed[willBracket];
|
||||
default:
|
||||
return -2.9;
|
||||
public double getAttackSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return vengefulAttackSpeed[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveAttackSpeed[willBracket];
|
||||
default:
|
||||
return -2.9;
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthBonus(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
public double getHealthBonus(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getMovementSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return movementSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
public double getMovementSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return movementSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDigSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
public double getDigSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
// return movementSpeed[willBracket];
|
||||
default:
|
||||
return defaultDigSpeedAdded[willBracket];
|
||||
default:
|
||||
return defaultDigSpeedAdded[willBracket];
|
||||
}
|
||||
}
|
||||
|
||||
public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket]));
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
if (!target.isEntityAlive())
|
||||
{
|
||||
float absorption = attacker.getAbsorptionAmount();
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127));
|
||||
attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts));
|
||||
}
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker) {
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket]));
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
if (!target.isEntityAlive()) {
|
||||
float absorption = attacker.getAbsorptionAmount();
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127));
|
||||
attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts));
|
||||
}
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
if (super.hitEntity(stack, target, attacker))
|
||||
{
|
||||
if (attacker instanceof EntityPlayer)
|
||||
{
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
if (super.hitEntity(stack, target, attacker)) {
|
||||
if (attacker instanceof EntityPlayer) {
|
||||
EntityPlayer attackerPlayer = (EntityPlayer) attacker;
|
||||
this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer);
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
@ -233,11 +207,9 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
applyEffectToEntity(type, willBracket, target, attackerPlayer);
|
||||
|
||||
ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
|
||||
if (offStack.getItem() instanceof ISentientSwordEffectProvider)
|
||||
{
|
||||
if (offStack.getItem() instanceof ISentientSwordEffectProvider) {
|
||||
ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem();
|
||||
if (provider.providesEffectForWill(type))
|
||||
{
|
||||
if (provider.providesEffectForWill(type)) {
|
||||
provider.applyOnHitEffect(type, stack, offStack, attacker, target);
|
||||
}
|
||||
}
|
||||
|
@ -250,22 +222,19 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||
{
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type)
|
||||
{
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -274,25 +243,20 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
recalculatePowers(player.getHeldItem(hand), world, player);
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
private int getLevel(ItemStack stack, double soulsRemaining)
|
||||
{
|
||||
private int getLevel(ItemStack stack, double soulsRemaining) {
|
||||
int lvl = -1;
|
||||
for (int i = 0; i < soulBracket.length; i++)
|
||||
{
|
||||
if (soulsRemaining >= soulBracket[i])
|
||||
{
|
||||
for (int i = 0; i < soulBracket.length; i++) {
|
||||
if (soulsRemaining >= soulBracket[i]) {
|
||||
lvl = i;
|
||||
}
|
||||
}
|
||||
|
@ -302,8 +266,7 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
@ -312,21 +275,17 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
|
||||
recalculatePowers(stack, player.getEntityWorld(), player);
|
||||
|
||||
double drain = this.getDrainOfActivatedSword(stack);
|
||||
if (drain > 0)
|
||||
{
|
||||
if (drain > 0) {
|
||||
EnumDemonWillType type = getCurrentType(stack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
|
||||
if (drain > soulsRemaining)
|
||||
{
|
||||
if (drain > soulsRemaining) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
|
||||
}
|
||||
}
|
||||
|
@ -336,24 +295,20 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionMultiWill("ItemSentientPickaxe");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
ret.add("type=" + type.getName().toLowerCase());
|
||||
}
|
||||
|
||||
|
@ -361,12 +316,10 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting)
|
||||
{
|
||||
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) {
|
||||
List<ItemStack> soulList = new ArrayList<ItemStack>();
|
||||
|
||||
if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob))
|
||||
{
|
||||
if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) {
|
||||
return soulList;
|
||||
}
|
||||
|
||||
|
@ -376,10 +329,8 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
for (int i = 0; i <= looting; i++)
|
||||
{
|
||||
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4)
|
||||
{
|
||||
for (int i = 0; i <= looting; i++) {
|
||||
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) {
|
||||
ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
|
@ -390,11 +341,9 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
|
||||
//TODO: Change attack speed.
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
|
||||
if (slot == EntityEquipmentSlot.MAINHAND)
|
||||
{
|
||||
if (slot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0));
|
||||
|
@ -404,16 +353,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
return multimap;
|
||||
}
|
||||
|
||||
public double getDamageOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDamageOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE);
|
||||
}
|
||||
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage)
|
||||
{
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -421,16 +368,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage);
|
||||
}
|
||||
|
||||
public double getDrainOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDrainOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN);
|
||||
}
|
||||
|
||||
public void setDrainOfActivatedSword(ItemStack stack, double drain)
|
||||
{
|
||||
public void setDrainOfActivatedSword(ItemStack stack, double drain) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -438,16 +383,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain);
|
||||
}
|
||||
|
||||
public double getStaticDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getStaticDropOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP);
|
||||
}
|
||||
|
||||
public void setStaticDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
public void setStaticDropOfActivatedSword(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -455,16 +398,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop);
|
||||
}
|
||||
|
||||
public double getDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDropOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP);
|
||||
}
|
||||
|
||||
public void setDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
public void setDropOfActivatedSword(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -472,16 +413,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_DROP, drop);
|
||||
}
|
||||
|
||||
public double getHealthBonusOfSword(ItemStack stack)
|
||||
{
|
||||
public double getHealthBonusOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
|
||||
}
|
||||
|
||||
public void setHealthBonusOfSword(ItemStack stack, double hp)
|
||||
{
|
||||
public void setHealthBonusOfSword(ItemStack stack, double hp) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -489,16 +428,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
|
||||
}
|
||||
|
||||
public double getAttackSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getAttackSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED);
|
||||
}
|
||||
|
||||
public void setAttackSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setAttackSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -506,16 +443,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed);
|
||||
}
|
||||
|
||||
public double getSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED);
|
||||
}
|
||||
|
||||
public void setSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -523,16 +458,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_SPEED, speed);
|
||||
}
|
||||
|
||||
public double getDigSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getDigSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DIG_SPEED);
|
||||
}
|
||||
|
||||
public void setDigSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setDigSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -541,17 +474,14 @@ public class ItemSentientPickaxe extends ItemPickaxe implements IDemonWillWeapon
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player)
|
||||
{
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) {
|
||||
World world = player.getEntityWorld();
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
this.recalculatePowers(droppedStack, world, player);
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(droppedStack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
if (soulsRemaining < 1024)
|
||||
{
|
||||
if (soulsRemaining < 1024) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
package WayofTime.bloodmagic.item.soul;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
@ -28,55 +41,38 @@ import net.minecraft.world.EnumDifficulty;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool
|
||||
{
|
||||
public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000 };
|
||||
public static double[] defaultDamageAdded = new double[] { 1, 2, 3, 3.5, 4 };
|
||||
public static double[] destructiveDamageAdded = new double[] { 2, 3, 4, 5, 6 };
|
||||
public static double[] vengefulDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 };
|
||||
public static double[] steadfastDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2 };
|
||||
public static double[] defaultDigSpeedAdded = new double[] { 1, 1.5, 2, 3, 4 };
|
||||
public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75 };
|
||||
public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13 };
|
||||
public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3 };
|
||||
public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool {
|
||||
public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000};
|
||||
public static double[] defaultDamageAdded = new double[]{1, 2, 3, 3.5, 4};
|
||||
public static double[] destructiveDamageAdded = new double[]{2, 3, 4, 5, 6};
|
||||
public static double[] vengefulDamageAdded = new double[]{0, 0.5, 1, 1.5, 2};
|
||||
public static double[] steadfastDamageAdded = new double[]{0, 0.5, 1, 1.5, 2};
|
||||
public static double[] defaultDigSpeedAdded = new double[]{1, 1.5, 2, 3, 4};
|
||||
public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75};
|
||||
public static double[] soulDrop = new double[]{2, 4, 7, 10, 13};
|
||||
public static double[] staticDrop = new double[]{1, 1, 2, 3, 3};
|
||||
|
||||
public static double[] healthBonus = new double[] { 0, 0, 0, 0, 0 }; //TODO: Think of implementing this later
|
||||
public static double[] vengefulAttackSpeed = new double[] { -3, -2.8, -2.7, -2.6, -2.5 };
|
||||
public static double[] destructiveAttackSpeed = new double[] { -3.1, -3.1, -3.2, -3.3, -3.3 };
|
||||
public static double[] healthBonus = new double[]{0, 0, 0, 0, 0}; //TODO: Think of implementing this later
|
||||
public static double[] vengefulAttackSpeed = new double[]{-3, -2.8, -2.7, -2.6, -2.5};
|
||||
public static double[] destructiveAttackSpeed = new double[]{-3.1, -3.1, -3.2, -3.3, -3.3};
|
||||
|
||||
public static int[] absorptionTime = new int[] { 200, 300, 400, 500, 600 };
|
||||
public static int[] absorptionTime = new int[]{200, 300, 400, 500, 600};
|
||||
|
||||
public static double maxAbsorptionHearts = 10;
|
||||
|
||||
public static int[] poisonTime = new int[] { 25, 50, 60, 80, 100 };
|
||||
public static int[] poisonLevel = new int[] { 0, 0, 0, 1, 1 };
|
||||
public static int[] poisonTime = new int[]{25, 50, 60, 80, 100};
|
||||
public static int[] poisonLevel = new int[]{0, 0, 0, 1, 1};
|
||||
|
||||
public static double[] movementSpeed = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25 };
|
||||
public static double[] movementSpeed = new double[]{0.05, 0.1, 0.15, 0.2, 0.25};
|
||||
|
||||
public final double baseAttackDamage = 3;
|
||||
public final double baseAttackSpeed = -2.8;
|
||||
|
||||
public ItemSentientShovel()
|
||||
{
|
||||
public ItemSentientShovel() {
|
||||
super(Item.ToolMaterial.IRON);
|
||||
setMaxDamage(getMaxDamage() * 2);
|
||||
// super(ModItems.soulToolMaterial);
|
||||
|
@ -86,26 +82,21 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state)
|
||||
{
|
||||
public float getStrVsBlock(ItemStack stack, IBlockState state) {
|
||||
float value = super.getStrVsBlock(stack, state);
|
||||
if (value > 1)
|
||||
{
|
||||
if (value > 1) {
|
||||
return (float) (value + getDigSpeedOfSword(stack));
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
|
||||
return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair);
|
||||
}
|
||||
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) {
|
||||
EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
this.setCurrentType(stack, soulsRemaining > 0 ? type : EnumDemonWillType.DEFAULT);
|
||||
|
@ -124,106 +115,89 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
setDigSpeedOfSword(stack, level >= 0 ? getDigSpeed(type, level) : 0);
|
||||
}
|
||||
|
||||
public double getExtraDamage(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
if (willBracket < 0)
|
||||
{
|
||||
public double getExtraDamage(EnumDemonWillType type, int willBracket) {
|
||||
if (willBracket < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
case DEFAULT:
|
||||
return defaultDamageAdded[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveDamageAdded[willBracket];
|
||||
case VENGEFUL:
|
||||
return vengefulDamageAdded[willBracket];
|
||||
case STEADFAST:
|
||||
return steadfastDamageAdded[willBracket];
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
case DEFAULT:
|
||||
return defaultDamageAdded[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveDamageAdded[willBracket];
|
||||
case VENGEFUL:
|
||||
return vengefulDamageAdded[willBracket];
|
||||
case STEADFAST:
|
||||
return steadfastDamageAdded[willBracket];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getAttackSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return vengefulAttackSpeed[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveAttackSpeed[willBracket];
|
||||
default:
|
||||
return -2.9;
|
||||
public double getAttackSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return vengefulAttackSpeed[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveAttackSpeed[willBracket];
|
||||
default:
|
||||
return -2.9;
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthBonus(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
public double getHealthBonus(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getMovementSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return movementSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
public double getMovementSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return movementSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getDigSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
public double getDigSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
// return movementSpeed[willBracket];
|
||||
default:
|
||||
return defaultDigSpeedAdded[willBracket];
|
||||
default:
|
||||
return defaultDigSpeedAdded[willBracket];
|
||||
}
|
||||
}
|
||||
|
||||
public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket]));
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
if (!target.isEntityAlive())
|
||||
{
|
||||
float absorption = attacker.getAbsorptionAmount();
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127));
|
||||
attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts));
|
||||
}
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityPlayer attacker) {
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket]));
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
if (!target.isEntityAlive()) {
|
||||
float absorption = attacker.getAbsorptionAmount();
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127));
|
||||
attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts));
|
||||
}
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
if (super.hitEntity(stack, target, attacker))
|
||||
{
|
||||
if (attacker instanceof EntityPlayer)
|
||||
{
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
if (super.hitEntity(stack, target, attacker)) {
|
||||
if (attacker instanceof EntityPlayer) {
|
||||
EntityPlayer attackerPlayer = (EntityPlayer) attacker;
|
||||
this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer);
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
@ -233,11 +207,9 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
applyEffectToEntity(type, willBracket, target, attackerPlayer);
|
||||
|
||||
ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
|
||||
if (offStack.getItem() instanceof ISentientSwordEffectProvider)
|
||||
{
|
||||
if (offStack.getItem() instanceof ISentientSwordEffectProvider) {
|
||||
ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem();
|
||||
if (provider.providesEffectForWill(type))
|
||||
{
|
||||
if (provider.providesEffectForWill(type)) {
|
||||
provider.applyOnHitEffect(type, stack, offStack, attacker, target);
|
||||
}
|
||||
}
|
||||
|
@ -250,22 +222,19 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||
{
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type)
|
||||
{
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -274,26 +243,21 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
recalculatePowers(player.getHeldItem(hand), world, player);
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
private int getLevel(ItemStack stack, double soulsRemaining)
|
||||
{
|
||||
private int getLevel(ItemStack stack, double soulsRemaining) {
|
||||
int lvl = -1;
|
||||
for (int i = 0; i < soulBracket.length; i++)
|
||||
{
|
||||
if (soulsRemaining >= soulBracket[i])
|
||||
{
|
||||
for (int i = 0; i < soulBracket.length; i++) {
|
||||
if (soulsRemaining >= soulBracket[i]) {
|
||||
lvl = i;
|
||||
}
|
||||
}
|
||||
|
@ -303,8 +267,7 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
@ -313,21 +276,17 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
|
||||
recalculatePowers(stack, player.getEntityWorld(), player);
|
||||
|
||||
double drain = this.getDrainOfActivatedSword(stack);
|
||||
if (drain > 0)
|
||||
{
|
||||
if (drain > 0) {
|
||||
EnumDemonWillType type = getCurrentType(stack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
|
||||
if (drain > soulsRemaining)
|
||||
{
|
||||
if (drain > soulsRemaining) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
|
||||
}
|
||||
}
|
||||
|
@ -337,24 +296,20 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionMultiWill("ItemSentientShovel");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
ret.add("type=" + type.getName().toLowerCase());
|
||||
}
|
||||
|
||||
|
@ -362,12 +317,10 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting)
|
||||
{
|
||||
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) {
|
||||
List<ItemStack> soulList = new ArrayList<ItemStack>();
|
||||
|
||||
if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob))
|
||||
{
|
||||
if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) {
|
||||
return soulList;
|
||||
}
|
||||
|
||||
|
@ -377,10 +330,8 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
for (int i = 0; i <= looting; i++)
|
||||
{
|
||||
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4)
|
||||
{
|
||||
for (int i = 0; i <= looting; i++) {
|
||||
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) {
|
||||
ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
|
@ -391,11 +342,9 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
|
||||
//TODO: Change attack speed.
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
|
||||
if (slot == EntityEquipmentSlot.MAINHAND)
|
||||
{
|
||||
if (slot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0));
|
||||
|
@ -405,16 +354,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
return multimap;
|
||||
}
|
||||
|
||||
public double getDamageOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDamageOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE);
|
||||
}
|
||||
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage)
|
||||
{
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -422,16 +369,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage);
|
||||
}
|
||||
|
||||
public double getDrainOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDrainOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN);
|
||||
}
|
||||
|
||||
public void setDrainOfActivatedSword(ItemStack stack, double drain)
|
||||
{
|
||||
public void setDrainOfActivatedSword(ItemStack stack, double drain) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -439,16 +384,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain);
|
||||
}
|
||||
|
||||
public double getStaticDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getStaticDropOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP);
|
||||
}
|
||||
|
||||
public void setStaticDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
public void setStaticDropOfActivatedSword(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -456,16 +399,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop);
|
||||
}
|
||||
|
||||
public double getDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDropOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP);
|
||||
}
|
||||
|
||||
public void setDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
public void setDropOfActivatedSword(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -473,16 +414,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_DROP, drop);
|
||||
}
|
||||
|
||||
public double getHealthBonusOfSword(ItemStack stack)
|
||||
{
|
||||
public double getHealthBonusOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
|
||||
}
|
||||
|
||||
public void setHealthBonusOfSword(ItemStack stack, double hp)
|
||||
{
|
||||
public void setHealthBonusOfSword(ItemStack stack, double hp) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -490,16 +429,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
|
||||
}
|
||||
|
||||
public double getAttackSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getAttackSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED);
|
||||
}
|
||||
|
||||
public void setAttackSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setAttackSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -507,16 +444,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed);
|
||||
}
|
||||
|
||||
public double getSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED);
|
||||
}
|
||||
|
||||
public void setSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -524,16 +459,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_SPEED, speed);
|
||||
}
|
||||
|
||||
public double getDigSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getDigSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DIG_SPEED);
|
||||
}
|
||||
|
||||
public void setDigSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setDigSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -542,17 +475,14 @@ public class ItemSentientShovel extends ItemSpade implements IDemonWillWeapon, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player)
|
||||
{
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) {
|
||||
World world = player.getEntityWorld();
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
this.recalculatePowers(droppedStack, world, player);
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(droppedStack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
if (soulsRemaining < 1024)
|
||||
{
|
||||
if (soulsRemaining < 1024) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
package WayofTime.bloodmagic.item.soul;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -26,51 +39,34 @@ import net.minecraft.world.EnumDifficulty;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientSwordEffectProvider;
|
||||
import WayofTime.bloodmagic.api.iface.ISentientTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillWeapon;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionMultiWill;
|
||||
import WayofTime.bloodmagic.entity.mob.EntitySentientSpecter;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool
|
||||
{
|
||||
public static int[] soulBracket = new int[] { 16, 60, 200, 400, 1000, 2000, 4000 };
|
||||
public static double[] defaultDamageAdded = new double[] { 1, 1.5, 2, 2.5, 3, 3.5, 4 };
|
||||
public static double[] destructiveDamageAdded = new double[] { 1.5, 2.25, 3, 3.75, 4.5, 5.25, 6 };
|
||||
public static double[] vengefulDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2, 2.25, 2.5 };
|
||||
public static double[] steadfastDamageAdded = new double[] { 0, 0.5, 1, 1.5, 2, 2.25, 2.5 };
|
||||
public static double[] soulDrainPerSwing = new double[] { 0.05, 0.1, 0.2, 0.4, 0.75, 1, 1.25 };
|
||||
public static double[] soulDrop = new double[] { 2, 4, 7, 10, 13, 15, 18 };
|
||||
public static double[] staticDrop = new double[] { 1, 1, 2, 3, 3, 4, 4 };
|
||||
public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IMeshProvider, IMultiWillTool, ISentientTool {
|
||||
public static int[] soulBracket = new int[]{16, 60, 200, 400, 1000, 2000, 4000};
|
||||
public static double[] defaultDamageAdded = new double[]{1, 1.5, 2, 2.5, 3, 3.5, 4};
|
||||
public static double[] destructiveDamageAdded = new double[]{1.5, 2.25, 3, 3.75, 4.5, 5.25, 6};
|
||||
public static double[] vengefulDamageAdded = new double[]{0, 0.5, 1, 1.5, 2, 2.25, 2.5};
|
||||
public static double[] steadfastDamageAdded = new double[]{0, 0.5, 1, 1.5, 2, 2.25, 2.5};
|
||||
public static double[] soulDrainPerSwing = new double[]{0.05, 0.1, 0.2, 0.4, 0.75, 1, 1.25};
|
||||
public static double[] soulDrop = new double[]{2, 4, 7, 10, 13, 15, 18};
|
||||
public static double[] staticDrop = new double[]{1, 1, 2, 3, 3, 4, 4};
|
||||
|
||||
public static double[] healthBonus = new double[] { 0, 0, 0, 0, 0, 0, 0 }; //TODO: Think of implementing this later
|
||||
public static double[] vengefulAttackSpeed = new double[] { -2.1, -2, -1.8, -1.7, -1.6, -1.6, -1.5 };
|
||||
public static double[] destructiveAttackSpeed = new double[] { -2.6, -2.7, -2.8, -2.9, -3, -3, -3 };
|
||||
public static double[] healthBonus = new double[]{0, 0, 0, 0, 0, 0, 0}; //TODO: Think of implementing this later
|
||||
public static double[] vengefulAttackSpeed = new double[]{-2.1, -2, -1.8, -1.7, -1.6, -1.6, -1.5};
|
||||
public static double[] destructiveAttackSpeed = new double[]{-2.6, -2.7, -2.8, -2.9, -3, -3, -3};
|
||||
|
||||
public static int[] absorptionTime = new int[] { 200, 300, 400, 500, 600, 700, 800 };
|
||||
public static int[] absorptionTime = new int[]{200, 300, 400, 500, 600, 700, 800};
|
||||
|
||||
public static double maxAbsorptionHearts = 10;
|
||||
|
||||
public static int[] poisonTime = new int[] { 25, 50, 60, 80, 100, 120, 150 };
|
||||
public static int[] poisonLevel = new int[] { 0, 0, 0, 1, 1, 1, 1 };
|
||||
public static int[] poisonTime = new int[]{25, 50, 60, 80, 100, 120, 150};
|
||||
public static int[] poisonLevel = new int[]{0, 0, 0, 1, 1, 1, 1};
|
||||
|
||||
public static double[] movementSpeed = new double[] { 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4 };
|
||||
public static double[] movementSpeed = new double[]{0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4};
|
||||
|
||||
public ItemSentientSword()
|
||||
{
|
||||
public ItemSentientSword() {
|
||||
super(RegistrarBloodMagicItems.SOUL_TOOL_MATERIAL);
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".sentientSword");
|
||||
|
@ -78,20 +74,17 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) {
|
||||
return RegistrarBloodMagicItems.ITEM_DEMON_CRYSTAL == repair.getItem() || super.getIsRepairable(toRepair, repair);
|
||||
}
|
||||
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
public void recalculatePowers(ItemStack stack, World world, EntityPlayer player) {
|
||||
EnumDemonWillType type = PlayerDemonWillHandler.getLargestWillType(player);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
recalculatePowers(stack, type, soulsRemaining);
|
||||
}
|
||||
|
||||
public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will)
|
||||
{
|
||||
public void recalculatePowers(ItemStack stack, EnumDemonWillType type, double will) {
|
||||
this.setCurrentType(stack, will > 0 ? type : EnumDemonWillType.DEFAULT);
|
||||
int level = getLevel(stack, will);
|
||||
|
||||
|
@ -107,95 +100,80 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
setSpeedOfSword(stack, level >= 0 ? getMovementSpeed(type, level) : 0);
|
||||
}
|
||||
|
||||
public double getExtraDamage(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
if (willBracket < 0)
|
||||
{
|
||||
public double getExtraDamage(EnumDemonWillType type, int willBracket) {
|
||||
if (willBracket < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
case DEFAULT:
|
||||
return defaultDamageAdded[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveDamageAdded[willBracket];
|
||||
case VENGEFUL:
|
||||
return vengefulDamageAdded[willBracket];
|
||||
case STEADFAST:
|
||||
return steadfastDamageAdded[willBracket];
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
case DEFAULT:
|
||||
return defaultDamageAdded[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveDamageAdded[willBracket];
|
||||
case VENGEFUL:
|
||||
return vengefulDamageAdded[willBracket];
|
||||
case STEADFAST:
|
||||
return steadfastDamageAdded[willBracket];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double getAttackSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return vengefulAttackSpeed[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveAttackSpeed[willBracket];
|
||||
default:
|
||||
return -2.4;
|
||||
public double getAttackSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return vengefulAttackSpeed[willBracket];
|
||||
case DESTRUCTIVE:
|
||||
return destructiveAttackSpeed[willBracket];
|
||||
default:
|
||||
return -2.4;
|
||||
}
|
||||
}
|
||||
|
||||
public double getHealthBonus(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case STEADFAST:
|
||||
return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
public double getHealthBonus(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case STEADFAST:
|
||||
return healthBonus[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double getMovementSpeed(EnumDemonWillType type, int willBracket)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case VENGEFUL:
|
||||
return movementSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
public double getMovementSpeed(EnumDemonWillType type, int willBracket) {
|
||||
switch (type) {
|
||||
case VENGEFUL:
|
||||
return movementSpeed[willBracket];
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case CORROSIVE:
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket]));
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
if (!target.isEntityAlive())
|
||||
{
|
||||
float absorption = attacker.getAbsorptionAmount();
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127));
|
||||
attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts));
|
||||
}
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
public void applyEffectToEntity(EnumDemonWillType type, int willBracket, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
switch (type) {
|
||||
case CORROSIVE:
|
||||
target.addPotionEffect(new PotionEffect(MobEffects.WITHER, poisonTime[willBracket], poisonLevel[willBracket]));
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
case DESTRUCTIVE:
|
||||
break;
|
||||
case STEADFAST:
|
||||
if (!target.isEntityAlive()) {
|
||||
float absorption = attacker.getAbsorptionAmount();
|
||||
attacker.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, absorptionTime[willBracket], 127));
|
||||
attacker.setAbsorptionAmount((float) Math.min(absorption + target.getMaxHealth() * 0.05f, maxAbsorptionHearts));
|
||||
}
|
||||
break;
|
||||
case VENGEFUL:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
|
||||
{
|
||||
if (super.hitEntity(stack, target, attacker))
|
||||
{
|
||||
if (attacker instanceof EntityPlayer)
|
||||
{
|
||||
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) {
|
||||
if (super.hitEntity(stack, target, attacker)) {
|
||||
if (attacker instanceof EntityPlayer) {
|
||||
EntityPlayer attackerPlayer = (EntityPlayer) attacker;
|
||||
this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer);
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
@ -205,11 +183,9 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
applyEffectToEntity(type, willBracket, target, attackerPlayer);
|
||||
|
||||
ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
|
||||
if (offStack.getItem() instanceof ISentientSwordEffectProvider)
|
||||
{
|
||||
if (offStack.getItem() instanceof ISentientSwordEffectProvider) {
|
||||
ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem();
|
||||
if (provider.providesEffectForWill(type))
|
||||
{
|
||||
if (provider.providesEffectForWill(type)) {
|
||||
provider.applyOnHitEffect(type, stack, offStack, attacker, target);
|
||||
}
|
||||
}
|
||||
|
@ -222,22 +198,19 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack)
|
||||
{
|
||||
public EnumDemonWillType getCurrentType(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type)
|
||||
{
|
||||
public void setCurrentType(ItemStack stack, EnumDemonWillType type) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -246,25 +219,20 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
recalculatePowers(player.getHeldItem(hand), world, player);
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
return oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
private int getLevel(ItemStack stack, double soulsRemaining)
|
||||
{
|
||||
private int getLevel(ItemStack stack, double soulsRemaining) {
|
||||
int lvl = -1;
|
||||
for (int i = 0; i < soulBracket.length; i++)
|
||||
{
|
||||
if (soulsRemaining >= soulBracket[i])
|
||||
{
|
||||
for (int i = 0; i < soulBracket.length; i++) {
|
||||
if (soulsRemaining >= soulBracket[i]) {
|
||||
lvl = i;
|
||||
}
|
||||
}
|
||||
|
@ -274,8 +242,7 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
@ -284,21 +251,17 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity)
|
||||
{
|
||||
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
|
||||
recalculatePowers(stack, player.getEntityWorld(), player);
|
||||
|
||||
double drain = this.getDrainOfActivatedSword(stack);
|
||||
if (drain > 0)
|
||||
{
|
||||
if (drain > 0) {
|
||||
EnumDemonWillType type = getCurrentType(stack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
|
||||
if (drain > soulsRemaining)
|
||||
{
|
||||
if (drain > soulsRemaining) {
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
|
||||
}
|
||||
}
|
||||
|
@ -308,24 +271,20 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionMultiWill("ItemSentientSword");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
ret.add("type=" + type.getName().toLowerCase());
|
||||
}
|
||||
|
||||
|
@ -333,12 +292,10 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting)
|
||||
{
|
||||
public List<ItemStack> getRandomDemonWillDrop(EntityLivingBase killedEntity, EntityLivingBase attackingEntity, ItemStack stack, int looting) {
|
||||
List<ItemStack> soulList = new ArrayList<ItemStack>();
|
||||
|
||||
if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob))
|
||||
{
|
||||
if (killedEntity.getEntityWorld().getDifficulty() != EnumDifficulty.PEACEFUL && !(killedEntity instanceof IMob)) {
|
||||
return soulList;
|
||||
}
|
||||
|
||||
|
@ -348,10 +305,8 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
|
||||
for (int i = 0; i <= looting; i++)
|
||||
{
|
||||
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4)
|
||||
{
|
||||
for (int i = 0; i <= looting; i++) {
|
||||
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4) {
|
||||
ItemStack soulStack = soul.createWill(type.ordinal(), willModifier * (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble() + this.getStaticDropOfActivatedSword(stack)) * killedEntity.getMaxHealth() / 20d);
|
||||
soulList.add(soulStack);
|
||||
}
|
||||
|
@ -362,11 +317,9 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
|
||||
//TODO: Change attack speed.
|
||||
@Override
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
|
||||
Multimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
|
||||
if (slot == EntityEquipmentSlot.MAINHAND)
|
||||
{
|
||||
if (slot == EntityEquipmentSlot.MAINHAND) {
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), 0));
|
||||
multimap.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), 0));
|
||||
|
@ -376,16 +329,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
return multimap;
|
||||
}
|
||||
|
||||
public double getDamageOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDamageOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE);
|
||||
}
|
||||
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage)
|
||||
{
|
||||
public void setDamageOfActivatedSword(ItemStack stack, double damage) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -393,16 +344,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage);
|
||||
}
|
||||
|
||||
public double getDrainOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDrainOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN);
|
||||
}
|
||||
|
||||
public void setDrainOfActivatedSword(ItemStack stack, double drain)
|
||||
{
|
||||
public void setDrainOfActivatedSword(ItemStack stack, double drain) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -410,16 +359,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain);
|
||||
}
|
||||
|
||||
public double getStaticDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getStaticDropOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP);
|
||||
}
|
||||
|
||||
public void setStaticDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
public void setStaticDropOfActivatedSword(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -427,16 +374,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop);
|
||||
}
|
||||
|
||||
public double getDropOfActivatedSword(ItemStack stack)
|
||||
{
|
||||
public double getDropOfActivatedSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP);
|
||||
}
|
||||
|
||||
public void setDropOfActivatedSword(ItemStack stack, double drop)
|
||||
{
|
||||
public void setDropOfActivatedSword(ItemStack stack, double drop) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -444,16 +389,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_DROP, drop);
|
||||
}
|
||||
|
||||
public double getHealthBonusOfSword(ItemStack stack)
|
||||
{
|
||||
public double getHealthBonusOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
|
||||
}
|
||||
|
||||
public void setHealthBonusOfSword(ItemStack stack, double hp)
|
||||
{
|
||||
public void setHealthBonusOfSword(ItemStack stack, double hp) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -461,16 +404,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
|
||||
}
|
||||
|
||||
public double getAttackSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getAttackSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED);
|
||||
}
|
||||
|
||||
public void setAttackSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setAttackSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -478,16 +419,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
tag.setDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed);
|
||||
}
|
||||
|
||||
public double getSpeedOfSword(ItemStack stack)
|
||||
{
|
||||
public double getSpeedOfSword(ItemStack stack) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED);
|
||||
}
|
||||
|
||||
public void setSpeedOfSword(ItemStack stack, double speed)
|
||||
{
|
||||
public void setSpeedOfSword(ItemStack stack, double speed) {
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
NBTTagCompound tag = stack.getTagCompound();
|
||||
|
@ -496,17 +435,14 @@ public class ItemSentientSword extends ItemSword implements IDemonWillWeapon, IM
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player)
|
||||
{
|
||||
public boolean spawnSentientEntityOnDrop(ItemStack droppedStack, EntityPlayer player) {
|
||||
World world = player.getEntityWorld();
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!world.isRemote) {
|
||||
this.recalculatePowers(droppedStack, world, player);
|
||||
|
||||
EnumDemonWillType type = this.getCurrentType(droppedStack);
|
||||
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
|
||||
if (soulsRemaining < 1024)
|
||||
{
|
||||
if (soulsRemaining < 1024) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
package WayofTime.bloodmagic.item.soul;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillGem;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionWillGem;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -18,24 +23,16 @@ import net.minecraft.util.math.MathHelper;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.iface.IMultiWillTool;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWill;
|
||||
import WayofTime.bloodmagic.api.soul.IDemonWillGem;
|
||||
import WayofTime.bloodmagic.api.soul.PlayerDemonWillHandler;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.client.IMeshProvider;
|
||||
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionWillGem;
|
||||
import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, IMultiWillTool
|
||||
{
|
||||
public static String[] names = { "petty", "lesser", "common", "greater", "grand" };
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public ItemSoulGem()
|
||||
{
|
||||
public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, IMultiWillTool {
|
||||
public static String[] names = {"petty", "lesser", "common", "greater", "grand"};
|
||||
|
||||
public ItemSoulGem() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".soulGem.");
|
||||
|
@ -45,14 +42,12 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10);
|
||||
|
@ -65,24 +60,20 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public ItemMeshDefinition getMeshDefinition()
|
||||
{
|
||||
public ItemMeshDefinition getMeshDefinition() {
|
||||
return new CustomMeshDefinitionWillGem("ItemSoulGem");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ResourceLocation getCustomLocation()
|
||||
{
|
||||
public ResourceLocation getCustomLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVariants()
|
||||
{
|
||||
public List<String> getVariants() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
ret.add("type=petty_" + type.getName().toLowerCase());
|
||||
ret.add("type=lesser_" + type.getName().toLowerCase());
|
||||
ret.add("type=common_" + type.getName().toLowerCase());
|
||||
|
@ -94,21 +85,17 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
for (int i = 0; i < names.length; i++)
|
||||
{
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
ItemStack emptyStack = new ItemStack(this, 1, i);
|
||||
|
||||
list.add(emptyStack);
|
||||
}
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values())
|
||||
{
|
||||
for (int i = 0; i < names.length; i++)
|
||||
{
|
||||
for (EnumDemonWillType type : EnumDemonWillType.values()) {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
ItemStack fullStack = new ItemStack(this, 1, i);
|
||||
setWill(type, fullStack, getMaxWill(EnumDemonWillType.DEFAULT, fullStack));
|
||||
list.add(fullStack);
|
||||
|
@ -118,8 +105,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
|
||||
|
@ -132,57 +118,47 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack)
|
||||
{
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
double maxWill = getMaxWill(type, stack);
|
||||
if (maxWill <= 0)
|
||||
{
|
||||
if (maxWill <= 0) {
|
||||
return 1;
|
||||
}
|
||||
return 1.0 - (getWill(type, stack) / maxWill);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack)
|
||||
{
|
||||
public int getRGBDurabilityForDisplay(ItemStack stack) {
|
||||
EnumDemonWillType type = this.getCurrentType(stack);
|
||||
double maxWill = getMaxWill(type, stack);
|
||||
if (maxWill <= 0)
|
||||
{
|
||||
if (maxWill <= 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float)(getWill(type, stack)) / (float) maxWill) / 3.0F, 1.0F, 1.0F);
|
||||
return MathHelper.hsvToRGB(Math.max(0.0F, (float) (getWill(type, stack)) / (float) maxWill) / 3.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack fillDemonWillGem(ItemStack soulGemStack, ItemStack soulStack)
|
||||
{
|
||||
if (soulStack != null && soulStack.getItem() instanceof IDemonWill)
|
||||
{
|
||||
public ItemStack fillDemonWillGem(ItemStack soulGemStack, ItemStack soulStack) {
|
||||
if (soulStack != null && soulStack.getItem() instanceof IDemonWill) {
|
||||
EnumDemonWillType thisType = this.getCurrentType(soulGemStack);
|
||||
if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack))
|
||||
{
|
||||
if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack)) {
|
||||
return soulStack;
|
||||
}
|
||||
IDemonWill soul = (IDemonWill) soulStack.getItem();
|
||||
double soulsLeft = getWill(thisType, soulGemStack);
|
||||
|
||||
if (soulsLeft < getMaxWill(thisType, soulGemStack))
|
||||
{
|
||||
if (soulsLeft < getMaxWill(thisType, soulGemStack)) {
|
||||
double newSoulsLeft = Math.min(soulsLeft + soul.getWill(thisType, soulStack), getMaxWill(thisType, soulGemStack));
|
||||
soul.drainWill(thisType, soulStack, newSoulsLeft - soulsLeft);
|
||||
|
||||
setWill(thisType, soulGemStack, newSoulsLeft);
|
||||
if (soul.getWill(thisType, soulStack) <= 0)
|
||||
{
|
||||
if (soul.getWill(thisType, soulStack) <= 0) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
@ -192,10 +168,8 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public double getWill(EnumDemonWillType type, ItemStack soulGemStack)
|
||||
{
|
||||
if (!type.equals(getCurrentType(soulGemStack)))
|
||||
{
|
||||
public double getWill(EnumDemonWillType type, ItemStack soulGemStack) {
|
||||
if (!type.equals(getCurrentType(soulGemStack))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -205,8 +179,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setWill(EnumDemonWillType type, ItemStack soulGemStack, double souls)
|
||||
{
|
||||
public void setWill(EnumDemonWillType type, ItemStack soulGemStack, double souls) {
|
||||
setCurrentType(type, soulGemStack);
|
||||
|
||||
NBTTagCompound tag = soulGemStack.getTagCompound();
|
||||
|
@ -215,19 +188,16 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount, boolean doDrain)
|
||||
{
|
||||
public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount, boolean doDrain) {
|
||||
EnumDemonWillType currentType = this.getCurrentType(soulGemStack);
|
||||
if (currentType != type)
|
||||
{
|
||||
if (currentType != type) {
|
||||
return 0;
|
||||
}
|
||||
double souls = getWill(type, soulGemStack);
|
||||
|
||||
double soulsDrained = Math.min(drainAmount, souls);
|
||||
|
||||
if (doDrain)
|
||||
{
|
||||
if (doDrain) {
|
||||
setWill(type, soulGemStack, souls - soulsDrained);
|
||||
}
|
||||
|
||||
|
@ -235,55 +205,47 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getMaxWill(EnumDemonWillType type, ItemStack soulGemStack)
|
||||
{
|
||||
public int getMaxWill(EnumDemonWillType type, ItemStack soulGemStack) {
|
||||
EnumDemonWillType currentType = getCurrentType(soulGemStack);
|
||||
if (!type.equals(currentType) && currentType != EnumDemonWillType.DEFAULT)
|
||||
{
|
||||
if (!type.equals(currentType) && currentType != EnumDemonWillType.DEFAULT) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (soulGemStack.getMetadata())
|
||||
{
|
||||
case 0:
|
||||
return 64;
|
||||
case 1:
|
||||
return 256;
|
||||
case 2:
|
||||
return 1024;
|
||||
case 3:
|
||||
return 4096;
|
||||
case 4:
|
||||
return 16384;
|
||||
switch (soulGemStack.getMetadata()) {
|
||||
case 0:
|
||||
return 64;
|
||||
case 1:
|
||||
return 256;
|
||||
case 2:
|
||||
return 1024;
|
||||
case 3:
|
||||
return 4096;
|
||||
case 4:
|
||||
return 16384;
|
||||
}
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumDemonWillType getCurrentType(ItemStack soulGemStack)
|
||||
{
|
||||
public EnumDemonWillType getCurrentType(ItemStack soulGemStack) {
|
||||
NBTHelper.checkNBT(soulGemStack);
|
||||
|
||||
NBTTagCompound tag = soulGemStack.getTagCompound();
|
||||
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
if (!tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
return EnumDemonWillType.DEFAULT;
|
||||
}
|
||||
|
||||
return EnumDemonWillType.valueOf(tag.getString(Constants.NBT.WILL_TYPE).toUpperCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public void setCurrentType(EnumDemonWillType type, ItemStack soulGemStack)
|
||||
{
|
||||
public void setCurrentType(EnumDemonWillType type, ItemStack soulGemStack) {
|
||||
NBTHelper.checkNBT(soulGemStack);
|
||||
|
||||
NBTTagCompound tag = soulGemStack.getTagCompound();
|
||||
|
||||
if (type == EnumDemonWillType.DEFAULT)
|
||||
{
|
||||
if (tag.hasKey(Constants.NBT.WILL_TYPE))
|
||||
{
|
||||
if (type == EnumDemonWillType.DEFAULT) {
|
||||
if (tag.hasKey(Constants.NBT.WILL_TYPE)) {
|
||||
tag.removeTag(Constants.NBT.WILL_TYPE);
|
||||
}
|
||||
|
||||
|
@ -294,10 +256,8 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
}
|
||||
|
||||
@Override
|
||||
public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill)
|
||||
{
|
||||
if (!type.equals(getCurrentType(stack)) && this.getWill(getCurrentType(stack), stack) > 0)
|
||||
{
|
||||
public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill) {
|
||||
if (!type.equals(getCurrentType(stack)) && this.getWill(getCurrentType(stack), stack) > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -306,8 +266,7 @@ public class ItemSoulGem extends Item implements IDemonWillGem, IMeshProvider, I
|
|||
|
||||
double filled = Math.min(fillAmount, maxWill - current);
|
||||
|
||||
if (doFill)
|
||||
{
|
||||
if (doFill) {
|
||||
this.setWill(type, stack, filled + current);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraft.util.*;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
|
@ -22,12 +21,10 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemSoulSnare extends Item implements IVariantProvider
|
||||
{
|
||||
public static String[] names = { "base" };
|
||||
public class ItemSoulSnare extends Item implements IVariantProvider {
|
||||
public static String[] names = {"base"};
|
||||
|
||||
public ItemSoulSnare()
|
||||
{
|
||||
public ItemSoulSnare() {
|
||||
super();
|
||||
|
||||
setUnlocalizedName(BloodMagic.MODID + ".soulSnare.");
|
||||
|
@ -37,18 +34,15 @@ public class ItemSoulSnare extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand)
|
||||
{
|
||||
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
|
||||
ItemStack stack = playerIn.getHeldItem(hand);
|
||||
if (!playerIn.capabilities.isCreativeMode)
|
||||
{
|
||||
if (!playerIn.capabilities.isCreativeMode) {
|
||||
stack.shrink(1);
|
||||
}
|
||||
|
||||
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!worldIn.isRemote)
|
||||
{
|
||||
if (!worldIn.isRemote) {
|
||||
EntitySoulSnare snare = new EntitySoulSnare(worldIn, playerIn);
|
||||
snare.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
|
||||
worldIn.spawnEntity(snare);
|
||||
|
@ -58,15 +52,13 @@ public class ItemSoulSnare extends Item implements IVariantProvider
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return super.getUnlocalizedName(stack) + names[stack.getItemDamage()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list)
|
||||
{
|
||||
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
|
||||
if (!isInCreativeTab(creativeTab))
|
||||
return;
|
||||
|
||||
|
@ -76,16 +68,14 @@ public class ItemSoulSnare extends Item implements IVariantProvider
|
|||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
|
||||
tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.soulSnare.desc"))));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pair<Integer, String>> getVariants()
|
||||
{
|
||||
public List<Pair<Integer, String>> getVariants() {
|
||||
List<Pair<Integer, String>> ret = new ArrayList<Pair<Integer, String>>();
|
||||
ret.add(new ImmutablePair<Integer, String>(0, "type=soulsnare"));
|
||||
return ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue