From b441e7fc1e0ce7587d70ae140c83681933994371 Mon Sep 17 00:00:00 2001 From: Arcaratus Date: Tue, 7 Aug 2018 18:27:12 -0400 Subject: [PATCH] SoulTicket internal implementation (#1372) * Fix the Blood Tank BB * Add modid to command localizations to prevent conflicts * Fixed the items not being drawn on the right Y-level for the Sigil of Holding HUD Corrected localizations of other lang files * SoulTicket internal implementation * do what TehNut says * implement hashCode() * Fix toggleable sigils draining on r-click when it shouldn't Also moved the ItemSigil and ItemSigilToggleable to the sigil package (why wasn't it there???) --- .../bloodmagic/altar/BloodAltar.java | 3 +- .../command/sub/SubCommandNetwork.java | 5 +- .../bloodmagic/core/data/SoulNetwork.java | 15 ++++++ .../bloodmagic/core/data/SoulTicket.java | 52 +++++++++++++++++++ .../WayofTime/bloodmagic/iface/ISigil.java | 2 +- .../bloodmagic/item/ItemBloodOrb.java | 5 +- .../bloodmagic/item/ItemBoundAxe.java | 3 +- .../bloodmagic/item/ItemBoundPickaxe.java | 7 ++- .../bloodmagic/item/ItemBoundShovel.java | 7 ++- .../bloodmagic/item/ItemBoundSword.java | 11 ++-- .../bloodmagic/item/ItemBoundTool.java | 3 +- .../bloodmagic/item/ItemLavaCrystal.java | 6 ++- .../item/armour/ItemLivingArmour.java | 3 +- .../item/{ => sigil}/ItemSigil.java | 2 +- .../bloodmagic/item/sigil/ItemSigilAir.java | 10 ++-- .../bloodmagic/item/sigil/ItemSigilBase.java | 1 - .../item/sigil/ItemSigilBloodLight.java | 19 +++---- .../item/sigil/ItemSigilDivination.java | 6 +-- .../item/sigil/ItemSigilGreenGrove.java | 4 +- .../bloodmagic/item/sigil/ItemSigilLava.java | 10 ++-- .../item/sigil/ItemSigilSuppression.java | 1 - .../item/{ => sigil}/ItemSigilToggleable.java | 9 ++-- .../item/sigil/ItemSigilToggleableBase.java | 1 - .../item/sigil/ItemSigilTransposition.java | 7 ++- .../bloodmagic/item/sigil/ItemSigilVoid.java | 14 +++-- .../bloodmagic/item/sigil/ItemSigilWater.java | 7 +-- .../bloodmagic/ritual/IMasterRitualStone.java | 5 ++ .../bloodmagic/ritual/portal/Teleports.java | 24 +++++---- .../ritual/types/RitualAltarBuilder.java | 8 +-- .../ritual/types/RitualAnimalGrowth.java | 2 +- .../ritual/types/RitualCobblestone.java | 2 +- .../ritual/types/RitualCrushing.java | 4 +- .../ritual/types/RitualCrystalHarvest.java | 2 +- .../ritual/types/RitualEllipsoid.java | 8 +-- .../ritual/types/RitualExpulsion.java | 2 +- .../ritual/types/RitualFeatheredKnife.java | 2 +- .../ritual/types/RitualFelling.java | 2 +- .../ritual/types/RitualForsakenSoul.java | 2 +- .../ritual/types/RitualFullStomach.java | 2 +- .../ritual/types/RitualGreenGrove.java | 2 +- .../ritual/types/RitualHarvest.java | 2 +- .../ritual/types/RitualJumping.java | 2 +- .../bloodmagic/ritual/types/RitualLava.java | 2 +- .../ritual/types/RitualMagnetic.java | 2 +- .../bloodmagic/ritual/types/RitualMeteor.java | 2 +- .../bloodmagic/ritual/types/RitualPlacer.java | 2 +- .../bloodmagic/ritual/types/RitualPump.java | 2 +- .../ritual/types/RitualRegeneration.java | 2 +- .../bloodmagic/ritual/types/RitualWater.java | 2 +- .../ritual/types/RitualWellOfSuffering.java | 2 +- .../bloodmagic/ritual/types/RitualZephyr.java | 2 +- .../bloodmagic/tile/TileAlchemyTable.java | 33 ++++++------ .../tile/TileImperfectRitualStone.java | 5 +- .../tile/TileMasterRitualStone.java | 2 +- .../bloodmagic/tile/TileTeleposer.java | 5 +- .../bloodmagic/util/helper/NetworkHelper.java | 10 ++-- 56 files changed, 210 insertions(+), 147 deletions(-) rename src/main/java/WayofTime/bloodmagic/item/{ => sigil}/ItemSigil.java (95%) rename src/main/java/WayofTime/bloodmagic/item/{ => sigil}/ItemSigilToggleable.java (89%) diff --git a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java index 0a6fcdb9..8df2775c 100644 --- a/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java +++ b/src/main/java/WayofTime/bloodmagic/altar/BloodAltar.java @@ -5,6 +5,7 @@ import WayofTime.bloodmagic.api.impl.BloodMagicAPI; import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar; import WayofTime.bloodmagic.block.enums.BloodRuneType; import WayofTime.bloodmagic.core.data.Binding; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.iface.IBindable; import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.orb.BloodOrb; @@ -365,7 +366,7 @@ public class BloodAltar implements IFluidHandler if (fluid != null && fluid.amount >= 1) { int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? orb.getFillRate() * (1 + consumptionMultiplier) : orb.getFillRate()), fluid.amount); - int drain = NetworkHelper.getSoulNetwork(binding).add(liquidDrained, (int) (orb.getCapacity() * this.orbCapacityMultiplier)); + int drain = NetworkHelper.getSoulNetwork(binding).add(SoulTicket.block(world, pos, liquidDrained), (int) (orb.getCapacity() * this.orbCapacityMultiplier)); fluid.amount = fluid.amount - drain; if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer) diff --git a/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandNetwork.java b/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandNetwork.java index f5a279d8..12db2d7f 100644 --- a/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandNetwork.java +++ b/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandNetwork.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.command.sub; import WayofTime.bloodmagic.core.data.SoulNetwork; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.command.CommandBloodMagic; import WayofTime.bloodmagic.util.Utils; @@ -66,7 +67,7 @@ public class SubCommandNetwork extends CommandBase { if (args.length == 3) { if (Utils.isInteger(args[2])) { int amount = Integer.parseInt(args[2]); - NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, amount); + NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.command(sender, "syphon", amount)); CommandBloodMagic.displaySuccessString(sender, "commands.bloodmagic.network.syphon.success", amount, player.getDisplayName().getFormattedText()); } else { CommandBloodMagic.displayErrorString(sender, "commands.bloodmagic.error.arg.invalid"); @@ -90,7 +91,7 @@ public class SubCommandNetwork extends CommandBase { if (Utils.isInteger(args[2])) { int amount = Integer.parseInt(args[2]); int maxOrb = NetworkHelper.getMaximumForTier(network.getOrbTier()); - CommandBloodMagic.displaySuccessString(sender, "commands.bloodmagic.network.add.success", network.add(amount, maxOrb), player.getDisplayName().getFormattedText()); + CommandBloodMagic.displaySuccessString(sender, "commands.bloodmagic.network.add.success", network.add(SoulTicket.command(sender, "add", amount), maxOrb), player.getDisplayName().getFormattedText()); } else { CommandBloodMagic.displayErrorString(sender, "commands.bloodmagic.error.arg.invalid"); } diff --git a/src/main/java/WayofTime/bloodmagic/core/data/SoulNetwork.java b/src/main/java/WayofTime/bloodmagic/core/data/SoulNetwork.java index d0686067..4ba15109 100644 --- a/src/main/java/WayofTime/bloodmagic/core/data/SoulNetwork.java +++ b/src/main/java/WayofTime/bloodmagic/core/data/SoulNetwork.java @@ -33,6 +33,10 @@ public class SoulNetwork implements INBTSerializable { ticketHistory = EvictingQueue.create(16); } + public void clear() { + ticketHistory.clear(); + } + public int add(SoulTicket ticket, int maximum) { SoulNetworkEvent.Fill event = new SoulNetworkEvent.Fill(this, ticket, maximum); if (MinecraftForge.EVENT_BUS.post(event)) @@ -46,7 +50,11 @@ public class SoulNetwork implements INBTSerializable { int newEss = Math.min(event.getMaximum(), currEss + event.getTicket().getAmount()); setCurrentEssence(newEss); + if (ticketHistory.contains(ticket)) + ticketHistory.remove(ticket); // "Pops" the existing ticket to the top of the queue + ticketHistory.add(ticket); + return newEss - currEss; } @@ -78,6 +86,9 @@ public class SoulNetwork implements INBTSerializable { int syphon = event.getTicket().getAmount(); if (getCurrentEssence() >= syphon) { setCurrentEssence(getCurrentEssence() - syphon); + if (ticketHistory.contains(ticket)) + ticketHistory.remove(ticket); + ticketHistory.add(ticket); return syphon; } @@ -107,7 +118,11 @@ public class SoulNetwork implements INBTSerializable { if (drainAmount <= 0 || event.shouldDamage()) hurtPlayer(user, event.getTicket().getAmount()); + if (ticketHistory.contains(ticket)) + ticketHistory.remove(ticket); + ticketHistory.add(ticket); + return BooleanResult.newResult(true, event.getTicket().getAmount()); } diff --git a/src/main/java/WayofTime/bloodmagic/core/data/SoulTicket.java b/src/main/java/WayofTime/bloodmagic/core/data/SoulTicket.java index 1f9c4c60..6d209dd5 100644 --- a/src/main/java/WayofTime/bloodmagic/core/data/SoulTicket.java +++ b/src/main/java/WayofTime/bloodmagic/core/data/SoulTicket.java @@ -1,7 +1,12 @@ package WayofTime.bloodmagic.core.data; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; +import net.minecraft.world.World; public class SoulTicket { @@ -30,4 +35,51 @@ public class SoulTicket { public int getAmount() { return amount; } + + /** + * @return A description in the format block|dimensionID|pos + */ + public static SoulTicket block(World world, BlockPos pos, int amount) { + return new SoulTicket(new TextComponentString("block|" + world.provider.getDimension() + "|" + pos.toLong()), amount); + } + + /** + * @return A description in the format item|item registry name|dimensionID|entityName|entityPos + */ + public static SoulTicket item(ItemStack itemStack, World world, Entity entity, int amount) { + return new SoulTicket(new TextComponentString("item|" + itemStack.getItem().getRegistryName() + "|" + world.provider.getDimension() + "|" + entity.getPersistentID()), amount); + } + + /** + * @return A description in the format item|item registry name|dimensionID|pos + */ + public static SoulTicket item(ItemStack itemStack, World world, BlockPos pos, int amount) { + return new SoulTicket(new TextComponentString("item|" + itemStack.getItem().getRegistryName() + "|" + world.provider.getDimension() + "|" + pos.toLong()), amount); + } + + /** + * @return A description in the format item|item registry name|dimensionID + */ + public static SoulTicket item(ItemStack itemStack, int amount) { + return new SoulTicket(new TextComponentString("item|" + itemStack.getItem().getRegistryName()), amount); + } + + public static SoulTicket command(ICommandSender sender, String command, int amount) { + return new SoulTicket(new TextComponentString("command|" + command + "|" + sender.getName()), amount); + } + + // TODO maybe make it check the amount?? + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o instanceof SoulTicket) + return ((SoulTicket) o).getDescription().equals(description); + + return false; + } + + @Override + public int hashCode() { + return description.hashCode(); + } } diff --git a/src/main/java/WayofTime/bloodmagic/iface/ISigil.java b/src/main/java/WayofTime/bloodmagic/iface/ISigil.java index 5912f52d..017df5c1 100644 --- a/src/main/java/WayofTime/bloodmagic/iface/ISigil.java +++ b/src/main/java/WayofTime/bloodmagic/iface/ISigil.java @@ -1,6 +1,6 @@ package WayofTime.bloodmagic.iface; -import WayofTime.bloodmagic.item.ItemSigil; +import WayofTime.bloodmagic.item.sigil.ItemSigil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java index c9e1b210..c8516244 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBloodOrb.java @@ -1,8 +1,7 @@ package WayofTime.bloodmagic.item; import WayofTime.bloodmagic.BloodMagic; -import WayofTime.bloodmagic.core.data.Binding; -import WayofTime.bloodmagic.core.data.SoulNetwork; +import WayofTime.bloodmagic.core.data.*; import WayofTime.bloodmagic.orb.BloodOrb; import WayofTime.bloodmagic.orb.IBloodOrb; import WayofTime.bloodmagic.util.helper.NetworkHelper; @@ -83,7 +82,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb { if (binding.getOwnerId().equals(player.getGameProfile().getId())) ownerNetwork.setOrbTier(orb.getTier()); - ownerNetwork.add(200, orb.getCapacity()); // Add LP to owner's network + 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); } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java index f4b092e0..14094b3d 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundAxe.java @@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item; import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.util.BlockStack; import WayofTime.bloodmagic.util.ItemStackWrapper; import WayofTime.bloodmagic.util.helper.NetworkHelper; @@ -100,7 +101,7 @@ public class ItemBoundAxe extends ItemBoundTool implements IMeshProvider { } } - NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, (int) (charge * charge * charge / 2.7)); + NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, (int) (charge * charge * charge / 2.7))); world.createExplosion(player, playerPos.getX(), playerPos.getY(), playerPos.getZ(), 0.1F, false); dropStacks(drops, world, playerPos.add(0, 1, 0)); } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java index 8e7da20c..68b37547 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundPickaxe.java @@ -2,12 +2,11 @@ package WayofTime.bloodmagic.item; import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.util.BlockStack; import WayofTime.bloodmagic.util.ItemStackWrapper; import WayofTime.bloodmagic.util.helper.NetworkHelper; -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; +import com.google.common.collect.*; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -113,7 +112,7 @@ public class ItemBoundPickaxe extends ItemBoundTool implements IMeshProvider { } } - NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, (int) (charge * charge * charge / 2.7)); + NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, (int) (charge * charge * charge / 2.7))); world.createExplosion(player, playerPos.getX(), playerPos.getY(), playerPos.getZ(), 0.5F, false); dropStacks(drops, world, playerPos.add(0, 1, 0)); } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java index a1426e9e..3634012d 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundShovel.java @@ -2,12 +2,11 @@ package WayofTime.bloodmagic.item; import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.util.BlockStack; import WayofTime.bloodmagic.util.ItemStackWrapper; import WayofTime.bloodmagic.util.helper.NetworkHelper; -import com.google.common.collect.HashMultiset; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; +import com.google.common.collect.*; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -99,7 +98,7 @@ public class ItemBoundShovel extends ItemBoundTool implements IMeshProvider { } } - NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, (int) (charge * charge * charge / 2.7)); + NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, (int) (charge * charge * charge / 2.7))); world.createExplosion(player, playerPos.getX(), playerPos.getY(), playerPos.getZ(), 0.5F, false); dropStacks(drops, world, playerPos.add(0, 1, 0)); } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java index 1c67b320..e9b30300 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundSword.java @@ -5,6 +5,7 @@ import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.core.data.Binding; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.iface.IActivatable; import WayofTime.bloodmagic.iface.IBindable; import WayofTime.bloodmagic.util.Utils; @@ -16,17 +17,13 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.*; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -71,7 +68,7 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable } if (entity instanceof EntityPlayer && getActivated(stack) && world.getTotalWorldTime() % 80 == 0) - NetworkHelper.getSoulNetwork(binding).syphonAndDamage((EntityPlayer) entity, 20); + NetworkHelper.getSoulNetwork(binding).syphonAndDamage((EntityPlayer) entity, SoulTicket.item(stack, world, entity, 20)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java index 4c39abdd..bdc791bf 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemBoundTool.java @@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.core.data.Binding; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.util.ItemStackWrapper; import WayofTime.bloodmagic.event.BoundToolEvent; import WayofTime.bloodmagic.iface.IActivatable; @@ -93,7 +94,7 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable { } if (entity instanceof EntityPlayer && getActivated(stack) && world.getTotalWorldTime() % 80 == 0) - NetworkHelper.getSoulNetwork(binding).syphonAndDamage((EntityPlayer) entity, 20); + NetworkHelper.getSoulNetwork(binding).syphonAndDamage((EntityPlayer) entity, SoulTicket.item(stack, world, entity, 20)); } protected int getHeldDownCount(ItemStack stack) { diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java index 3e3c07ba..ed4153a0 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemLavaCrystal.java @@ -3,6 +3,7 @@ package WayofTime.bloodmagic.item; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.core.data.Binding; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; @@ -14,6 +15,7 @@ import net.minecraft.potion.PotionEffect; import javax.annotation.Nonnull; import javax.annotation.Nullable; +// TODO: Make some hook somewhere that attaches the pos to the ticket otherwise the tickets are basically useless lmao public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvider { public ItemLavaCrystal() { @@ -25,7 +27,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvide public ItemStack getContainerItem(ItemStack stack) { Binding binding = getBinding(stack); if (binding != null) - NetworkHelper.getSoulNetwork(binding.getOwnerId()).syphon(25); + NetworkHelper.getSoulNetwork(binding.getOwnerId()).syphon(SoulTicket.item(stack, 25)); ItemStack returnStack = new ItemStack(this); returnStack.setTagCompound(stack.getTagCompound()); @@ -43,7 +45,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvide if (binding == null) return -1; - if (NetworkHelper.syphonFromContainer(stack, 25)) + if (NetworkHelper.syphonFromContainer(stack, SoulTicket.item(stack, 25))) return 200; else { EntityPlayer player = PlayerHelper.getPlayerFromUUID(binding.getOwnerId()); diff --git a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java index b976cb04..001b3264 100644 --- a/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java +++ b/src/main/java/WayofTime/bloodmagic/item/armour/ItemLivingArmour.java @@ -4,6 +4,7 @@ import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.core.data.SoulNetwork; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.item.types.ComponentTypes; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade; @@ -210,7 +211,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; SoulNetwork network = NetworkHelper.getSoulNetwork(player); - network.syphonAndDamage(player, damage * 100); + network.syphonAndDamage(player, SoulTicket.item(stack, entity.getEntityWorld(), entity, damage * 100)); } return; diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSigil.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigil.java similarity index 95% rename from src/main/java/WayofTime/bloodmagic/item/ItemSigil.java rename to src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigil.java index 605c4bdc..70be6e84 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSigil.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigil.java @@ -1,4 +1,4 @@ -package WayofTime.bloodmagic.item; +package WayofTime.bloodmagic.item.sigil; import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.iface.IBindable; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java index a8e50e25..da71b84d 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilAir.java @@ -1,21 +1,19 @@ package WayofTime.bloodmagic.item.sigil; +import WayofTime.bloodmagic.core.RegistrarBloodMagic; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.iface.ISentientSwordEffectProvider; import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.soul.EnumDemonWillType; import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper; -import WayofTime.bloodmagic.core.RegistrarBloodMagic; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; -import net.minecraft.util.SoundCategory; +import net.minecraft.util.*; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -51,7 +49,7 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP if (!world.isRemote) { if (!player.capabilities.isCreativeMode) - this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, getLpUsed())); + this.setUnusable(stack, !NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()); if (!unusable) player.fallDistance = 0; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java index c9f5747b..c62a8ca8 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBase.java @@ -3,7 +3,6 @@ package WayofTime.bloodmagic.item.sigil; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.core.data.Binding; -import WayofTime.bloodmagic.item.ItemSigil; import WayofTime.bloodmagic.util.helper.TextHelper; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import net.minecraft.client.util.ITooltipFlag; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java index 42b5f026..8c161786 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilBloodLight.java @@ -1,19 +1,16 @@ package WayofTime.bloodmagic.item.sigil; -import WayofTime.bloodmagic.core.data.SoulNetwork; -import WayofTime.bloodmagic.util.Constants; -import WayofTime.bloodmagic.iface.ISigil; -import WayofTime.bloodmagic.util.helper.NBTHelper; -import WayofTime.bloodmagic.util.helper.NetworkHelper; -import WayofTime.bloodmagic.util.helper.PlayerHelper; import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks; +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.*; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; @@ -56,7 +53,7 @@ public class ItemSigilBloodLight extends ItemSigilBase if (!world.isRemote) { SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack)); - network.syphonAndDamage(player, getLpUsed()); + network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())); } resetCooldown(stack); player.swingArm(hand); @@ -68,7 +65,7 @@ public class ItemSigilBloodLight extends ItemSigilBase { SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack)); world.spawnEntity(new EntityBloodLight(world, player)); - network.syphonAndDamage(player, getLpUsed()); + network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())); } resetCooldown(stack); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java index a9a4b26f..a25a5122 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilDivination.java @@ -3,15 +3,13 @@ package WayofTime.bloodmagic.item.sigil; 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.PlayerHelper; -import WayofTime.bloodmagic.util.ChatUtil; import com.google.common.collect.Lists; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; +import net.minecraft.util.*; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java index 02a8a4d7..8f479995 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilGreenGrove.java @@ -1,6 +1,8 @@ package WayofTime.bloodmagic.item.sigil; import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.core.data.SoulTicket; +import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper; import net.minecraft.block.IGrowable; import net.minecraft.block.state.IBlockState; @@ -24,7 +26,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase { if (PlayerHelper.isFakePlayer(player)) return false; - if (applyBonemeal(world, blockPos, player, stack)) { + if (NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess() && applyBonemeal(world, blockPos, player, stack)) { if (!world.isRemote) { world.playEvent(2005, blockPos, 0); } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java index b02e3f3c..6b044a6d 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilLava.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.item.sigil; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper; @@ -8,10 +9,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; @@ -59,7 +57,7 @@ public class ItemSigilLava extends ItemSigilBase { return super.onItemRightClick(world, player, hand); } - if (this.canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceLava(world, blockpos1)) { + if (canPlaceLava(world, blockpos1) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess() && tryPlaceLava(world, blockpos1)) { return super.onItemRightClick(world, player, hand); } } @@ -85,7 +83,7 @@ public class ItemSigilLava extends ItemSigilBase { FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000); int amount = handler.fill(fluid, false); - if (amount > 0 && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, getLpUsed())) { + if (amount > 0 && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) { handler.fill(fluid, true); return EnumActionResult.SUCCESS; } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java index 4b2d2180..16783af4 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilSuppression.java @@ -47,5 +47,4 @@ public class ItemSigilSuppression extends ItemSigilToggleableBase { } } } - } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemSigilToggleable.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleable.java similarity index 89% rename from src/main/java/WayofTime/bloodmagic/item/ItemSigilToggleable.java rename to src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleable.java index 9b9bbe27..4a354186 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemSigilToggleable.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleable.java @@ -1,6 +1,7 @@ -package WayofTime.bloodmagic.item; +package WayofTime.bloodmagic.item.sigil; import WayofTime.bloodmagic.core.data.Binding; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.iface.IActivatable; import WayofTime.bloodmagic.iface.ISigil; @@ -53,7 +54,7 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable { if (!world.isRemote && !isUnusable(stack)) { if (player.isSneaking()) setActivatedState(stack, !getActivated(stack)); - if (getActivated(stack) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) + if (getActivated(stack)) return super.onItemRightClick(world, player, hand); } @@ -70,7 +71,7 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable { if (binding == null || player.isSneaking()) // Make sure Sigils are bound before handling. Also ignores while toggling state return EnumActionResult.PASS; - return (NetworkHelper.getSoulNetwork(binding).syphonAndDamage(player, getLpUsed()) && onSigilUse(player.getHeldItem(hand), player, world, pos, side, hitX, hitY, hitZ)) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; + return onSigilUse(player.getHeldItem(hand), player, world, pos, side, hitX, hitY, hitZ) ? EnumActionResult.SUCCESS : EnumActionResult.FAIL; } public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ) { @@ -81,7 +82,7 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable { public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) { if (entityIn.ticksExisted % 100 == 0) { - if (!NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage((EntityPlayer) entityIn, getLpUsed())) { + if (!NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage((EntityPlayer) entityIn, SoulTicket.item(stack, worldIn, entityIn, getLpUsed())).isSuccess()) { setActivatedState(stack, false); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleableBase.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleableBase.java index 6aa74856..08fb9dff 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleableBase.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilToggleableBase.java @@ -4,7 +4,6 @@ import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; import WayofTime.bloodmagic.core.data.Binding; -import WayofTime.bloodmagic.item.ItemSigilToggleable; import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.util.ITooltipFlag; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTransposition.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTransposition.java index 6e3b00f4..4cba37ed 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTransposition.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilTransposition.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.item.sigil; import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper; @@ -12,9 +13,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTUtil; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityMobSpawner; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; @@ -89,7 +88,7 @@ public class ItemSigilTransposition extends ItemSigilBase { } stack.getTagCompound().setTag("stored", stored); - NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, cost); + NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, cost)); world.removeTileEntity(blockPos); world.setBlockToAir(blockPos); return EnumActionResult.SUCCESS; diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java index a2e20146..93796d8d 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilVoid.java @@ -1,16 +1,14 @@ package WayofTime.bloodmagic.item.sigil; import WayofTime.bloodmagic.core.data.SoulNetwork; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; @@ -56,7 +54,7 @@ public class ItemSigilVoid extends ItemSigilBase { return super.onItemRightClick(world, player, hand); } - if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) { + if (world.getBlockState(blockpos).getBlock().getMaterial(world.getBlockState(blockpos)).isLiquid() && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) { world.setBlockToAir(blockpos); return super.onItemRightClick(world, player, hand); } @@ -66,7 +64,7 @@ public class ItemSigilVoid extends ItemSigilBase { } if (!player.capabilities.isCreativeMode) - this.setUnusable(stack, !NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())); + setUnusable(stack, !NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()); } return super.onItemRightClick(world, player, hand); @@ -92,7 +90,7 @@ public class ItemSigilVoid extends ItemSigilBase { IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); FluidStack amount = handler.drain(1000, false); - if (amount != null && amount.amount > 0 && network.syphonAndDamage(player, getLpUsed())) { + if (amount != null && amount.amount > 0 && network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) { handler.drain(1000, true); return EnumActionResult.SUCCESS; } @@ -106,7 +104,7 @@ public class ItemSigilVoid extends ItemSigilBase { return EnumActionResult.FAIL; } - if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && network.syphonAndDamage(player, getLpUsed())) { + if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) { world.setBlockToAir(newPos); return EnumActionResult.SUCCESS; } diff --git a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java index 396c2aa5..5737fd32 100644 --- a/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java +++ b/src/main/java/WayofTime/bloodmagic/item/sigil/ItemSigilWater.java @@ -1,5 +1,6 @@ package WayofTime.bloodmagic.item.sigil; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper; @@ -54,7 +55,7 @@ public class ItemSigilWater extends ItemSigilBase { if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack)) return super.onItemRightClick(world, player, hand); - if (this.canPlaceWater(world, blockpos1) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, getLpUsed()) && this.tryPlaceWater(world, blockpos1)) + if (canPlaceWater(world, blockpos1) && NetworkHelper.getSoulNetwork(getBinding(stack)).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess() && tryPlaceWater(world, blockpos1)) return super.onItemRightClick(world, player, hand); } } @@ -78,7 +79,7 @@ public class ItemSigilWater extends ItemSigilBase { FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000); int amount = handler.fill(fluid, false); - if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) { + if (amount > 0 && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) { handler.fill(fluid, true); return EnumActionResult.SUCCESS; } @@ -86,7 +87,7 @@ public class ItemSigilWater extends ItemSigilBase { return EnumActionResult.FAIL; } - if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) { + if (world.getBlockState(blockPos).getBlock() == Blocks.CAULDRON && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed())).isSuccess()) { world.setBlockState(blockPos, Blocks.CAULDRON.getDefaultState().withProperty(BlockCauldron.LEVEL, 3)); return EnumActionResult.SUCCESS; } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/IMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/ritual/IMasterRitualStone.java index f6743a12..eb61019c 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/IMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/IMasterRitualStone.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.ritual; import WayofTime.bloodmagic.core.data.SoulNetwork; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.soul.EnumDemonWillType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -56,4 +57,8 @@ public interface IMasterRitualStone { boolean setBlockRangeByBounds(EntityPlayer player, String range, BlockPos offset1, BlockPos offset2); List getActiveWillConfig(); + + default SoulTicket ticket(int amount) { + return SoulTicket.block(getWorldObj(), getBlockPos(), amount); + } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java b/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java index 5e24db13..79902bc7 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java @@ -1,12 +1,11 @@ package WayofTime.bloodmagic.ritual.portal; -import WayofTime.bloodmagic.event.TeleposeEvent; import WayofTime.bloodmagic.core.data.SoulNetwork; +import WayofTime.bloodmagic.core.data.SoulTicket; +import WayofTime.bloodmagic.event.TeleposeEvent; import WayofTime.bloodmagic.teleport.Teleport; import WayofTime.bloodmagic.util.helper.NetworkHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; -import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.*; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.SoundEvents; @@ -15,6 +14,7 @@ import net.minecraft.network.play.server.SPacketUpdateHealth; import net.minecraft.server.MinecraftServer; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.common.MinecraftForge; @@ -49,10 +49,10 @@ public class Teleports { if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), entity.getEntityWorld(), new BlockPos(x, y, z)))) return; - network.syphon(getTeleportCost()); - EntityPlayerMP player = (EntityPlayerMP) entity; + network.syphon(ticket(entity.world, player, getTeleportCost())); + player.setPositionAndUpdate(x + 0.5, y + 0.5, z + 0.5); player.getEntityWorld().updateEntityWithOptionalForce(player, false); player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel())); @@ -70,10 +70,10 @@ public class Teleports { if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), entity.getEntityWorld(), new BlockPos(x, y, z)))) return; - network.syphon(getTeleportCost() / 10); - WorldServer world = (WorldServer) entity.getEntityWorld(); + network.syphon(ticket(world, entity, getTeleportCost() / 10)); + entity.setPosition(x + 0.5, y + 0.5, z + 0.5); entity.timeUntilPortal = 150; world.resetUpdateEntityTick(); @@ -128,7 +128,7 @@ public class Teleports { if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), newWorldServer, new BlockPos(x, y, z)))) return; - network.syphon(getTeleportCost()); + network.syphon(ticket(oldWorld, player, getTeleportCost())); player.changeDimension(newWorldID); //TODO: UNTESTED // server.getConfigurationManager().transferPlayerToDimension(player, newWorldID, new TeleporterBloodMagic(newWorldServer)); @@ -148,7 +148,7 @@ public class Teleports { if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), newWorldServer, new BlockPos(x, y, z)))) return; - network.syphon(getTeleportCost() / 10); + network.syphon(ticket(oldWorld, entity, getTeleportCost() / 10)); NBTTagCompound tag = new NBTTagCompound(); @@ -193,4 +193,8 @@ public class Teleports { return teleposer; } } + + public static SoulTicket ticket(World world, Entity entity, int amount) { + return new SoulTicket(new TextComponentString("teleport|" + world.provider.getDimension() + "|" + entity.getName() + "|" + entity.getPosition().toLong()), amount); + } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAltarBuilder.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAltarBuilder.java index 4c7783b4..1cf2f0ce 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAltarBuilder.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAltarBuilder.java @@ -58,7 +58,7 @@ public class RitualAltarBuilder extends Ritual { if (world.getBlockState(altarPos).getBlock().isReplaceable(world, altarPos) && hasItem(tileEntity, Item.getItemFromBlock(RegistrarBloodMagicBlocks.ALTAR), 0, true)) { world.setBlockState(altarPos, RegistrarBloodMagicBlocks.ALTAR.getDefaultState()); lightning(world, altarPos); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); } if (altarComponentsIterator.hasNext()) { @@ -72,7 +72,7 @@ public class RitualAltarBuilder extends Ritual { if (blockStack != null) { world.setBlockState(currentPos, blockStack.getState(), 3); lightning(world, currentPos); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); } break; } @@ -81,7 +81,7 @@ public class RitualAltarBuilder extends Ritual { if (blockStack != null) { world.setBlockState(currentPos, blockStack.getState(), 3); lightning(world, currentPos); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); } break; } @@ -90,7 +90,7 @@ public class RitualAltarBuilder extends Ritual { if (hasItem(tileEntity, Item.getItemFromBlock(blockStack.getBlock()), blockStack.getMeta(), true)) { world.setBlockState(currentPos, blockStack.getState(), 3); lightning(world, currentPos); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); } break; } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAnimalGrowth.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAnimalGrowth.java index 260447b2..401398cc 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAnimalGrowth.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAnimalGrowth.java @@ -161,7 +161,7 @@ public class RitualAnimalGrowth extends Ritual { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveDrain, true); } - masterRitualStone.getOwnerNetwork().syphon(totalGrowths * getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(totalGrowths * getRefreshCost())); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCobblestone.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCobblestone.java index ab8516e2..f9d0d6e9 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCobblestone.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCobblestone.java @@ -75,7 +75,7 @@ public class RitualCobblestone extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrushing.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrushing.java index 1ad10719..8f1a5855 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrushing.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrushing.java @@ -153,7 +153,7 @@ public class RitualCrushing extends Ritual { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, willDrain, true); corrosiveWill -= willDrain; - masterRitualStone.getOwnerNetwork().syphon(lpDrain); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(lpDrain)); currentEssence -= lpDrain; isBlockClaimed = true; @@ -211,7 +211,7 @@ public class RitualCrushing extends Ritual { } world.destroyBlock(newPos, false); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); hasOperated = true; if (consumeRawWill) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrystalHarvest.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrystalHarvest.java index 5f5e9be2..a28c8433 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrystalHarvest.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrystalHarvest.java @@ -54,7 +54,7 @@ public class RitualCrystalHarvest extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java index 74bbdaa8..636e5806 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java @@ -1,7 +1,6 @@ package WayofTime.bloodmagic.ritual.types; -import java.util.function.Consumer; - +import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.ritual.*; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -14,7 +13,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; -import WayofTime.bloodmagic.BloodMagic; + +import java.util.function.Consumer; @RitualRegister("ellipsoid") public class RitualEllipsoid extends Ritual @@ -133,7 +133,7 @@ public class RitualEllipsoid extends Ritual itemHandler.extractItem(blockSlot, 1, false); tileInventory.markDirty(); //TODO: - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); k++; this.currentPos = new BlockPos(i, j, k); return; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualExpulsion.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualExpulsion.java index 393645d2..1294ea4f 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualExpulsion.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualExpulsion.java @@ -75,7 +75,7 @@ public class RitualExpulsion extends Ritual { continue; if (teleportRandomly(player, teleportDistance)) - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * 1000); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * 1000)); } whitelist.clear(); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFeatheredKnife.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFeatheredKnife.java index ddddf20b..eae72593 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFeatheredKnife.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFeatheredKnife.java @@ -169,7 +169,7 @@ public class RitualFeatheredKnife extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects)); if (totalEffects > 0 && consumeRawWill) { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWillDrain, true); } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFelling.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFelling.java index 749ff388..6e1f01e1 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFelling.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFelling.java @@ -67,7 +67,7 @@ public class RitualFelling extends Ritual { } if (blockPosIterator.hasNext() && tileInventory != null) { - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); currentPos = blockPosIterator.next(); IItemHandler inventory = Utils.getInventory(tileInventory, EnumFacing.DOWN); placeInInventory(world.getBlockState(currentPos), world, currentPos, inventory); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualForsakenSoul.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualForsakenSoul.java index c56ff474..0e3207bc 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualForsakenSoul.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualForsakenSoul.java @@ -141,7 +141,7 @@ public class RitualForsakenSoul extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects)); } /** diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFullStomach.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFullStomach.java index 0b4153a6..b803b810 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFullStomach.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFullStomach.java @@ -80,7 +80,7 @@ public class RitualFullStomach extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualGreenGrove.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualGreenGrove.java index ccbfca81..d8cdf397 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualGreenGrove.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualGreenGrove.java @@ -194,7 +194,7 @@ public class RitualGreenGrove extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(totalGrowths * getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(totalGrowths * getRefreshCost())); } public double getPlantGrowthChanceForWill(double will) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualHarvest.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualHarvest.java index b04ba5b2..fed3bb5b 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualHarvest.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualHarvest.java @@ -62,7 +62,7 @@ public class RitualHarvest extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * harvested); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * harvested)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualJumping.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualJumping.java index 78c89219..975f84d7 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualJumping.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualJumping.java @@ -56,7 +56,7 @@ public class RitualJumping extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLava.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLava.java index ae953425..e7e064a8 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLava.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLava.java @@ -215,7 +215,7 @@ public class RitualLava extends Ritual { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrained, true); } - masterRitualStone.getOwnerNetwork().syphon(lpDrain); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(lpDrain)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMagnetic.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMagnetic.java index d5047838..cbd5cd20 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMagnetic.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMagnetic.java @@ -72,7 +72,7 @@ public class RitualMagnetic extends Ritual { ItemStack checkStack = state.getBlock().getPickBlock(state, null, world, newPos, null); if (isBlockOre(checkStack)) { Utils.swapLocations(world, newPos, world, replacement); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); k++; this.lastPos = new BlockPos(i, j, k); return; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMeteor.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMeteor.java index 0abb6a48..b9dbc916 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMeteor.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMeteor.java @@ -61,7 +61,7 @@ public class RitualMeteor extends Ritual { entityItem.setDead(); if (destructiveWill >= destructiveWillDrain && currentEssence >= 1000000000) { - masterRitualStone.getOwnerNetwork().syphon(1000000); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(1000000)); } else { masterRitualStone.setActive(false); } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPlacer.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPlacer.java index c421f794..90469c94 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPlacer.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPlacer.java @@ -67,7 +67,7 @@ public class RitualPlacer extends Ritual { world.setBlockState(blockPos, placeState); itemHandler.extractItem(invSlot, 1, false); tileEntity.markDirty(); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); break posLoop; // Break instead of return in case we add things later } } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPump.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPump.java index e7d6b74c..2fb5001a 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPump.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPump.java @@ -77,7 +77,7 @@ public class RitualPump extends Ritual { blockPosIterator = liquidsCache.iterator(); if (blockPosIterator.hasNext()) { Pair posInfo = blockPosIterator.next(); - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost())); fluidHandler.fill(posInfo.getRight(), true); world.setBlockState(posInfo.getLeft(), Blocks.STONE.getDefaultState()); world.notifyBlockUpdate(posInfo.getLeft(), tankState, tankState, 3); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualRegeneration.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualRegeneration.java index e851b8ad..1f431459 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualRegeneration.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualRegeneration.java @@ -140,7 +140,7 @@ public class RitualRegeneration extends Ritual { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true); } - masterRitualStone.getOwnerNetwork().syphon(totalCost); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(totalCost)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWater.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWater.java index c63b3b6d..c4f7d6b1 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWater.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWater.java @@ -44,7 +44,7 @@ public class RitualWater extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWellOfSuffering.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWellOfSuffering.java index a1c96a08..8e20ebf6 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWellOfSuffering.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWellOfSuffering.java @@ -105,7 +105,7 @@ public class RitualWellOfSuffering extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects)); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualZephyr.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualZephyr.java index 780e5061..9935e162 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualZephyr.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualZephyr.java @@ -67,7 +67,7 @@ public class RitualZephyr extends Ritual { } } - masterRitualStone.getOwnerNetwork().syphon(this.getRefreshCost() * Math.min(count, 100)); + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * Math.min(count, 100))); } } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java index 4871b0b5..b023c5c0 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileAlchemyTable.java @@ -1,8 +1,17 @@ package WayofTime.bloodmagic.tile; -import java.util.ArrayList; -import java.util.List; - +import WayofTime.bloodmagic.api.event.BloodMagicCraftedEvent; +import WayofTime.bloodmagic.api.impl.BloodMagicAPI; +import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable; +import WayofTime.bloodmagic.core.data.*; +import WayofTime.bloodmagic.core.registry.AlchemyTableRecipeRegistry; +import WayofTime.bloodmagic.iface.IBindable; +import WayofTime.bloodmagic.iface.ICustomAlchemyConsumable; +import WayofTime.bloodmagic.orb.BloodOrb; +import WayofTime.bloodmagic.orb.IBloodOrb; +import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTableRecipe; +import WayofTime.bloodmagic.util.Constants; +import WayofTime.bloodmagic.util.helper.NetworkHelper; import net.minecraft.block.state.IBlockState; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -15,22 +24,10 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemHandlerHelper; - import org.apache.commons.lang3.ArrayUtils; -import WayofTime.bloodmagic.api.event.BloodMagicCraftedEvent; -import WayofTime.bloodmagic.api.impl.BloodMagicAPI; -import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable; -import WayofTime.bloodmagic.core.data.Binding; -import WayofTime.bloodmagic.core.data.SoulNetwork; -import WayofTime.bloodmagic.core.registry.AlchemyTableRecipeRegistry; -import WayofTime.bloodmagic.iface.IBindable; -import WayofTime.bloodmagic.iface.ICustomAlchemyConsumable; -import WayofTime.bloodmagic.orb.BloodOrb; -import WayofTime.bloodmagic.orb.IBloodOrb; -import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTableRecipe; -import WayofTime.bloodmagic.util.Constants; -import WayofTime.bloodmagic.util.helper.NetworkHelper; +import java.util.ArrayList; +import java.util.List; public class TileAlchemyTable extends TileInventory implements ISidedInventory, ITickable { @@ -446,7 +443,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory, { if (orbStack.getItem() instanceof IBloodOrb) { - if (NetworkHelper.syphonFromContainer(orbStack, requested)) + if (NetworkHelper.syphonFromContainer(orbStack, SoulTicket.item(orbStack, world, pos, requested))) { return requested; } diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java b/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java index 27b4e876..e10d556e 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileImperfectRitualStone.java @@ -4,13 +4,12 @@ import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.ritual.imperfect.IImperfectRitualStone; import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual; +import WayofTime.bloodmagic.tile.base.TileBase; import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper; -import WayofTime.bloodmagic.tile.base.TileBase; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; import javax.annotation.Nullable; @@ -21,7 +20,7 @@ public class TileImperfectRitualStone extends TileBase implements IImperfectRitu public boolean performRitual(World world, BlockPos pos, @Nullable ImperfectRitual imperfectRitual, EntityPlayer player) { if (imperfectRitual != null && BloodMagic.RITUAL_MANAGER.enabled(BloodMagic.RITUAL_MANAGER.getId(imperfectRitual), true)) { if (!PlayerHelper.isFakePlayer(player) && !world.isRemote) { - NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, new SoulTicket(new TextComponentTranslation(imperfectRitual.getUnlocalizedName()), imperfectRitual.getActivationCost())); + NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, SoulTicket.block(getWorld(), getPos(), imperfectRitual.getActivationCost())); if (imperfectRitual.onActivate(this, player)) { if (imperfectRitual.isLightShow()) getWorld().addWeatherEffect(new EntityLightningBolt(getWorld(), getPos().getX(), getPos().getY() + 2, getPos().getZ(), true)); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java index 68f01766..510e8932 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java @@ -147,7 +147,7 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS if (ritual.activateRitual(this, activator, binding.getOwnerId())) { if (!isRedstoned() && (activator != null && !activator.capabilities.isCreativeMode)) - network.syphon(ritual.getActivationCost()); + network.syphon(ticket(ritual.getActivationCost())); if (activator != null) activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.activate"), true); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java b/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java index 9a4e955e..6c1c09b5 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileTeleposer.java @@ -1,6 +1,7 @@ package WayofTime.bloodmagic.tile; import WayofTime.bloodmagic.core.data.Binding; +import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.event.TeleposeEvent; import WayofTime.bloodmagic.teleport.TeleportQueue; @@ -75,7 +76,7 @@ public class TileTeleposer extends TileInventory implements ITickable { final int focusLevel = (getStackInSlot(0).getItemDamage() + 1); final int lpToBeDrained = (int) (0.5F * Math.sqrt((pos.getX() - focusPos.getX()) * (pos.getX() - focusPos.getX()) + (pos.getY() - focusPos.getY() + 1) * (pos.getY() - focusPos.getY() + 1) + (pos.getZ() - focusPos.getZ()) * (pos.getZ() - focusPos.getZ()))); - if (NetworkHelper.getSoulNetwork(binding).syphonAndDamage(PlayerHelper.getPlayerFromUUID(binding.getOwnerId()), lpToBeDrained * (focusLevel * 2 - 1) * (focusLevel * 2 - 1) * (focusLevel * 2 - 1))) { + if (NetworkHelper.getSoulNetwork(binding).syphonAndDamage(PlayerHelper.getPlayerFromUUID(binding.getOwnerId()), SoulTicket.block(world, pos, lpToBeDrained * (focusLevel * 2 - 1) * (focusLevel * 2 - 1) * (focusLevel * 2 - 1))).isSuccess()) { int blocksTransported = 0; for (int i = -(focusLevel - 1); i <= (focusLevel - 1); i++) { @@ -89,7 +90,7 @@ public class TileTeleposer extends TileInventory implements ITickable { } } - NetworkHelper.syphonFromContainer(focusStack, lpToBeDrained * blocksTransported); + NetworkHelper.syphonFromContainer(focusStack, SoulTicket.item(focusStack, world, pos, lpToBeDrained * blocksTransported)); List originalWorldEntities; List focusWorldEntities; diff --git a/src/main/java/WayofTime/bloodmagic/util/helper/NetworkHelper.java b/src/main/java/WayofTime/bloodmagic/util/helper/NetworkHelper.java index dbd07fc5..bd79a435 100644 --- a/src/main/java/WayofTime/bloodmagic/util/helper/NetworkHelper.java +++ b/src/main/java/WayofTime/bloodmagic/util/helper/NetworkHelper.java @@ -98,7 +98,7 @@ public class NetworkHelper { * @param user - User of the item. * @param toSyphon - Amount of LP to syphon * @return - Whether the action should be performed. - * @deprecated Use {@link #getSoulNetwork(EntityPlayer)} and {@link SoulNetwork#syphonAndDamage(EntityPlayer, SoulTicket)} + * @deprecated Use {@link #getSoulNetwork(EntityPlayer)} and {@link SoulNetwork#syphonAndDamage$(EntityPlayer, SoulTicket)} */ @Deprecated public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon) { @@ -116,10 +116,10 @@ public class NetworkHelper { * Syphons a player from within a container. * * @param stack - ItemStack in the Container. - * @param toSyphon - Amount of LP to syphon + * @param ticket - SoulTicket to syphon * @return - If the syphon was successful. */ - public static boolean syphonFromContainer(ItemStack stack, int toSyphon) + public static boolean syphonFromContainer(ItemStack stack, SoulTicket ticket) { if (!(stack.getItem() instanceof IBindable)) return false; @@ -129,9 +129,9 @@ public class NetworkHelper { return false; SoulNetwork network = getSoulNetwork(binding); - SoulNetworkEvent.Syphon.Item event = new SoulNetworkEvent.Syphon.Item(network, new SoulTicket(toSyphon), stack); + SoulNetworkEvent.Syphon.Item event = new SoulNetworkEvent.Syphon.Item(network, ticket, stack); - return !MinecraftForge.EVENT_BUS.post(event) && network.syphon(event.getTicket(), true) >= toSyphon; + return !MinecraftForge.EVENT_BUS.post(event) && network.syphon(event.getTicket(),true) >= ticket.getAmount(); } /**