Creation of 1.16.3 branch
Initial publishing of the 1.16.3 branch of the mod. A lot of systems are missing (such as Rituals and Living Armour), but enough is present for a decent Alpha release.
This commit is contained in:
parent
0e02b983f1
commit
d617911d7a
1662 changed files with 18791 additions and 85075 deletions
|
@ -0,0 +1,113 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilAir;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilBloodLight;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilDivination;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilFastMiner;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilFrost;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilGreenGrove;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilLava;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilMagnetism;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilVoid;
|
||||
import wayoftime.bloodmagic.common.item.sigil.ItemSigilWater;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemMonsterSoul;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemSentientSword;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemSoulGem;
|
||||
import wayoftime.bloodmagic.common.item.soul.ItemSoulSnare;
|
||||
import wayoftime.bloodmagic.common.registration.impl.BloodOrbDeferredRegister;
|
||||
import wayoftime.bloodmagic.common.registration.impl.BloodOrbRegistryObject;
|
||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
||||
import wayoftime.bloodmagic.will.EnumDemonWillType;
|
||||
|
||||
public class BloodMagicItems
|
||||
{
|
||||
// public static Item.ToolMaterial SOUL_TOOL_MATERIAL = EnumHelper.addToolMaterial("demonic", 4, 520, 7, 8, 50);
|
||||
// public static final BloodOrb WEAK_ORB_INSTANCE = new BloodOrb(new ResourceLocation(BloodMagic.MODID, "weakbloodorb"), 0, 5000, 10);
|
||||
public static final BloodOrbDeferredRegister BLOOD_ORBS = new BloodOrbDeferredRegister(BloodMagic.MODID);
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, BloodMagic.MODID);
|
||||
public static final DeferredRegister<Item> BASICITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, BloodMagic.MODID);
|
||||
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_WEAK = BLOOD_ORBS.register("weakbloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "weakbloodorb"), 1, 5000, 2));
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_APPRENTICE = BLOOD_ORBS.register("apprenticebloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "apprenticebloodorb"), 2, 25000, 5));
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_MAGICIAN = BLOOD_ORBS.register("magicianbloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "magicianbloodorb"), 3, 150000, 15));
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_MASTER = BLOOD_ORBS.register("masterbloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "masterbloodorb"), 4, 1000000, 25));
|
||||
public static final BloodOrbRegistryObject<BloodOrb> ORB_ARCHMAGE = BLOOD_ORBS.register("archmagebloodorb", () -> new BloodOrb(new ResourceLocation(BloodMagic.MODID, "archmagebloodorb"), 5, 10000000, 50));
|
||||
// public static final DeferredRegister<BloodOrb> BLOOD_ORBS = DeferredRegister.create(RegistrarBloodMagic.BLOOD_ORBS, BloodMagic.MODID);
|
||||
|
||||
// public static final RegistryObject<Item> BLOODSTONE_ITEM = ITEMS.register("ruby_block", () -> new BlockItem(BloodMagicBlocks.BLOODSTONE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> SOUL_FORGE_ITEM = ITEMS.register("soulforge", () -> new BlockItem(BloodMagicBlocks.SOUL_FORGE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> BLANK_RUNE_ITEM = ITEMS.register("blankrune", () -> new BlockItem(BloodMagicBlocks.BLANK_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> SPEED_RUNE_ITEM = ITEMS.register("speedrune", () -> new BlockItem(BloodMagicBlocks.SPEED_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> SACRIFICE_RUNE_ITEM = ITEMS.register("sacrificerune", () -> new BlockItem(BloodMagicBlocks.SACRIFICE_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> SELF_SACRIFICE_RUNE_ITEM = ITEMS.register("selfsacrificerune", () -> new BlockItem(BloodMagicBlocks.SELF_SACRIFICE_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> DISPLACEMENT_RUNE_ITEM = ITEMS.register("dislocationrune", () -> new BlockItem(BloodMagicBlocks.DISPLACEMENT_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> CAPACITY_RUNE_ITEM = ITEMS.register("altarcapacityrune", () -> new BlockItem(BloodMagicBlocks.CAPACITY_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> AUGMENTED_CAPACITY_RUNE_ITEM = ITEMS.register("bettercapacityrune", () -> new BlockItem(BloodMagicBlocks.AUGMENTED_CAPACITY_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> ORB_RUNE_ITEM = ITEMS.register("orbcapacityrune", () -> new BlockItem(BloodMagicBlocks.ORB_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> ACCELERATION_RUNE_ITEM = ITEMS.register("accelerationrune", () -> new BlockItem(BloodMagicBlocks.ACCELERATION_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
public static final RegistryObject<Item> CHARGING_RUNE_ITEM = ITEMS.register("chargingrune", () -> new BlockItem(BloodMagicBlocks.CHARGING_RUNE.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
|
||||
public static final RegistryObject<Item> BLOOD_ALTAR_ITEM = ITEMS.register("altar", () -> new BlockItem(BloodMagicBlocks.BLOOD_ALTAR.get(), new Item.Properties().group(BloodMagic.TAB)));
|
||||
|
||||
// TODO: Need to rework the above instantiations for the ItemBlocks so that it's
|
||||
// done with the Blocks.
|
||||
|
||||
// public static final RegistryObject<Item> WEAK_BLOOD_ORB = BASICITEMS.register("weakbloodorb", ItemBloodOrb::new);
|
||||
// public static final RegistryObject<Item> WEAK_BLOOD_ORB = BASICITEMS.register("weakbloodorb", () -> new ItemBloodOrb(WEAK_ORB_INSTANCE));
|
||||
public static final RegistryObject<Item> WEAK_BLOOD_ORB = BASICITEMS.register("weakbloodorb", () -> new ItemBloodOrb(ORB_WEAK));
|
||||
public static final RegistryObject<Item> APPRENTICE_BLOOD_ORB = BASICITEMS.register("apprenticebloodorb", () -> new ItemBloodOrb(ORB_APPRENTICE));
|
||||
public static final RegistryObject<Item> MAGICIAN_BLOOD_ORB = BASICITEMS.register("magicianbloodorb", () -> new ItemBloodOrb(ORB_MAGICIAN));
|
||||
public static final RegistryObject<Item> MASTER_BLOOD_ORB = BASICITEMS.register("masterbloodorb", () -> new ItemBloodOrb(ORB_MASTER));
|
||||
|
||||
public static final RegistryObject<Item> DIVINATION_SIGIL = BASICITEMS.register("divinationsigil", () -> new ItemSigilDivination(true));
|
||||
public static final RegistryObject<Item> SACRIFICIAL_DAGGER = BASICITEMS.register("sacrificialdagger", () -> new ItemSacrificialDagger());
|
||||
public static final RegistryObject<Item> SLATE = BASICITEMS.register("blankslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REINFORCED_SLATE = BASICITEMS.register("reinforcedslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> IMBUED_SLATE = BASICITEMS.register("infusedslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> DEMONIC_SLATE = BASICITEMS.register("demonslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> ETHEREAL_SLATE = BASICITEMS.register("etherealslate", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> WATER_SIGIL = BASICITEMS.register("watersigil", () -> new ItemSigilWater());
|
||||
public static final RegistryObject<Item> VOID_SIGIL = BASICITEMS.register("voidsigil", () -> new ItemSigilVoid());
|
||||
public static final RegistryObject<Item> LAVA_SIGIL = BASICITEMS.register("lavasigil", () -> new ItemSigilLava());
|
||||
public static final RegistryObject<Item> GREEN_GROVE_SIGIL = ITEMS.register("growthsigil", () -> new ItemSigilGreenGrove());
|
||||
public static final RegistryObject<Item> FAST_MINER_SIGIL = ITEMS.register("miningsigil", () -> new ItemSigilFastMiner());
|
||||
public static final RegistryObject<Item> MAGNETISM_SIGIL = ITEMS.register("sigilofmagnetism", () -> new ItemSigilMagnetism());
|
||||
public static final RegistryObject<Item> ICE_SIGIL = ITEMS.register("icesigil", () -> new ItemSigilFrost());
|
||||
public static final RegistryObject<Item> AIR_SIGIL = BASICITEMS.register("airsigil", ItemSigilAir::new);
|
||||
public static final RegistryObject<Item> BLOOD_LIGHT_SIGIL = BASICITEMS.register("bloodlightsigil", ItemSigilBloodLight::new);
|
||||
|
||||
public static final RegistryObject<Item> ARCANE_ASHES = BASICITEMS.register("arcaneashes", () -> new ItemArcaneAshes());
|
||||
public static final RegistryObject<Item> DAGGER_OF_SACRIFICE = BASICITEMS.register("daggerofsacrifice", () -> new ItemDaggerOfSacrifice());
|
||||
|
||||
// Reagents used to make the Sigils
|
||||
public static final RegistryObject<Item> REAGENT_WATER = BASICITEMS.register("reagentwater", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_LAVA = BASICITEMS.register("reagentlava", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_VOID = BASICITEMS.register("reagentvoid", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_GROWTH = BASICITEMS.register("reagentgrowth", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_FAST_MINER = BASICITEMS.register("reagentfastminer", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_MAGNETISM = BASICITEMS.register("reagentmagnetism", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_AIR = BASICITEMS.register("reagentair", () -> new ItemBase());
|
||||
public static final RegistryObject<Item> REAGENT_BLOOD_LIGHT = BASICITEMS.register("reagentbloodlight", () -> new ItemBase());
|
||||
|
||||
// Tartaric Gems
|
||||
public static final RegistryObject<Item> PETTY_GEM = ITEMS.register("soulgempetty", () -> new ItemSoulGem("petty", 64));
|
||||
public static final RegistryObject<Item> LESSER_GEM = ITEMS.register("soulgemlesser", () -> new ItemSoulGem("lesser", 256));
|
||||
public static final RegistryObject<Item> COMMON_GEM = ITEMS.register("soulgemcommon", () -> new ItemSoulGem("common", 1024));
|
||||
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_RAW = BASICITEMS.register("basemonstersoul", () -> new ItemMonsterSoul(EnumDemonWillType.DEFAULT));
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_CORROSIVE = BASICITEMS.register("basemonstersoul_corrosive", () -> new ItemMonsterSoul(EnumDemonWillType.CORROSIVE));
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_DESTRUCTIVE = BASICITEMS.register("basemonstersoul_destructive", () -> new ItemMonsterSoul(EnumDemonWillType.DESTRUCTIVE));
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_STEADFAST = BASICITEMS.register("basemonstersoul_steadfast", () -> new ItemMonsterSoul(EnumDemonWillType.STEADFAST));
|
||||
public static final RegistryObject<Item> MONSTER_SOUL_VENGEFUL = BASICITEMS.register("basemonstersoul_vengeful", () -> new ItemMonsterSoul(EnumDemonWillType.VENGEFUL));
|
||||
|
||||
public static final RegistryObject<Item> SOUL_SNARE = BASICITEMS.register("soulsnare", ItemSoulSnare::new);
|
||||
public static final RegistryObject<Item> SENTIENT_SWORD = ITEMS.register("soulsword", () -> new ItemSentientSword());
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
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.ItemUseContext;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.tile.TileAlchemyArray;
|
||||
|
||||
public class ItemArcaneAshes extends Item
|
||||
{
|
||||
public ItemArcaneAshes()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB).maxDamage(20));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.arcaneAshes"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext context)
|
||||
{
|
||||
ItemStack stack = context.getItem();
|
||||
BlockPos newPos = context.getPos().offset(context.getFace());
|
||||
World world = context.getWorld();
|
||||
PlayerEntity player = context.getPlayer();
|
||||
|
||||
if (world.isAirBlock(newPos))
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
Direction rotation = Direction.fromAngle(player.getRotationYawHead());
|
||||
world.setBlockState(newPos, BloodMagicBlocks.ALCHEMY_ARRAY.get().getDefaultState());
|
||||
TileEntity tile = world.getTileEntity(newPos);
|
||||
if (tile instanceof TileAlchemyArray)
|
||||
{
|
||||
((TileAlchemyArray) tile).setRotation(rotation);
|
||||
}
|
||||
|
||||
// PickaxeItem d;
|
||||
stack.damageItem(1, player, (entity) -> {
|
||||
entity.sendBreakAnimation(EquipmentSlotType.MAINHAND);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public ActionResultType onItemUse(PlayerEntity player, World world, BlockPos blockPos, Hand hand, Direction side, float hitX, float hitY, float hitZ)
|
||||
// {
|
||||
// ItemStack stack = player.getHeldItem(hand);
|
||||
// BlockPos newPos = blockPos.offset(side);
|
||||
//
|
||||
// if (world.isAirBlock(newPos))
|
||||
// {
|
||||
// if (!world.isRemote)
|
||||
// {
|
||||
// Direction rotation = Direction.fromAngle(player.getRotationYawHead());
|
||||
// world.setBlockState(newPos, RegistrarBloodMagicBlocks.ALCHEMY_ARRAY.getDefaultState());
|
||||
// TileEntity tile = world.getTileEntity(newPos);
|
||||
// if (tile instanceof TileAlchemyArray)
|
||||
// {
|
||||
// ((TileAlchemyArray) tile).setRotation(rotation);
|
||||
// }
|
||||
//
|
||||
// stack.damageItem(1, player);
|
||||
// }
|
||||
//
|
||||
// return ActionResultType.SUCCESS;
|
||||
// }
|
||||
//
|
||||
// return ActionResultType.FAIL;
|
||||
// }
|
||||
|
||||
}
|
38
src/main/java/wayoftime/bloodmagic/common/item/ItemBase.java
Normal file
38
src/main/java/wayoftime/bloodmagic/common/item/ItemBase.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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;
|
||||
|
||||
public class ItemBase extends Item
|
||||
{
|
||||
private final String desc;
|
||||
|
||||
public ItemBase()
|
||||
{
|
||||
this("");
|
||||
}
|
||||
|
||||
public ItemBase(String desc)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(64).group(BloodMagic.TAB));
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
if (!desc.isEmpty())
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic." + desc));
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.core.data.Binding;
|
||||
import wayoftime.bloodmagic.iface.IBindable;
|
||||
|
||||
public class ItemBindableBase extends Item implements IBindable
|
||||
{
|
||||
public ItemBindableBase()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
if (!stack.hasTag())
|
||||
return;
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding != null)
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
|
||||
}
|
||||
}
|
106
src/main/java/wayoftime/bloodmagic/common/item/ItemBloodOrb.java
Normal file
106
src/main/java/wayoftime/bloodmagic/common/item/ItemBloodOrb.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
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 net.minecraftforge.common.extensions.IForgeItem;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.core.data.SoulNetwork;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.orb.BloodOrb;
|
||||
import wayoftime.bloodmagic.orb.IBloodOrb;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb, IForgeItem
|
||||
{
|
||||
private final Supplier<BloodOrb> sup;
|
||||
|
||||
public ItemBloodOrb(Supplier<BloodOrb> sup)
|
||||
{
|
||||
this.sup = sup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BloodOrb getOrb(ItemStack stack)
|
||||
{
|
||||
return sup.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
BloodOrb orb = getOrb(stack);
|
||||
|
||||
if (orb == null)
|
||||
return ActionResult.resultFail(stack);
|
||||
|
||||
if (world == null)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F
|
||||
+ (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (!stack.hasTag())
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding == null)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (world.isRemote)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
SoulNetwork ownerNetwork = NetworkHelper.getSoulNetwork(binding);
|
||||
if (binding.getOwnerId().equals(player.getGameProfile().getId()))
|
||||
ownerNetwork.setOrbTier(orb.getTier());
|
||||
|
||||
ownerNetwork.add(SoulTicket.item(stack, world, player, 200), orb.getCapacity()); // Add LP to owner's network
|
||||
ownerNetwork.hurtPlayer(player, 200); // Hurt whoever is using it
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.orb.desc"));
|
||||
|
||||
BloodOrb orb = getOrb(stack);
|
||||
if (flag.isAdvanced() && orb != null)
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.orb.owner", stack.getItem().getRegistryName()));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
//
|
||||
@Override
|
||||
public ItemStack getContainerItem(ItemStack stack)
|
||||
{
|
||||
return stack.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasContainerItem(ItemStack stack)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.monster.IMob;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerSacrificeHelper;
|
||||
|
||||
public class ItemDaggerOfSacrifice extends Item
|
||||
{
|
||||
public ItemDaggerOfSacrifice()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker)
|
||||
{
|
||||
if (attacker instanceof FakePlayer)
|
||||
return false;
|
||||
|
||||
if (target == null || attacker == null || attacker.getEntityWorld().isRemote
|
||||
|| (attacker instanceof PlayerEntity && !(attacker instanceof ServerPlayerEntity)))
|
||||
return false;
|
||||
|
||||
if (!target.isNonBoss())
|
||||
return false;
|
||||
|
||||
if (target instanceof PlayerEntity)
|
||||
return false;
|
||||
|
||||
if (target.isChild() && !(target instanceof IMob))
|
||||
return false;
|
||||
|
||||
if (!target.isAlive() || target.getHealth() < 0.5F)
|
||||
return false;
|
||||
|
||||
// EntityEntry entityEntry = EntityRegistry.getEntry(target.getClass());
|
||||
// if (entityEntry == null)
|
||||
// return false;
|
||||
// int lifeEssenceRatio = BloodMagicAPI.INSTANCE.getValueManager().getSacrificial().getOrDefault(entityEntry.getRegistryName(), 25);
|
||||
int lifeEssenceRatio = 25;
|
||||
|
||||
if (lifeEssenceRatio <= 0)
|
||||
return false;
|
||||
|
||||
int lifeEssence = (int) (lifeEssenceRatio * target.getHealth());
|
||||
// if (target instanceof AnimalEntity)
|
||||
// {
|
||||
// lifeEssence = (int) (lifeEssence * (1 + PurificationHelper.getCurrentPurity((AnimalEntity) target)));
|
||||
// }
|
||||
|
||||
if (target.isChild())
|
||||
{
|
||||
lifeEssence *= 0.5F;
|
||||
}
|
||||
|
||||
if (PlayerSacrificeHelper.findAndFillAltar(attacker.getEntityWorld(), target, lifeEssence, true))
|
||||
{
|
||||
target.getEntityWorld().playSound(null, target.getPosX(), target.getPosY(), target.getPosZ(), 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(DamageSourceBloodMagic.INSTANCE);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,204 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.UseAction;
|
||||
import net.minecraft.particles.RedstoneParticleData;
|
||||
import net.minecraft.util.ActionResult;
|
||||
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 net.minecraftforge.common.MinecraftForge;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.ConfigHandler;
|
||||
import wayoftime.bloodmagic.event.SacrificeKnifeUsedEvent;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerSacrificeHelper;
|
||||
|
||||
public class ItemSacrificialDagger extends Item
|
||||
{
|
||||
|
||||
public ItemSacrificialDagger()
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
// tooltip.addAll(Arrays.asList(TextHelper.cutLongString(TextHelper.localizeEffect("tooltip.bloodmagic.sacrificialDagger.desc"))));
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.sacrificialdagger.desc"));
|
||||
|
||||
// if (stack.getItemDamage() == 1)
|
||||
// list.add(TextHelper.localizeEffect("tooltip.bloodmagic.sacrificialDagger.creative"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft)
|
||||
{
|
||||
if (entityLiving instanceof PlayerEntity && !entityLiving.getEntityWorld().isRemote)
|
||||
PlayerSacrificeHelper.sacrificePlayerHealth((PlayerEntity) entityLiving);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUseDuration(ItemStack stack)
|
||||
{
|
||||
return 72000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseAction getUseAction(ItemStack stack)
|
||||
{
|
||||
return UseAction.BOW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
|
||||
{
|
||||
ItemStack stack = player.getHeldItem(hand);
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (this.canUseForSacrifice(stack))
|
||||
{
|
||||
player.setActiveHand(hand);
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
|
||||
int lpAdded = ConfigHandler.values.sacrificialDaggerConversion * 2;
|
||||
|
||||
// RayTraceResult rayTrace = rayTrace(world, player, false);
|
||||
// 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.abilities.isCreativeMode)
|
||||
{
|
||||
SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2, lpAdded);
|
||||
if (MinecraftForge.EVENT_BUS.post(evt))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (evt.shouldDrainHealth)
|
||||
{
|
||||
player.hurtResistantTime = 0;
|
||||
player.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 0.001F);
|
||||
player.setHealth(Math.max(player.getHealth() - 1.998F, 0.0001f));
|
||||
if (player.getHealth() <= 0.001f)
|
||||
{
|
||||
player.onDeath(DamageSourceBloodMagic.INSTANCE);
|
||||
player.setHealth(0);
|
||||
}
|
||||
// player.attackEntityFrom(BloodMagicAPI.getDamageSource(), 2.0F);
|
||||
}
|
||||
|
||||
if (!evt.shouldFillAltar)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
lpAdded = evt.lpAdded;
|
||||
}
|
||||
|
||||
double posX = player.getPosX();
|
||||
double posY = player.getPosY();
|
||||
double posZ = player.getPosZ();
|
||||
world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F
|
||||
+ (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
|
||||
for (int l = 0; l < 8; ++l) world.addParticle(RedstoneParticleData.REDSTONE_DUST, posX + Math.random()
|
||||
- Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), 0, 0, 0);
|
||||
|
||||
if (!world.isRemote && PlayerHelper.isFakePlayer(player))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
// TODO - Check if SoulFray is active
|
||||
PlayerSacrificeHelper.findAndFillAltar(world, player, lpAdded, false);
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (!world.isRemote && entity instanceof PlayerEntity)
|
||||
this.setUseForSacrifice(stack, this.isPlayerPreparedForSacrifice(world, (PlayerEntity) entity));
|
||||
}
|
||||
|
||||
public boolean isPlayerPreparedForSacrifice(World world, PlayerEntity player)
|
||||
{
|
||||
return !world.isRemote && (PlayerSacrificeHelper.getPlayerIncense(player) > 0);
|
||||
}
|
||||
|
||||
public boolean canUseForSacrifice(ItemStack stack)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
return stack.getTag().getBoolean(Constants.NBT.SACRIFICE);
|
||||
}
|
||||
|
||||
public void setUseForSacrifice(ItemStack stack, boolean sacrifice)
|
||||
{
|
||||
stack = NBTHelper.checkNBT(stack);
|
||||
stack.getTag().putBoolean(Constants.NBT.SACRIFICE, sacrifice);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public ItemMeshDefinition getMeshDefinition()
|
||||
// {
|
||||
// return stack -> {
|
||||
// String variant = "type=normal";
|
||||
// if (stack.getItemDamage() != 0)
|
||||
// variant = "type=creative";
|
||||
//
|
||||
// if (canUseForSacrifice(stack))
|
||||
// variant = "type=ceremonial";
|
||||
//
|
||||
// return new ModelResourceLocation(getRegistryName(), variant);
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void gatherVariants(Consumer<String> variants)
|
||||
// {
|
||||
// variants.accept("type=normal");
|
||||
// variants.accept("type=creative");
|
||||
// variants.accept("type=ceremonial");
|
||||
// }
|
||||
//
|
||||
// public enum DaggerType implements ISubItem
|
||||
// {
|
||||
//
|
||||
// NORMAL, CREATIVE,;
|
||||
//
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public String getInternalName()
|
||||
// {
|
||||
// return name().toLowerCase(Locale.ROOT);
|
||||
// }
|
||||
//
|
||||
// @Nonnull
|
||||
// @Override
|
||||
// public ItemStack getStack(int count)
|
||||
// {
|
||||
// return new ItemStack(RegistrarBloodMagicItems.SACRIFICIAL_DAGGER, count, ordinal());
|
||||
// }
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package wayoftime.bloodmagic.common.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.core.data.Binding;
|
||||
import wayoftime.bloodmagic.iface.IBindable;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
|
||||
/**
|
||||
* Base class for all (static) sigils.
|
||||
*/
|
||||
public class ItemSigil extends Item implements IBindable, ISigil
|
||||
{
|
||||
private int lpUsed;
|
||||
|
||||
public ItemSigil(Properties prop, int lpUsed)
|
||||
{
|
||||
super(prop);
|
||||
|
||||
this.lpUsed = lpUsed;
|
||||
}
|
||||
|
||||
public boolean isUnusable(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
return stack.getTag().getBoolean(Constants.NBT.UNUSABLE);
|
||||
}
|
||||
|
||||
public ItemStack setUnusable(ItemStack stack, boolean unusable)
|
||||
{
|
||||
NBTHelper.checkNBT(stack);
|
||||
|
||||
stack.getTag().putBoolean(Constants.NBT.UNUSABLE, unusable);
|
||||
return stack;
|
||||
}
|
||||
|
||||
public int getLpUsed()
|
||||
{
|
||||
return lpUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
if (!stack.hasTag())
|
||||
return;
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding != null)
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic.currentOwner", binding.getOwnerName()));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilAir extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilAir()
|
||||
{
|
||||
super("air", 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand 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.resultFail(stack);
|
||||
|
||||
boolean unusable = isUnusable(stack);
|
||||
if (world.isRemote && !unusable)
|
||||
{
|
||||
Vector3d vec = player.getLookVec();
|
||||
double wantedVelocity = 1.7;
|
||||
|
||||
// TODO - Revisit after potions
|
||||
// if (player.isPotionActive(RegistrarBloodMagic.BOOST))
|
||||
// {
|
||||
// int amplifier = player.getActivePotionEffect(RegistrarBloodMagic.BOOST).getAmplifier();
|
||||
// wantedVelocity += (1 + amplifier) * (0.35);
|
||||
// }
|
||||
|
||||
player.setMotion(vec.x * wantedVelocity, vec.y * wantedVelocity, vec.z * wantedVelocity);
|
||||
|
||||
world.playSound(null, player.getPosX(), player.getPosY(), player.getPosZ(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F
|
||||
+ (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
}
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
if (!player.isCreative())
|
||||
this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess());
|
||||
|
||||
if (!unusable)
|
||||
player.fallDistance = 0;
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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.common.item.ItemSigil;
|
||||
|
||||
public class ItemSigilBase extends ItemSigil
|
||||
{
|
||||
protected final String tooltipBase;
|
||||
// private final String name;
|
||||
|
||||
public ItemSigilBase(String name, int lpUsed)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB), lpUsed);
|
||||
// super(lpUsed);
|
||||
|
||||
// this.name = name;
|
||||
this.tooltipBase = "tooltip.bloodmagic.sigil." + name + ".";
|
||||
}
|
||||
|
||||
public ItemSigilBase(String name)
|
||||
{
|
||||
this(name, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
tooltip.add(new TranslationTextComponent(tooltipBase + "desc"));
|
||||
// if (TextHelper.canTranslate(tooltipBase + "desc"))
|
||||
// tooltip.addAll(Arrays.asList(WordUtils.wrap(TextHelper.localizeEffect(tooltipBase
|
||||
// + "desc"), 30, "/cut", false).split("/cut")));
|
||||
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
}
|
||||
|
||||
// public String getName()
|
||||
// {
|
||||
// return name;
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.core.data.SoulNetwork;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.entity.projectile.EntityBloodLight;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilBloodLight extends ItemSigilBase
|
||||
{
|
||||
public ItemSigilBloodLight()
|
||||
{
|
||||
super("bloodlight", 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (getCooldownRemainder(stack) > 0)
|
||||
reduceCooldown(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand 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.resultFail(stack);
|
||||
|
||||
RayTraceResult mop = rayTrace(world, player, RayTraceContext.FluidMode.NONE);
|
||||
|
||||
if (getCooldownRemainder(stack) > 0)
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
|
||||
if (mop != null && mop.getType() == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
BlockRayTraceResult blockRayTrace = (BlockRayTraceResult) mop;
|
||||
BlockPos blockPos = blockRayTrace.getPos().offset(blockRayTrace.getFace());
|
||||
|
||||
if (world.isAirBlock(blockPos))
|
||||
{
|
||||
world.setBlockState(blockPos, BloodMagicBlocks.BLOOD_LIGHT.get().getDefaultState());
|
||||
if (!world.isRemote)
|
||||
{
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
|
||||
network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed()));
|
||||
}
|
||||
resetCooldown(stack);
|
||||
player.swingArm(hand);
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
|
||||
EntityBloodLight light = new EntityBloodLight(world, player);
|
||||
light.func_234612_a_(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
|
||||
world.addEntity(light);
|
||||
network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed()));
|
||||
}
|
||||
resetCooldown(stack);
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
|
||||
{
|
||||
return oldStack.getItem() != newStack.getItem();
|
||||
}
|
||||
|
||||
public int getCooldownRemainder(ItemStack stack)
|
||||
{
|
||||
return NBTHelper.checkNBT(stack).getTag().getInt(Constants.NBT.TICKS_REMAINING);
|
||||
}
|
||||
|
||||
public void reduceCooldown(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTag().putInt(Constants.NBT.TICKS_REMAINING, getCooldownRemainder(stack) - 1);
|
||||
}
|
||||
|
||||
public void resetCooldown(ItemStack stack)
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTag().putInt(Constants.NBT.TICKS_REMAINING, 10);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceContext.FluidMode;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.altar.IBloodAltar;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.iface.IAltarReader;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.ChatUtil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.NumeralHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
|
||||
{
|
||||
|
||||
public ItemSigilDivination(boolean simple)
|
||||
{
|
||||
super(simple ? "divination" : "seer");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand 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.resultFail(stack);
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
RayTraceResult position = Item.rayTrace(world, player, FluidMode.NONE);
|
||||
|
||||
if (position == null || position.getType() == RayTraceResult.Type.MISS)
|
||||
{
|
||||
super.onItemRightClick(world, player, hand);
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding != null)
|
||||
{
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(binding).getCurrentEssence();
|
||||
List<ITextComponent> toSend = Lists.newArrayList();
|
||||
if (!binding.getOwnerId().equals(player.getGameProfile().getId()))
|
||||
toSend.add(new TranslationTextComponent(tooltipBase + "otherNetwork", binding.getOwnerName()));
|
||||
toSend.add(new TranslationTextComponent(tooltipBase + "currentEssence", currentEssence));
|
||||
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (position.getType() == RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
TileEntity tile = world.getTileEntity(new BlockPos(position.getHitVec()));
|
||||
|
||||
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 TranslationTextComponent(tooltipBase
|
||||
+ "currentAltarTier", NumeralHelper.toRoman(tier)), new TranslationTextComponent(tooltipBase
|
||||
+ "currentEssence", currentEssence), new TranslationTextComponent(tooltipBase
|
||||
+ "currentAltarCapacity", capacity));
|
||||
}
|
||||
// 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)
|
||||
// {
|
||||
// TileInversionPillar pillar = (TileInversionPillar) tile;
|
||||
// double inversion = pillar.getCurrentInversion();
|
||||
// ChatUtil.sendNoSpam(player, new TextComponentTranslation(tooltipBase + "currentInversion", ((int) (10 * inversion)) / 10d));
|
||||
// }
|
||||
else
|
||||
{
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding != null)
|
||||
{
|
||||
int currentEssence = NetworkHelper.getSoulNetwork(binding).getCurrentEssence();
|
||||
List<ITextComponent> toSend = Lists.newArrayList();
|
||||
if (!binding.getOwnerId().equals(player.getGameProfile().getId()))
|
||||
toSend.add(new TranslationTextComponent(tooltipBase
|
||||
+ "otherNetwork", binding.getOwnerName()));
|
||||
toSend.add(new TranslationTextComponent(tooltipBase + "currentEssence", currentEssence));
|
||||
ChatUtil.sendNoSpam(player, toSend.toArray(new ITextComponent[toSend.size()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilFastMiner extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilFastMiner()
|
||||
{
|
||||
super("fast_miner", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
player.addPotionEffect(new EffectInstance(Effects.HASTE, 2, 0, true, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performArrayEffect(World world, BlockPos pos)
|
||||
{
|
||||
double radius = 10;
|
||||
int ticks = 600;
|
||||
int potionPotency = 2;
|
||||
|
||||
AxisAlignedBB bb = new AxisAlignedBB(pos).grow(radius);
|
||||
List<PlayerEntity> playerList = world.getEntitiesWithinAABB(PlayerEntity.class, bb);
|
||||
for (PlayerEntity player : playerList)
|
||||
{
|
||||
if (!player.isPotionActive(Effects.HASTE) || (player.isPotionActive(Effects.HASTE)
|
||||
&& player.getActivePotionEffect(Effects.HASTE).getAmplifier() < potionPotency))
|
||||
{
|
||||
player.addPotionEffect(new EffectInstance(Effects.HASTE, ticks, potionPotency));
|
||||
if (!player.isCreative())
|
||||
{
|
||||
player.hurtResistantTime = 0;
|
||||
player.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArrayEffect()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,152 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BucketItem;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
|
||||
import net.minecraftforge.fluids.capability.wrappers.BlockWrapper;
|
||||
|
||||
public abstract class ItemSigilFluidBase extends ItemSigilBase
|
||||
{
|
||||
// Class for sigils that interact with fluids, either creating or deleting them.
|
||||
// Sigils still have to define their own onRightClick behavior, but the actual
|
||||
// fluid-interacting code is largely limited to here.
|
||||
public final FluidStack sigilFluid;
|
||||
|
||||
public ItemSigilFluidBase(String name, int lpUsed, FluidStack fluid)
|
||||
{
|
||||
super(name, lpUsed);
|
||||
sigilFluid = fluid;
|
||||
}
|
||||
|
||||
public ItemSigilFluidBase(String name, FluidStack fluid)
|
||||
{
|
||||
super(name);
|
||||
sigilFluid = fluid;
|
||||
}
|
||||
|
||||
public ItemSigilFluidBase(String name)
|
||||
{
|
||||
super(name);
|
||||
sigilFluid = null;
|
||||
}
|
||||
|
||||
// The following are handler functions for fluids, all genericized.
|
||||
// They're all based off of the Forge FluidUtil methods, but directly taking the
|
||||
// sigilFluid constant instead of getting an argument.
|
||||
|
||||
/*
|
||||
* Gets a fluid handler for the targeted block and siding. Works for both tile
|
||||
* entity liquid containers and fluid blocks. This one is literally identical to
|
||||
* the FluidUtil method of the same signature.
|
||||
*/
|
||||
@Nullable
|
||||
protected IFluidHandler getFluidHandler(World world, BlockPos blockPos, @Nullable Direction side)
|
||||
{
|
||||
BlockState state = world.getBlockState(blockPos);
|
||||
Block block = state.getBlock();
|
||||
BucketItem b;
|
||||
System.out.println(block);
|
||||
IFluidHandler targetFluidHandler = FluidUtil.getFluidHandler(world, blockPos, side).orElse(null);
|
||||
System.out.println(targetFluidHandler);
|
||||
|
||||
if (targetFluidHandler == null)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
return targetFluidHandler;
|
||||
// if (block instanceof IFluidBlock)
|
||||
// return new FluidBlockWrapper((IFluidBlock) block, world, blockPos);
|
||||
// else if (block instanceof BlockLiquid)
|
||||
// return new BlockLiquidWrapper((BlockLiquid) block, world, blockPos);
|
||||
// return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tries to insert fluid into a fluid handler. If doTransfer is false, only
|
||||
* simulate the transfer. If true, actually do so. Returns true if the transfer
|
||||
* is successful, false otherwise.
|
||||
*/
|
||||
protected boolean tryInsertSigilFluid(IFluidHandler destination, boolean doTransfer)
|
||||
{
|
||||
if (destination == null)
|
||||
return false;
|
||||
return destination.fill(sigilFluid, doTransfer ? FluidAction.EXECUTE : FluidAction.SIMULATE) > 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tries basically the oppostive of the above, removing fluids instead of adding
|
||||
* them
|
||||
*/
|
||||
protected boolean tryRemoveFluid(IFluidHandler source, int amount, boolean doTransfer)
|
||||
{
|
||||
if (source == null)
|
||||
return false;
|
||||
return source.drain(amount, doTransfer ? FluidAction.EXECUTE : FluidAction.SIMULATE) != null;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tries to place a fluid block in the world. Returns true if successful,
|
||||
* otherwise false. This is the big troublesome one, oddly enough. It's
|
||||
* genericized in case anyone wants to create variant sigils with weird fluids.
|
||||
*/
|
||||
protected boolean tryPlaceSigilFluid(PlayerEntity player, World world, BlockPos blockPos)
|
||||
{
|
||||
BlockState state = sigilFluid.getFluid().getAttributes().getBlock(world, blockPos, sigilFluid.getFluid().getDefaultState());
|
||||
BlockWrapper wrapper = new BlockWrapper(state, world, blockPos);
|
||||
return wrapper.fill(sigilFluid, FluidAction.EXECUTE) > 0;
|
||||
// // Make sure world coordinants are valid
|
||||
// if (world == null || blockPos == null)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// // Make sure fluid is placeable
|
||||
// Fluid fluid = sigilFluid.getFluid();
|
||||
// if (!fluid.getAttributes().canBePlacedInWorld(world, blockPos, sigilFluid))
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Check if the block is an air block or otherwise replaceable
|
||||
// BlockState state = world.getBlockState(blockPos);
|
||||
// Material mat = state.getMaterial();
|
||||
// boolean isDestSolid = mat.isSolid();
|
||||
// boolean isDestReplaceable = state.getBlock().isReplaceable(state, fluid);
|
||||
// if (!world.isAirBlock(blockPos) && isDestSolid && !isDestReplaceable)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
//// // If the fluid vaporizes, this exists here in the lava sigil solely so the code
|
||||
//// // is usable for other fluids
|
||||
//// if (world.provider.doesWaterVaporize() && fluid.doesVaporize(sigilFluid))
|
||||
//// {
|
||||
//// fluid.vaporize(player, world, blockPos, sigilFluid);
|
||||
//// return true;
|
||||
//// }
|
||||
//
|
||||
// // Finally we've done enough checking to make sure everything at the end is
|
||||
// // safe, let's place some fluid.
|
||||
// IFluidHandler handler;
|
||||
// Block block = fluid.getAttributes().getStateForPlacement(world, blockPos, sigilFluid).getBlockState().getBlock();
|
||||
// if (block instanceof IFluidBlock)
|
||||
// {
|
||||
// handler = new FluidBlockWrapper((IFluidBlock) block, world, blockPos);
|
||||
// } else if (block instanceof BlockLiquid)
|
||||
// handler = new BlockLiquidWrapper((BlockLiquid) block, world, blockPos);
|
||||
// else
|
||||
// handler = new BlockWrapper(block, world, blockPos);
|
||||
// return tryInsertSigilFluid(handler, true);
|
||||
//// return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.enchantment.FrostWalkerEnchantment;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilFrost extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilFrost()
|
||||
{
|
||||
super("frost", 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
FrostWalkerEnchantment.freezeNearby(player, world, player.getPosition(), 1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilGreenGrove extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilGreenGrove()
|
||||
{
|
||||
super("green_grove", 150);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSigilUse(ItemStack stack, PlayerEntity player, World world, BlockPos blockPos, Direction side, Vector3d vec)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return false;
|
||||
|
||||
if (NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()
|
||||
&& applyBonemeal(stack, world, blockPos, player))
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
world.playEvent(2005, blockPos, 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World worldIn, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
int range = 3;
|
||||
int verticalRange = 2;
|
||||
int posX = (int) Math.round(player.getPosX() - 0.5f);
|
||||
int posY = (int) player.getPosY();
|
||||
int posZ = (int) Math.round(player.getPosZ() - 0.5f);
|
||||
if (worldIn instanceof ServerWorld)
|
||||
{
|
||||
ServerWorld serverWorld = (ServerWorld) worldIn;
|
||||
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);
|
||||
BlockState state = worldIn.getBlockState(blockPos);
|
||||
|
||||
// if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state))
|
||||
{
|
||||
if (state.getBlock() instanceof IGrowable)
|
||||
{
|
||||
if (worldIn.rand.nextInt(50) == 0)
|
||||
{
|
||||
BlockState preBlockState = worldIn.getBlockState(blockPos);
|
||||
((IGrowable) state.getBlock()).grow(serverWorld, worldIn.rand, blockPos, state);
|
||||
|
||||
BlockState newState = worldIn.getBlockState(blockPos);
|
||||
if (!newState.equals(preBlockState) && !worldIn.isRemote)
|
||||
worldIn.playEvent(2005, blockPos, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static boolean applyBonemeal(ItemStack stack, World worldIn, BlockPos pos, PlayerEntity player)
|
||||
{
|
||||
BlockState blockstate = worldIn.getBlockState(pos);
|
||||
int hook = net.minecraftforge.event.ForgeEventFactory.onApplyBonemeal(player, worldIn, pos, blockstate, stack);
|
||||
if (hook != 0)
|
||||
return hook > 0;
|
||||
if (blockstate.getBlock() instanceof IGrowable)
|
||||
{
|
||||
IGrowable igrowable = (IGrowable) blockstate.getBlock();
|
||||
if (igrowable.canGrow(worldIn, pos, blockstate, worldIn.isRemote))
|
||||
{
|
||||
if (worldIn instanceof ServerWorld)
|
||||
{
|
||||
if (igrowable.canUseBonemeal(worldIn, worldIn.rand, pos, blockstate))
|
||||
{
|
||||
igrowable.grow((ServerWorld) worldIn, worldIn.rand, pos, blockstate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilLava extends ItemSigilFluidBase
|
||||
{
|
||||
public ItemSigilLava()
|
||||
{
|
||||
super("lava", 1000, new FluidStack(Fluids.LAVA, 10000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand 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.resultFail(stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
RayTraceResult rayTrace = rayTrace(world, player, RayTraceContext.FluidMode.NONE);
|
||||
|
||||
if (rayTrace == null || rayTrace.getType() != RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
return ActionResult.resultFail(stack);
|
||||
}
|
||||
|
||||
BlockRayTraceResult blockRayTrace = (BlockRayTraceResult) rayTrace;
|
||||
BlockPos blockPos = blockRayTrace.getPos();
|
||||
Direction sideHit = blockRayTrace.getFace();
|
||||
BlockPos blockpos1 = blockPos.offset(sideHit);
|
||||
|
||||
if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockpos1, sideHit, stack))
|
||||
{
|
||||
|
||||
// Case for if block at blockPos is a fluid handler like a tank
|
||||
// Try to put fluid into tank
|
||||
IFluidHandler destination = getFluidHandler(world, blockPos, null);
|
||||
if (destination != null && tryInsertSigilFluid(destination, false)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
boolean result = tryInsertSigilFluid(destination, true);
|
||||
if (result)
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
// Do the same as above, but use sidedness to interact with the fluid handler.
|
||||
IFluidHandler destinationSide = getFluidHandler(world, blockPos, sideHit);
|
||||
if (destinationSide != null && tryInsertSigilFluid(destinationSide, false)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
boolean result = tryInsertSigilFluid(destinationSide, true);
|
||||
if (result)
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
|
||||
// Case for if block at blockPos is not a tank
|
||||
// Place fluid in world
|
||||
if (destination == null && destinationSide == null)
|
||||
{
|
||||
BlockPos targetPos = blockPos.offset(sideHit);
|
||||
if (tryPlaceSigilFluid(player, world, targetPos)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.item.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.item.ItemEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilMagnetism extends ItemSigilToggleableBase
|
||||
{
|
||||
public ItemSigilMagnetism()
|
||||
{
|
||||
super("magnetism", 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSigilUpdate(ItemStack stack, World world, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (PlayerHelper.isFakePlayer(player))
|
||||
return;
|
||||
|
||||
int range = 5;
|
||||
int verticalRange = 5;
|
||||
float posX = Math.round(player.getPosX());
|
||||
float posY = (float) (player.getPosY() - player.getEyeHeight());
|
||||
float posZ = Math.round(player.getPosZ());
|
||||
List<ItemEntity> entities = player.getEntityWorld().getEntitiesWithinAABB(ItemEntity.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<ExperienceOrbEntity> xpOrbs = player.getEntityWorld().getEntitiesWithinAABB(ExperienceOrbEntity.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 (ItemEntity entity : entities)
|
||||
{
|
||||
if (entity != null && !world.isRemote && entity.isAlive())
|
||||
{
|
||||
entity.onCollideWithPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
for (ExperienceOrbEntity xpOrb : xpOrbs)
|
||||
{
|
||||
if (xpOrb != null && !world.isRemote)
|
||||
{
|
||||
xpOrb.onCollideWithPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.common.item.ItemSigil;
|
||||
import wayoftime.bloodmagic.core.data.Binding;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.IActivatable;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.helper.NBTHelper;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
/**
|
||||
* Base class for all toggleable sigils.
|
||||
*/
|
||||
public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
||||
{
|
||||
|
||||
public ItemSigilToggleable(Properties property, int lpUsed)
|
||||
{
|
||||
super(property, lpUsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getActivated(ItemStack stack)
|
||||
{
|
||||
return !stack.isEmpty() && NBTHelper.checkNBT(stack).getTag().getBoolean(Constants.NBT.ACTIVATED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack setActivatedState(ItemStack stack, boolean activated)
|
||||
{
|
||||
if (!stack.isEmpty())
|
||||
{
|
||||
NBTHelper.checkNBT(stack).getTag().putBoolean(Constants.NBT.ACTIVATED, activated);
|
||||
return stack;
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand 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.resultFail(stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
if (player.isSneaking())
|
||||
setActivatedState(stack, !getActivated(stack));
|
||||
if (getActivated(stack))
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUse(ItemUseContext context)
|
||||
{
|
||||
World world = context.getWorld();
|
||||
BlockPos blockpos = context.getPos();
|
||||
|
||||
PlayerEntity player = context.getPlayer();
|
||||
ItemStack stack = context.getItem();
|
||||
if (stack.getItem() instanceof ISigil.Holding)
|
||||
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||
|
||||
Binding binding = getBinding(stack);
|
||||
if (binding == null || player.isSneaking()) // Make sure Sigils are bound before handling. Also ignores while
|
||||
// toggling state
|
||||
return ActionResultType.PASS;
|
||||
|
||||
return onSigilUse(stack, player, world, blockpos, context.getFace(), context.getHitVec())
|
||||
? ActionResultType.SUCCESS
|
||||
: ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
public boolean onSigilUse(ItemStack itemStack, PlayerEntity player, World world, BlockPos blockPos, Direction side, Vector3d hitVec)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
|
||||
{
|
||||
if (!worldIn.isRemote && entityIn instanceof PlayerEntity && getActivated(stack))
|
||||
{
|
||||
if (entityIn.ticksExisted % 100 == 0)
|
||||
{
|
||||
if (!NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage((PlayerEntity) entityIn, SoulTicket.item(stack, worldIn, entityIn, getLpUsed())).isSuccess())
|
||||
{
|
||||
setActivatedState(stack, false);
|
||||
}
|
||||
}
|
||||
|
||||
onSigilUpdate(stack, worldIn, (PlayerEntity) entityIn, itemSlot, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSigilUpdate(ItemStack stack, World world, PlayerEntity player, int itemSlot, boolean isSelected)
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
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;
|
||||
|
||||
public class ItemSigilToggleableBase extends ItemSigilToggleable// implements IMeshProvider
|
||||
{
|
||||
protected final String tooltipBase;
|
||||
private final String name;
|
||||
|
||||
public ItemSigilToggleableBase(String name, int lpUsed)
|
||||
{
|
||||
super(new Item.Properties().maxStackSize(1).group(BloodMagic.TAB), lpUsed);
|
||||
|
||||
this.name = name;
|
||||
this.tooltipBase = "tooltip.bloodmagic.sigil." + name + ".";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World world, List<ITextComponent> tooltip, ITooltipFlag flag)
|
||||
{
|
||||
super.addInformation(stack, world, tooltip, flag);
|
||||
if (!stack.hasTag())
|
||||
return;
|
||||
|
||||
tooltip.add(new TranslationTextComponent("tooltip.bloodmagic." + (getActivated(stack) ? "activated"
|
||||
: "deactivated")));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public ItemMeshDefinition getMeshDefinition()
|
||||
// {
|
||||
// return new CustomMeshDefinitionActivatable("sigil_" + name.toLowerCase(Locale.ROOT));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void gatherVariants(Consumer<String> variants)
|
||||
// {
|
||||
// variants.accept("active=false");
|
||||
// variants.accept("active=true");
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.IBucketPickupHandler;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilVoid extends ItemSigilFluidBase
|
||||
{
|
||||
public ItemSigilVoid()
|
||||
{
|
||||
super("void", 50, new FluidStack(Fluids.EMPTY, 1000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand 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.resultFail(stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
RayTraceResult rayTrace = rayTrace(world, player, RayTraceContext.FluidMode.SOURCE_ONLY);
|
||||
|
||||
if (rayTrace == null || rayTrace.getType() != RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
return ActionResult.resultFail(stack);
|
||||
}
|
||||
|
||||
BlockRayTraceResult blockRayTrace = (BlockRayTraceResult) rayTrace;
|
||||
BlockPos blockPos = blockRayTrace.getPos();
|
||||
Direction sideHit = blockRayTrace.getFace();
|
||||
|
||||
if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockPos, sideHit, stack))
|
||||
{
|
||||
BlockState blockState = world.getBlockState(blockPos);
|
||||
if (blockState.getBlock() instanceof IBucketPickupHandler)
|
||||
{
|
||||
if (NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
((IBucketPickupHandler) blockState.getBlock()).pickupFluid(world, blockPos, blockState);
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
}
|
||||
// Void is simpler than the other fluid sigils, because getFluidHandler grabs
|
||||
// fluid blocks just fine
|
||||
// So extract from fluid tanks with a null side; or drain fluid blocks.
|
||||
// IFluidHandler destination = getFluidHandler(world, blockPos, sideHit);
|
||||
// if (destination != null && tryRemoveFluid(destination, 1000, false)
|
||||
// && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
// {
|
||||
// if (tryRemoveFluid(destination, 1000, true))
|
||||
// return ActionResult.resultSuccess(stack);
|
||||
// }
|
||||
// // Do the same as above, but use sidedness to interact with the fluid handler.
|
||||
// IFluidHandler destinationSide = getFluidHandler(world, blockPos, sideHit);
|
||||
// if (destinationSide != null && tryRemoveFluid(destinationSide, 1000, false)
|
||||
// && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
// {
|
||||
// if (tryRemoveFluid(destinationSide, 1000, true))
|
||||
// return ActionResult.resultSuccess(stack);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package wayoftime.bloodmagic.common.item.sigil;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CauldronBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceContext;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import wayoftime.bloodmagic.core.data.SoulTicket;
|
||||
import wayoftime.bloodmagic.iface.ISigil;
|
||||
import wayoftime.bloodmagic.util.helper.NetworkHelper;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerHelper;
|
||||
|
||||
public class ItemSigilWater extends ItemSigilFluidBase
|
||||
{
|
||||
public ItemSigilWater()
|
||||
{
|
||||
super("water", 100, new FluidStack(Fluids.WATER, 10000));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand 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.resultFail(stack);
|
||||
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
RayTraceResult rayTrace = rayTrace(world, player, RayTraceContext.FluidMode.NONE);
|
||||
|
||||
if (rayTrace == null || rayTrace.getType() != RayTraceResult.Type.BLOCK)
|
||||
{
|
||||
return ActionResult.resultFail(stack);
|
||||
}
|
||||
|
||||
BlockRayTraceResult blockRayTrace = (BlockRayTraceResult) rayTrace;
|
||||
BlockPos blockPos = blockRayTrace.getPos();
|
||||
Direction sideHit = blockRayTrace.getFace();
|
||||
BlockPos blockpos1 = blockPos.offset(sideHit);
|
||||
|
||||
if (world.isBlockModifiable(player, blockPos) && player.canPlayerEdit(blockpos1, sideHit, stack))
|
||||
{
|
||||
|
||||
// Case for if block at blockPos is a fluid handler like a tank
|
||||
// Try to put fluid into tank
|
||||
IFluidHandler destination = getFluidHandler(world, blockPos, null);
|
||||
if (destination != null && tryInsertSigilFluid(destination, false)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
boolean result = tryInsertSigilFluid(destination, true);
|
||||
if (result)
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
// Do the same as above, but use sidedness to interact with the fluid handler.
|
||||
IFluidHandler destinationSide = getFluidHandler(world, blockPos, sideHit);
|
||||
if (destinationSide != null && tryInsertSigilFluid(destinationSide, false)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
boolean result = tryInsertSigilFluid(destinationSide, true);
|
||||
if (result)
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
|
||||
// Special vanilla cauldron handling, yay.
|
||||
if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
world.setBlockState(blockPos, Blocks.CAULDRON.getDefaultState().with(CauldronBlock.LEVEL, 3));
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
|
||||
// Case for if block at blockPos is not a tank
|
||||
// Place fluid in world
|
||||
if (destination == null && destinationSide == null)
|
||||
{
|
||||
BlockPos targetPos = blockPos.offset(sideHit);
|
||||
if (tryPlaceSigilFluid(player, world, targetPos)
|
||||
&& NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess())
|
||||
{
|
||||
return ActionResult.resultSuccess(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.onItemRightClick(world, player, hand);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
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);
|
||||
// }
|
||||
|
||||
}
|
|
@ -0,0 +1,503 @@
|
|||
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.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.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 Item 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(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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,260 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue