Attempt to try to fix the 1.16.3's branch having multiple 'wayoftime' folders.

This commit is contained in:
WayofTime 2020-10-29 15:48:44 -04:00
parent c159828248
commit 6b4145a67c
224 changed files with 0 additions and 24047 deletions

View file

@ -1,128 +0,0 @@
package wayoftime.bloodmagic.common.item.soul;
import java.util.List;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.NonNullList;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.util.ChatUtil;
import wayoftime.bloodmagic.util.Constants;
import wayoftime.bloodmagic.util.helper.NBTHelper;
import wayoftime.bloodmagic.will.EnumDemonWillType;
import wayoftime.bloodmagic.will.IDemonWill;
public class ItemMonsterSoul extends Item implements IDemonWill
{
private final EnumDemonWillType type;
public ItemMonsterSoul(EnumDemonWillType type)
{
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
this.type = type;
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
{
if (!stack.hasTag())
return;
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.will", ChatUtil.DECIMAL_FORMAT.format(getWill(getType(stack), stack))));
super.addInformation(stack, world, tooltip, flag);
}
@Override
public EnumDemonWillType getType(ItemStack stack)
{
return type;
}
@Override
public double getWill(EnumDemonWillType type, ItemStack soulStack)
{
if (type != this.getType(soulStack))
{
return 0;
}
NBTHelper.checkNBT(soulStack);
CompoundNBT tag = soulStack.getTag();
return tag.getDouble(Constants.NBT.SOULS);
}
@Override
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items)
{
if (this.isInGroup(group))
{
ItemStack stack = new ItemStack(this);
this.setWill(type, stack, 5);
items.add(stack);
}
}
@Override
public boolean setWill(EnumDemonWillType type, ItemStack soulStack, double souls)
{
if (type != this.getType(soulStack))
{
return false;
}
NBTHelper.checkNBT(soulStack);
CompoundNBT tag = soulStack.getTag();
tag.putDouble(Constants.NBT.SOULS, souls);
return true;
}
@Override
public double drainWill(EnumDemonWillType type, ItemStack soulStack, double drainAmount)
{
double souls = getWill(type, soulStack);
double soulsDrained = Math.min(drainAmount, souls);
setWill(type, soulStack, souls - soulsDrained);
return soulsDrained;
}
@Override
public ItemStack createWill(double number)
{
ItemStack soulStack = new ItemStack(this);
setWill(getType(soulStack), soulStack, number);
return soulStack;
}
// @Override
// public double getWill(ItemStack willStack)
// {
// return this.getWill(EnumDemonWillType.DEFAULT, willStack);
// }
//
// @Override
// public void setWill(ItemStack willStack, double will)
// {
// this.setWill(EnumDemonWillType.DEFAULT, willStack, will);
// }
//
// @Override
// public double drainWill(ItemStack willStack, double drainAmount)
// {
// return this.drainWill(EnumDemonWillType.DEFAULT, willStack, drainAmount);
// }
}

View file

@ -1,505 +0,0 @@
package wayoftime.bloodmagic.common.item.soul;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.monster.SlimeEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.Difficulty;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.common.item.BMItemTier;
import wayoftime.bloodmagic.common.item.BloodMagicItems;
import wayoftime.bloodmagic.iface.IMultiWillTool;
import wayoftime.bloodmagic.util.Constants;
import wayoftime.bloodmagic.util.helper.NBTHelper;
import wayoftime.bloodmagic.will.EnumDemonWillType;
import wayoftime.bloodmagic.will.IDemonWill;
import wayoftime.bloodmagic.will.IDemonWillWeapon;
import wayoftime.bloodmagic.will.PlayerDemonWillHandler;
public class ItemSentientSword extends SwordItem implements IDemonWillWeapon, IMultiWillTool
{
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 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 double[] movementSpeed = new double[]
{ 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4 };
public ItemSentientSword()
{
// super(RegistrarBloodMagicItems.SOUL_TOOL_MATERIAL);
super(BMItemTier.SENTIENT, 6, -2.6f, new Item.Properties().maxDamage(520).group(BloodMagic.TAB));
}
// @Override
// 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, PlayerEntity 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)
{
this.setCurrentType(stack, will > 0 ? type : EnumDemonWillType.DEFAULT);
int level = getLevel(stack, will);
double drain = level >= 0 ? soulDrainPerSwing[level] : 0;
double extraDamage = getExtraDamage(type, level);
setActivatedState(stack, will > 16);
setDrainOfActivatedSword(stack, drain);
setDamageOfActivatedSword(stack, 5 + extraDamage);
setStaticDropOfActivatedSword(stack, level >= 0 ? staticDrop[level] : 1);
setDropOfActivatedSword(stack, level >= 0 ? soulDrop[level] : 0);
setAttackSpeedOfSword(stack, level >= 0 ? getAttackSpeed(type, level) : -2.4);
setHealthBonusOfSword(stack, level >= 0 ? getHealthBonus(type, level) : 0);
setSpeedOfSword(stack, level >= 0 ? getMovementSpeed(type, level) : 0);
}
public boolean getActivated(ItemStack stack)
{
return !stack.isEmpty() && NBTHelper.checkNBT(stack).getTag().getBoolean(Constants.NBT.ACTIVATED);
}
public ItemStack setActivatedState(ItemStack stack, boolean activated)
{
if (!stack.isEmpty())
{
NBTHelper.checkNBT(stack).getTag().putBoolean(Constants.NBT.ACTIVATED, activated);
return stack;
}
return stack;
}
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];
}
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 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 void applyEffectToEntity(EnumDemonWillType type, int willBracket, LivingEntity target, LivingEntity 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, LivingEntity target, LivingEntity attacker)
{
if (super.hitEntity(stack, target, attacker))
{
if (attacker instanceof PlayerEntity)
{
PlayerEntity attackerPlayer = (PlayerEntity) attacker;
this.recalculatePowers(stack, attackerPlayer.getEntityWorld(), attackerPlayer);
EnumDemonWillType type = this.getCurrentType(stack);
double will = PlayerDemonWillHandler.getTotalDemonWill(type, attackerPlayer);
int willBracket = this.getLevel(stack, will);
applyEffectToEntity(type, willBracket, target, attackerPlayer);
// ItemStack offStack = attackerPlayer.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
// if (offStack.getItem() instanceof ISentientSwordEffectProvider)
// {
// ISentientSwordEffectProvider provider = (ISentientSwordEffectProvider) offStack.getItem();
// if (provider.providesEffectForWill(type))
// {
// provider.applyOnHitEffect(type, stack, offStack, attacker, target);
// }
// }
}
return true;
}
return false;
}
@Override
public EnumDemonWillType getCurrentType(ItemStack stack)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
if (!tag.contains(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)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
tag.putString(Constants.NBT.WILL_TYPE, type.toString());
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
{
recalculatePowers(player.getHeldItem(hand), world, player);
return super.onItemRightClick(world, player, hand);
}
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
{
return oldStack.getItem() != newStack.getItem();
}
private int getLevel(ItemStack stack, double soulsRemaining)
{
int lvl = -1;
for (int i = 0; i < soulBracket.length; i++)
{
if (soulsRemaining >= soulBracket[i])
{
lvl = i;
}
}
return lvl;
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
{
if (!stack.hasTag())
return;
// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.sentientSword.desc"))));
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.sentientSword.desc"));
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.currentType." + getCurrentType(stack).name().toLowerCase()));
}
@Override
public boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity)
{
recalculatePowers(stack, player.getEntityWorld(), player);
double drain = this.getDrainOfActivatedSword(stack);
if (drain > 0)
{
EnumDemonWillType type = getCurrentType(stack);
double soulsRemaining = PlayerDemonWillHandler.getTotalDemonWill(type, player);
if (drain > soulsRemaining)
{
return false;
} else
{
PlayerDemonWillHandler.consumeDemonWill(type, player, drain);
}
}
return super.onLeftClickEntity(stack, player, entity);
}
@Override
public List<ItemStack> getRandomDemonWillDrop(LivingEntity killedEntity, LivingEntity attackingEntity, ItemStack stack, int looting)
{
List<ItemStack> soulList = new ArrayList<>();
if (killedEntity.getEntityWorld().getDifficulty() != Difficulty.PEACEFUL && !(killedEntity instanceof IMob))
{
return soulList;
}
double willModifier = killedEntity instanceof SlimeEntity ? 0.67 : 1;
IDemonWill soul = ((IDemonWill) BloodMagicItems.MONSTER_SOUL_RAW.get());
EnumDemonWillType type = this.getCurrentType(stack);
for (int i = 0; i <= looting; i++)
{
if (i == 0 || attackingEntity.getEntityWorld().rand.nextDouble() < 0.4)
{
ItemStack soulStack = soul.createWill(willModifier
* (this.getDropOfActivatedSword(stack) * attackingEntity.getEntityWorld().rand.nextDouble()
+ this.getStaticDropOfActivatedSword(stack))
* killedEntity.getMaxHealth() / 20d);
soulList.add(soulStack);
}
}
return soulList;
}
// TODO: Change attack speed.
@Override
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack)
{
Multimap<Attribute, AttributeModifier> multimap = HashMultimap.create();
if (slot == EquipmentSlotType.MAINHAND)
{
multimap.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", getDamageOfActivatedSword(stack), AttributeModifier.Operation.ADDITION));
multimap.put(Attributes.ATTACK_SPEED, new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", this.getAttackSpeedOfSword(stack), AttributeModifier.Operation.ADDITION));
multimap.put(Attributes.MAX_HEALTH, new AttributeModifier(new UUID(0, 31818145), "Weapon modifier", this.getHealthBonusOfSword(stack), AttributeModifier.Operation.ADDITION));
multimap.put(Attributes.MOVEMENT_SPEED, new AttributeModifier(new UUID(0, 4218052), "Weapon modifier", this.getSpeedOfSword(stack), AttributeModifier.Operation.ADDITION));
}
return multimap;
}
public double getDamageOfActivatedSword(ItemStack stack)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
return tag.getDouble(Constants.NBT.SOUL_SWORD_DAMAGE);
}
public void setDamageOfActivatedSword(ItemStack stack, double damage)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
tag.putDouble(Constants.NBT.SOUL_SWORD_DAMAGE, damage);
}
public double getDrainOfActivatedSword(ItemStack stack)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
return tag.getDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN);
}
public void setDrainOfActivatedSword(ItemStack stack, double drain)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
tag.putDouble(Constants.NBT.SOUL_SWORD_ACTIVE_DRAIN, drain);
}
public double getStaticDropOfActivatedSword(ItemStack stack)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
return tag.getDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP);
}
public void setStaticDropOfActivatedSword(ItemStack stack, double drop)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
tag.putDouble(Constants.NBT.SOUL_SWORD_STATIC_DROP, drop);
}
public double getDropOfActivatedSword(ItemStack stack)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
return tag.getDouble(Constants.NBT.SOUL_SWORD_DROP);
}
public void setDropOfActivatedSword(ItemStack stack, double drop)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
tag.putDouble(Constants.NBT.SOUL_SWORD_DROP, drop);
}
public double getHealthBonusOfSword(ItemStack stack)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
return tag.getDouble(Constants.NBT.SOUL_SWORD_HEALTH);
}
public void setHealthBonusOfSword(ItemStack stack, double hp)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
tag.putDouble(Constants.NBT.SOUL_SWORD_HEALTH, hp);
}
public double getAttackSpeedOfSword(ItemStack stack)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
return tag.getDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED);
}
public void setAttackSpeedOfSword(ItemStack stack, double speed)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
tag.putDouble(Constants.NBT.SOUL_SWORD_ATTACK_SPEED, speed);
}
public double getSpeedOfSword(ItemStack stack)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
return tag.getDouble(Constants.NBT.SOUL_SWORD_SPEED);
}
public void setSpeedOfSword(ItemStack stack, double speed)
{
NBTHelper.checkNBT(stack);
CompoundNBT tag = stack.getTag();
tag.putDouble(Constants.NBT.SOUL_SWORD_SPEED, speed);
}
}

View file

@ -1,260 +0,0 @@
package wayoftime.bloodmagic.common.item.soul;
import java.util.List;
import java.util.Locale;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.iface.IMultiWillTool;
import wayoftime.bloodmagic.util.ChatUtil;
import wayoftime.bloodmagic.util.Constants;
import wayoftime.bloodmagic.util.helper.NBTHelper;
import wayoftime.bloodmagic.will.EnumDemonWillType;
import wayoftime.bloodmagic.will.IDemonWill;
import wayoftime.bloodmagic.will.IDemonWillGem;
import wayoftime.bloodmagic.will.PlayerDemonWillHandler;
public class ItemSoulGem extends Item implements IDemonWillGem, IMultiWillTool
{
private final int maxWill;
private final String name;
public ItemSoulGem(String name, int maxWill)
{
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
this.name = name;
this.maxWill = maxWill;
}
@Override
public void fillItemGroup(ItemGroup group, NonNullList<ItemStack> items)
{
if (this.isInGroup(group))
{
for (EnumDemonWillType type : EnumDemonWillType.values())
{
ItemStack stack = new ItemStack(this);
this.setCurrentType(type, stack);
this.setWill(type, stack, maxWill);
items.add(stack);
}
}
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
{
ItemStack stack = player.getHeldItem(hand);
EnumDemonWillType type = this.getCurrentType(stack);
double drain = Math.min(this.getWill(type, stack), this.getMaxWill(type, stack) / 10);
double filled = PlayerDemonWillHandler.addDemonWill(type, player, drain, stack);
this.drainWill(type, stack, filled, true);
return new ActionResult<>(ActionResultType.PASS, stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
{
if (!stack.hasTag())
return;
Items d;
EnumDemonWillType type = this.getCurrentType(stack);
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.soulGem." + name));
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.will", ChatUtil.DECIMAL_FORMAT.format(getWill(type, stack))));
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.currentType." + getCurrentType(stack).name().toLowerCase()));
super.addInformation(stack, world, tooltip, flag);
}
@Override
public boolean showDurabilityBar(ItemStack stack)
{
return true;
}
@Override
public double getDurabilityForDisplay(ItemStack stack)
{
EnumDemonWillType type = this.getCurrentType(stack);
double maxWill = getMaxWill(type, stack);
if (maxWill <= 0)
{
return 1;
}
return 1.0 - (getWill(type, stack) / maxWill);
}
@Override
public int getRGBDurabilityForDisplay(ItemStack stack)
{
EnumDemonWillType type = this.getCurrentType(stack);
double maxWill = getMaxWill(type, stack);
if (maxWill <= 0)
{
return 1;
}
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)
{
EnumDemonWillType thisType = this.getCurrentType(soulGemStack);
if (thisType != ((IDemonWill) soulStack.getItem()).getType(soulStack))
{
return soulStack;
}
IDemonWill soul = (IDemonWill) soulStack.getItem();
double soulsLeft = getWill(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)
{
return ItemStack.EMPTY;
}
}
}
return soulStack;
}
@Override
public double getWill(EnumDemonWillType type, ItemStack soulGemStack)
{
if (!type.equals(getCurrentType(soulGemStack)))
{
return 0;
}
CompoundNBT tag = soulGemStack.getTag();
return tag.getDouble(Constants.NBT.SOULS);
}
@Override
public void setWill(EnumDemonWillType type, ItemStack soulGemStack, double souls)
{
setCurrentType(type, soulGemStack);
CompoundNBT tag = soulGemStack.getTag();
tag.putDouble(Constants.NBT.SOULS, souls);
}
@Override
public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount, boolean doDrain)
{
EnumDemonWillType currentType = this.getCurrentType(soulGemStack);
if (currentType != type)
{
return 0;
}
double souls = getWill(type, soulGemStack);
double soulsDrained = Math.min(drainAmount, souls);
if (doDrain)
{
setWill(type, soulGemStack, souls - soulsDrained);
}
return soulsDrained;
}
@Override
public int getMaxWill(EnumDemonWillType type, ItemStack soulGemStack)
{
EnumDemonWillType currentType = getCurrentType(soulGemStack);
if (!type.equals(currentType) && currentType != EnumDemonWillType.DEFAULT)
{
return 0;
}
return maxWill;
}
@Override
public EnumDemonWillType getCurrentType(ItemStack soulGemStack)
{
NBTHelper.checkNBT(soulGemStack);
CompoundNBT tag = soulGemStack.getTag();
if (!tag.contains(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)
{
NBTHelper.checkNBT(soulGemStack);
CompoundNBT tag = soulGemStack.getTag();
if (type == EnumDemonWillType.DEFAULT)
{
if (tag.contains(Constants.NBT.WILL_TYPE))
{
tag.remove(Constants.NBT.WILL_TYPE);
}
return;
}
tag.putString(Constants.NBT.WILL_TYPE, type.toString());
}
@Override
public double fillWill(EnumDemonWillType type, ItemStack stack, double fillAmount, boolean doFill)
{
if (!type.equals(getCurrentType(stack)) && this.getWill(getCurrentType(stack), stack) > 0)
{
return 0;
}
double current = this.getWill(type, stack);
double maxWill = this.getMaxWill(type, stack);
double filled = Math.min(fillAmount, maxWill - current);
if (doFill)
{
this.setWill(type, stack, filled + current);
}
return filled;
}
}

View file

@ -1,76 +0,0 @@
package wayoftime.bloodmagic.common.item.soul;
import java.util.List;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SnowballItem;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import wayoftime.bloodmagic.BloodMagic;
import wayoftime.bloodmagic.entity.projectile.EntitySoulSnare;
public class ItemSoulSnare extends Item
{
public static String[] names =
{ "base" };
public ItemSoulSnare()
{
super(new Item.Properties().maxStackSize(16).group(BloodMagic.TAB));
// setTranslationKey(BloodMagic.MODID + ".soulSnare.");
// setCreativeTab(BloodMagic.TAB_BM);
// setHasSubtypes(true);
// setMaxStackSize(16);
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand hand)
{
ItemStack stack = playerIn.getHeldItem(hand);
if (!playerIn.isCreative())
{
stack.shrink(1);
}
SnowballItem d;
worldIn.playSound((PlayerEntity) null, playerIn.getPosX(), playerIn.getPosY(), playerIn.getPosZ(), SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F
/ (random.nextFloat() * 0.4F + 0.8F));
if (!worldIn.isRemote)
{
System.out.println("Attempting to spawn");
EntitySoulSnare snare = new EntitySoulSnare(worldIn, playerIn);
snare.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
worldIn.addEntity(snare);
//
// SnowballEntity snowballentity = new SnowballEntity(worldIn, playerIn);
// snowballentity.setItem(itemstack);
// snowballentity.func_234612_a_(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
// worldIn.addEntity(snowballentity);
}
return new ActionResult<>(ActionResultType.SUCCESS, stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
{
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.soulSnare.desc"));
super.addInformation(stack, world, tooltip, flag);
}
}