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???)
This commit is contained in:
Arcaratus 2018-08-07 18:27:12 -04:00 committed by Nick Ignoffo
parent 093cfb13ef
commit b441e7fc1e
56 changed files with 210 additions and 147 deletions

View file

@ -5,6 +5,7 @@ import WayofTime.bloodmagic.api.impl.BloodMagicAPI;
import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar; import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar;
import WayofTime.bloodmagic.block.enums.BloodRuneType; import WayofTime.bloodmagic.block.enums.BloodRuneType;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.IBindable; import WayofTime.bloodmagic.iface.IBindable;
import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.orb.BloodOrb; import WayofTime.bloodmagic.orb.BloodOrb;
@ -365,7 +366,7 @@ public class BloodAltar implements IFluidHandler
if (fluid != null && fluid.amount >= 1) if (fluid != null && fluid.amount >= 1)
{ {
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? orb.getFillRate() * (1 + consumptionMultiplier) : orb.getFillRate()), fluid.amount); 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; fluid.amount = fluid.amount - drain;
if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer) if (drain > 0 && internalCounter % 4 == 0 && world instanceof WorldServer)

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.command.sub; package WayofTime.bloodmagic.command.sub;
import WayofTime.bloodmagic.core.data.SoulNetwork; import WayofTime.bloodmagic.core.data.SoulNetwork;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.command.CommandBloodMagic; import WayofTime.bloodmagic.command.CommandBloodMagic;
import WayofTime.bloodmagic.util.Utils; import WayofTime.bloodmagic.util.Utils;
@ -66,7 +67,7 @@ public class SubCommandNetwork extends CommandBase {
if (args.length == 3) { if (args.length == 3) {
if (Utils.isInteger(args[2])) { if (Utils.isInteger(args[2])) {
int amount = Integer.parseInt(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()); CommandBloodMagic.displaySuccessString(sender, "commands.bloodmagic.network.syphon.success", amount, player.getDisplayName().getFormattedText());
} else { } else {
CommandBloodMagic.displayErrorString(sender, "commands.bloodmagic.error.arg.invalid"); CommandBloodMagic.displayErrorString(sender, "commands.bloodmagic.error.arg.invalid");
@ -90,7 +91,7 @@ public class SubCommandNetwork extends CommandBase {
if (Utils.isInteger(args[2])) { if (Utils.isInteger(args[2])) {
int amount = Integer.parseInt(args[2]); int amount = Integer.parseInt(args[2]);
int maxOrb = NetworkHelper.getMaximumForTier(network.getOrbTier()); 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 { } else {
CommandBloodMagic.displayErrorString(sender, "commands.bloodmagic.error.arg.invalid"); CommandBloodMagic.displayErrorString(sender, "commands.bloodmagic.error.arg.invalid");
} }

View file

@ -33,6 +33,10 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound> {
ticketHistory = EvictingQueue.create(16); ticketHistory = EvictingQueue.create(16);
} }
public void clear() {
ticketHistory.clear();
}
public int add(SoulTicket ticket, int maximum) { public int add(SoulTicket ticket, int maximum) {
SoulNetworkEvent.Fill event = new SoulNetworkEvent.Fill(this, ticket, maximum); SoulNetworkEvent.Fill event = new SoulNetworkEvent.Fill(this, ticket, maximum);
if (MinecraftForge.EVENT_BUS.post(event)) if (MinecraftForge.EVENT_BUS.post(event))
@ -46,7 +50,11 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound> {
int newEss = Math.min(event.getMaximum(), currEss + event.getTicket().getAmount()); int newEss = Math.min(event.getMaximum(), currEss + event.getTicket().getAmount());
setCurrentEssence(newEss); setCurrentEssence(newEss);
if (ticketHistory.contains(ticket))
ticketHistory.remove(ticket); // "Pops" the existing ticket to the top of the queue
ticketHistory.add(ticket); ticketHistory.add(ticket);
return newEss - currEss; return newEss - currEss;
} }
@ -78,6 +86,9 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound> {
int syphon = event.getTicket().getAmount(); int syphon = event.getTicket().getAmount();
if (getCurrentEssence() >= syphon) { if (getCurrentEssence() >= syphon) {
setCurrentEssence(getCurrentEssence() - syphon); setCurrentEssence(getCurrentEssence() - syphon);
if (ticketHistory.contains(ticket))
ticketHistory.remove(ticket);
ticketHistory.add(ticket); ticketHistory.add(ticket);
return syphon; return syphon;
} }
@ -107,7 +118,11 @@ public class SoulNetwork implements INBTSerializable<NBTTagCompound> {
if (drainAmount <= 0 || event.shouldDamage()) if (drainAmount <= 0 || event.shouldDamage())
hurtPlayer(user, event.getTicket().getAmount()); hurtPlayer(user, event.getTicket().getAmount());
if (ticketHistory.contains(ticket))
ticketHistory.remove(ticket);
ticketHistory.add(ticket); ticketHistory.add(ticket);
return BooleanResult.newResult(true, event.getTicket().getAmount()); return BooleanResult.newResult(true, event.getTicket().getAmount());
} }

View file

@ -1,7 +1,12 @@
package WayofTime.bloodmagic.core.data; 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.ITextComponent;
import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
public class SoulTicket { public class SoulTicket {
@ -30,4 +35,51 @@ public class SoulTicket {
public int getAmount() { public int getAmount() {
return amount; 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();
}
} }

View file

@ -1,6 +1,6 @@
package WayofTime.bloodmagic.iface; package WayofTime.bloodmagic.iface;
import WayofTime.bloodmagic.item.ItemSigil; import WayofTime.bloodmagic.item.sigil.ItemSigil;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;

View file

@ -1,8 +1,7 @@
package WayofTime.bloodmagic.item; package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.*;
import WayofTime.bloodmagic.core.data.SoulNetwork;
import WayofTime.bloodmagic.orb.BloodOrb; import WayofTime.bloodmagic.orb.BloodOrb;
import WayofTime.bloodmagic.orb.IBloodOrb; import WayofTime.bloodmagic.orb.IBloodOrb;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
@ -83,7 +82,7 @@ public class ItemBloodOrb extends ItemBindableBase implements IBloodOrb {
if (binding.getOwnerId().equals(player.getGameProfile().getId())) if (binding.getOwnerId().equals(player.getGameProfile().getId()))
ownerNetwork.setOrbTier(orb.getTier()); 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 ownerNetwork.hurtPlayer(player, 200); // Hurt whoever is using it
return super.onItemRightClick(world, player, hand); return super.onItemRightClick(world, player, hand);
} }

View file

@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.util.BlockStack; import WayofTime.bloodmagic.util.BlockStack;
import WayofTime.bloodmagic.util.ItemStackWrapper; import WayofTime.bloodmagic.util.ItemStackWrapper;
import WayofTime.bloodmagic.util.helper.NetworkHelper; 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); world.createExplosion(player, playerPos.getX(), playerPos.getY(), playerPos.getZ(), 0.1F, false);
dropStacks(drops, world, playerPos.add(0, 1, 0)); dropStacks(drops, world, playerPos.add(0, 1, 0));
} }

View file

@ -2,12 +2,11 @@ package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.util.BlockStack; import WayofTime.bloodmagic.util.BlockStack;
import WayofTime.bloodmagic.util.ItemStackWrapper; import WayofTime.bloodmagic.util.ItemStackWrapper;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import com.google.common.collect.HashMultiset; import com.google.common.collect.*;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; 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); world.createExplosion(player, playerPos.getX(), playerPos.getY(), playerPos.getZ(), 0.5F, false);
dropStacks(drops, world, playerPos.add(0, 1, 0)); dropStacks(drops, world, playerPos.add(0, 1, 0));
} }

View file

@ -2,12 +2,11 @@ package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.util.BlockStack; import WayofTime.bloodmagic.util.BlockStack;
import WayofTime.bloodmagic.util.ItemStackWrapper; import WayofTime.bloodmagic.util.ItemStackWrapper;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import com.google.common.collect.HashMultiset; import com.google.common.collect.*;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; 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); world.createExplosion(player, playerPos.getX(), playerPos.getY(), playerPos.getZ(), 0.5F, false);
dropStacks(drops, world, playerPos.add(0, 1, 0)); dropStacks(drops, world, playerPos.add(0, 1, 0));
} }

View file

@ -5,6 +5,7 @@ import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.IActivatable; import WayofTime.bloodmagic.iface.IActivatable;
import WayofTime.bloodmagic.iface.IBindable; import WayofTime.bloodmagic.iface.IBindable;
import WayofTime.bloodmagic.util.Utils; 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.renderer.ItemMeshDefinition;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity; import net.minecraft.entity.*;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword; import net.minecraft.item.ItemSword;
import net.minecraft.util.ActionResult; import net.minecraft.util.*;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; 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) 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 @Override

View file

@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.util.ItemStackWrapper; import WayofTime.bloodmagic.util.ItemStackWrapper;
import WayofTime.bloodmagic.event.BoundToolEvent; import WayofTime.bloodmagic.event.BoundToolEvent;
import WayofTime.bloodmagic.iface.IActivatable; 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) 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) { protected int getHeldDownCount(ItemStack stack) {

View file

@ -3,6 +3,7 @@ package WayofTime.bloodmagic.item;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@ -14,6 +15,7 @@ import net.minecraft.potion.PotionEffect;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; 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 class ItemLavaCrystal extends ItemBindableBase implements IVariantProvider {
public ItemLavaCrystal() { public ItemLavaCrystal() {
@ -25,7 +27,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvide
public ItemStack getContainerItem(ItemStack stack) { public ItemStack getContainerItem(ItemStack stack) {
Binding binding = getBinding(stack); Binding binding = getBinding(stack);
if (binding != null) if (binding != null)
NetworkHelper.getSoulNetwork(binding.getOwnerId()).syphon(25); NetworkHelper.getSoulNetwork(binding.getOwnerId()).syphon(SoulTicket.item(stack, 25));
ItemStack returnStack = new ItemStack(this); ItemStack returnStack = new ItemStack(this);
returnStack.setTagCompound(stack.getTagCompound()); returnStack.setTagCompound(stack.getTagCompound());
@ -43,7 +45,7 @@ public class ItemLavaCrystal extends ItemBindableBase implements IVariantProvide
if (binding == null) if (binding == null)
return -1; return -1;
if (NetworkHelper.syphonFromContainer(stack, 25)) if (NetworkHelper.syphonFromContainer(stack, SoulTicket.item(stack, 25)))
return 200; return 200;
else { else {
EntityPlayer player = PlayerHelper.getPlayerFromUUID(binding.getOwnerId()); EntityPlayer player = PlayerHelper.getPlayerFromUUID(binding.getOwnerId());

View file

@ -4,6 +4,7 @@ import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.core.RegistrarBloodMagicItems; import WayofTime.bloodmagic.core.RegistrarBloodMagicItems;
import WayofTime.bloodmagic.core.data.SoulNetwork; import WayofTime.bloodmagic.core.data.SoulNetwork;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.item.types.ComponentTypes; import WayofTime.bloodmagic.item.types.ComponentTypes;
import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.livingArmour.LivingArmourUpgrade;
@ -210,7 +211,7 @@ public class ItemLivingArmour extends ItemArmor implements ISpecialArmor, IMeshP
if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) { if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity; EntityPlayer player = (EntityPlayer) entity;
SoulNetwork network = NetworkHelper.getSoulNetwork(player); SoulNetwork network = NetworkHelper.getSoulNetwork(player);
network.syphonAndDamage(player, damage * 100); network.syphonAndDamage(player, SoulTicket.item(stack, entity.getEntityWorld(), entity, damage * 100));
} }
return; return;

View file

@ -1,4 +1,4 @@
package WayofTime.bloodmagic.item; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.iface.IBindable; import WayofTime.bloodmagic.iface.IBindable;

View file

@ -1,21 +1,19 @@
package WayofTime.bloodmagic.item.sigil; 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.ISentientSwordEffectProvider;
import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.soul.EnumDemonWillType; import WayofTime.bloodmagic.soul.EnumDemonWillType;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper;
import WayofTime.bloodmagic.core.RegistrarBloodMagic;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects; import net.minecraft.init.MobEffects;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect; import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ActionResult; import net.minecraft.util.*;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -51,7 +49,7 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP
if (!world.isRemote) { if (!world.isRemote) {
if (!player.capabilities.isCreativeMode) 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) if (!unusable)
player.fallDistance = 0; player.fallDistance = 0;

View file

@ -3,7 +3,6 @@ package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.client.IVariantProvider; import WayofTime.bloodmagic.client.IVariantProvider;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.item.ItemSigil;
import WayofTime.bloodmagic.util.helper.TextHelper; import WayofTime.bloodmagic.util.helper.TextHelper;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;

View file

@ -1,19 +1,16 @@
package WayofTime.bloodmagic.item.sigil; 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.RegistrarBloodMagicBlocks;
import WayofTime.bloodmagic.core.data.SoulNetwork;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.entity.projectile.EntityBloodLight; 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.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.*;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -56,7 +53,7 @@ public class ItemSigilBloodLight extends ItemSigilBase
if (!world.isRemote) if (!world.isRemote)
{ {
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack)); SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
network.syphonAndDamage(player, getLpUsed()); network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed()));
} }
resetCooldown(stack); resetCooldown(stack);
player.swingArm(hand); player.swingArm(hand);
@ -68,7 +65,7 @@ public class ItemSigilBloodLight extends ItemSigilBase
{ {
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack)); SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
world.spawnEntity(new EntityBloodLight(world, player)); world.spawnEntity(new EntityBloodLight(world, player));
network.syphonAndDamage(player, getLpUsed()); network.syphonAndDamage(player, SoulTicket.item(stack, world, player, getLpUsed()));
} }
resetCooldown(stack); resetCooldown(stack);
} }

View file

@ -3,15 +3,13 @@ package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.iface.IAltarReader; import WayofTime.bloodmagic.iface.IAltarReader;
import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.util.ChatUtil;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper;
import WayofTime.bloodmagic.util.ChatUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult; import net.minecraft.util.*;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World; import net.minecraft.world.World;

View file

@ -1,6 +1,8 @@
package WayofTime.bloodmagic.item.sigil; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.impl.BloodMagicAPI; 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 WayofTime.bloodmagic.util.helper.PlayerHelper;
import net.minecraft.block.IGrowable; import net.minecraft.block.IGrowable;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -24,7 +26,7 @@ public class ItemSigilGreenGrove extends ItemSigilToggleableBase {
if (PlayerHelper.isFakePlayer(player)) if (PlayerHelper.isFakePlayer(player))
return false; 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) { if (!world.isRemote) {
world.playEvent(2005, blockPos, 0); world.playEvent(2005, blockPos, 0);
} }

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper;
@ -8,10 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult; import net.minecraft.util.*;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -59,7 +57,7 @@ public class ItemSigilLava extends ItemSigilBase {
return super.onItemRightClick(world, player, hand); 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); return super.onItemRightClick(world, player, hand);
} }
} }
@ -85,7 +83,7 @@ public class ItemSigilLava extends ItemSigilBase {
FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000); FluidStack fluid = new FluidStack(FluidRegistry.LAVA, 1000);
int amount = handler.fill(fluid, false); 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); handler.fill(fluid, true);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }

View file

@ -47,5 +47,4 @@ public class ItemSigilSuppression extends ItemSigilToggleableBase {
} }
} }
} }
} }

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.item; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.iface.IActivatable; import WayofTime.bloodmagic.iface.IActivatable;
import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.iface.ISigil;
@ -53,7 +54,7 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable {
if (!world.isRemote && !isUnusable(stack)) { if (!world.isRemote && !isUnusable(stack)) {
if (player.isSneaking()) if (player.isSneaking())
setActivatedState(stack, !getActivated(stack)); setActivatedState(stack, !getActivated(stack));
if (getActivated(stack) && NetworkHelper.getSoulNetwork(player).syphonAndDamage(player, getLpUsed())) if (getActivated(stack))
return super.onItemRightClick(world, player, hand); 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 if (binding == null || player.isSneaking()) // Make sure Sigils are bound before handling. Also ignores while toggling state
return EnumActionResult.PASS; 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) { 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) { public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) { if (!worldIn.isRemote && entityIn instanceof EntityPlayerMP && getActivated(stack)) {
if (entityIn.ticksExisted % 100 == 0) { 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); setActivatedState(stack, false);
} }
} }

View file

@ -4,7 +4,6 @@ import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.client.IMeshProvider; import WayofTime.bloodmagic.client.IMeshProvider;
import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable; import WayofTime.bloodmagic.client.mesh.CustomMeshDefinitionActivatable;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.item.ItemSigilToggleable;
import WayofTime.bloodmagic.util.helper.TextHelper; import WayofTime.bloodmagic.util.helper.TextHelper;
import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.util.ITooltipFlag; import net.minecraft.client.util.ITooltipFlag;

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.item.sigil; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.api.impl.BloodMagicAPI; import WayofTime.bloodmagic.api.impl.BloodMagicAPI;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper;
@ -12,9 +13,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTUtil; import net.minecraft.nbt.NBTUtil;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityMobSpawner; import net.minecraft.tileentity.TileEntityMobSpawner;
import net.minecraft.util.EnumActionResult; import net.minecraft.util.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@ -89,7 +88,7 @@ public class ItemSigilTransposition extends ItemSigilBase {
} }
stack.getTagCompound().setTag("stored", stored); 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.removeTileEntity(blockPos);
world.setBlockToAir(blockPos); world.setBlockToAir(blockPos);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;

View file

@ -1,16 +1,14 @@
package WayofTime.bloodmagic.item.sigil; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.core.data.SoulNetwork; import WayofTime.bloodmagic.core.data.SoulNetwork;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult; import net.minecraft.util.*;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -56,7 +54,7 @@ public class ItemSigilVoid extends ItemSigilBase {
return super.onItemRightClick(world, player, hand); 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); world.setBlockToAir(blockpos);
return super.onItemRightClick(world, player, hand); return super.onItemRightClick(world, player, hand);
} }
@ -66,7 +64,7 @@ public class ItemSigilVoid extends ItemSigilBase {
} }
if (!player.capabilities.isCreativeMode) 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); return super.onItemRightClick(world, player, hand);
@ -92,7 +90,7 @@ public class ItemSigilVoid extends ItemSigilBase {
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side); IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
FluidStack amount = handler.drain(1000, false); 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); handler.drain(1000, true);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }
@ -106,7 +104,7 @@ public class ItemSigilVoid extends ItemSigilBase {
return EnumActionResult.FAIL; 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); world.setBlockToAir(newPos);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.item.sigil; package WayofTime.bloodmagic.item.sigil;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.iface.ISigil; import WayofTime.bloodmagic.iface.ISigil;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper;
@ -54,7 +55,7 @@ public class ItemSigilWater extends ItemSigilBase {
if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack)) if (!player.canPlayerEdit(blockpos1, rayTrace.sideHit, stack))
return super.onItemRightClick(world, player, hand); 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); return super.onItemRightClick(world, player, hand);
} }
} }
@ -78,7 +79,7 @@ public class ItemSigilWater extends ItemSigilBase {
FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000); FluidStack fluid = new FluidStack(FluidRegistry.WATER, 1000);
int amount = handler.fill(fluid, false); 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); handler.fill(fluid, true);
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }
@ -86,7 +87,7 @@ public class ItemSigilWater extends ItemSigilBase {
return EnumActionResult.FAIL; 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)); world.setBlockState(blockPos, Blocks.CAULDRON.getDefaultState().withProperty(BlockCauldron.LEVEL, 3));
return EnumActionResult.SUCCESS; return EnumActionResult.SUCCESS;
} }

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.ritual; package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.core.data.SoulNetwork; import WayofTime.bloodmagic.core.data.SoulNetwork;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.soul.EnumDemonWillType; import WayofTime.bloodmagic.soul.EnumDemonWillType;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -56,4 +57,8 @@ public interface IMasterRitualStone {
boolean setBlockRangeByBounds(EntityPlayer player, String range, BlockPos offset1, BlockPos offset2); boolean setBlockRangeByBounds(EntityPlayer player, String range, BlockPos offset1, BlockPos offset2);
List<EnumDemonWillType> getActiveWillConfig(); List<EnumDemonWillType> getActiveWillConfig();
default SoulTicket ticket(int amount) {
return SoulTicket.block(getWorldObj(), getBlockPos(), amount);
}
} }

View file

@ -1,12 +1,11 @@
package WayofTime.bloodmagic.ritual.portal; package WayofTime.bloodmagic.ritual.portal;
import WayofTime.bloodmagic.event.TeleposeEvent;
import WayofTime.bloodmagic.core.data.SoulNetwork; 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.teleport.Teleport;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import net.minecraft.entity.Entity; import net.minecraft.entity.*;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
@ -15,6 +14,7 @@ import net.minecraft.network.play.server.SPacketUpdateHealth;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.WorldServer; import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge; 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)))) if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), entity.getEntityWorld(), new BlockPos(x, y, z))))
return; return;
network.syphon(getTeleportCost());
EntityPlayerMP player = (EntityPlayerMP) entity; EntityPlayerMP player = (EntityPlayerMP) entity;
network.syphon(ticket(entity.world, player, getTeleportCost()));
player.setPositionAndUpdate(x + 0.5, y + 0.5, z + 0.5); player.setPositionAndUpdate(x + 0.5, y + 0.5, z + 0.5);
player.getEntityWorld().updateEntityWithOptionalForce(player, false); player.getEntityWorld().updateEntityWithOptionalForce(player, false);
player.connection.sendPacket(new SPacketUpdateHealth(player.getHealth(), player.getFoodStats().getFoodLevel(), player.getFoodStats().getSaturationLevel())); 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)))) if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), entity.getEntityWorld(), new BlockPos(x, y, z))))
return; return;
network.syphon(getTeleportCost() / 10);
WorldServer world = (WorldServer) entity.getEntityWorld(); WorldServer world = (WorldServer) entity.getEntityWorld();
network.syphon(ticket(world, entity, getTeleportCost() / 10));
entity.setPosition(x + 0.5, y + 0.5, z + 0.5); entity.setPosition(x + 0.5, y + 0.5, z + 0.5);
entity.timeUntilPortal = 150; entity.timeUntilPortal = 150;
world.resetUpdateEntityTick(); 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)))) if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), newWorldServer, new BlockPos(x, y, z))))
return; return;
network.syphon(getTeleportCost()); network.syphon(ticket(oldWorld, player, getTeleportCost()));
player.changeDimension(newWorldID); //TODO: UNTESTED player.changeDimension(newWorldID); //TODO: UNTESTED
// server.getConfigurationManager().transferPlayerToDimension(player, newWorldID, new TeleporterBloodMagic(newWorldServer)); // 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)))) if (MinecraftForge.EVENT_BUS.post(new TeleposeEvent.Ent(entity, entity.getEntityWorld(), entity.getPosition(), newWorldServer, new BlockPos(x, y, z))))
return; return;
network.syphon(getTeleportCost() / 10); network.syphon(ticket(oldWorld, entity, getTeleportCost() / 10));
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
@ -193,4 +193,8 @@ public class Teleports {
return teleposer; 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);
}
} }

View file

@ -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)) { if (world.getBlockState(altarPos).getBlock().isReplaceable(world, altarPos) && hasItem(tileEntity, Item.getItemFromBlock(RegistrarBloodMagicBlocks.ALTAR), 0, true)) {
world.setBlockState(altarPos, RegistrarBloodMagicBlocks.ALTAR.getDefaultState()); world.setBlockState(altarPos, RegistrarBloodMagicBlocks.ALTAR.getDefaultState());
lightning(world, altarPos); lightning(world, altarPos);
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
} }
if (altarComponentsIterator.hasNext()) { if (altarComponentsIterator.hasNext()) {
@ -72,7 +72,7 @@ public class RitualAltarBuilder extends Ritual {
if (blockStack != null) { if (blockStack != null) {
world.setBlockState(currentPos, blockStack.getState(), 3); world.setBlockState(currentPos, blockStack.getState(), 3);
lightning(world, currentPos); lightning(world, currentPos);
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
} }
break; break;
} }
@ -81,7 +81,7 @@ public class RitualAltarBuilder extends Ritual {
if (blockStack != null) { if (blockStack != null) {
world.setBlockState(currentPos, blockStack.getState(), 3); world.setBlockState(currentPos, blockStack.getState(), 3);
lightning(world, currentPos); lightning(world, currentPos);
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
} }
break; break;
} }
@ -90,7 +90,7 @@ public class RitualAltarBuilder extends Ritual {
if (hasItem(tileEntity, Item.getItemFromBlock(blockStack.getBlock()), blockStack.getMeta(), true)) { if (hasItem(tileEntity, Item.getItemFromBlock(blockStack.getBlock()), blockStack.getMeta(), true)) {
world.setBlockState(currentPos, blockStack.getState(), 3); world.setBlockState(currentPos, blockStack.getState(), 3);
lightning(world, currentPos); lightning(world, currentPos);
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
} }
break; break;
} }

View file

@ -161,7 +161,7 @@ public class RitualAnimalGrowth extends Ritual {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveDrain, true); WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveDrain, true);
} }
masterRitualStone.getOwnerNetwork().syphon(totalGrowths * getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(totalGrowths * getRefreshCost()));
} }
@Override @Override

View file

@ -75,7 +75,7 @@ public class RitualCobblestone extends Ritual {
} }
} }
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects));
} }
@Override @Override

View file

@ -153,7 +153,7 @@ public class RitualCrushing extends Ritual {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, willDrain, true); WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, willDrain, true);
corrosiveWill -= willDrain; corrosiveWill -= willDrain;
masterRitualStone.getOwnerNetwork().syphon(lpDrain); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(lpDrain));
currentEssence -= lpDrain; currentEssence -= lpDrain;
isBlockClaimed = true; isBlockClaimed = true;
@ -211,7 +211,7 @@ public class RitualCrushing extends Ritual {
} }
world.destroyBlock(newPos, false); world.destroyBlock(newPos, false);
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
hasOperated = true; hasOperated = true;
if (consumeRawWill) { if (consumeRawWill) {

View file

@ -54,7 +54,7 @@ public class RitualCrystalHarvest extends Ritual {
} }
} }
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects));
} }
@Override @Override

View file

@ -1,7 +1,6 @@
package WayofTime.bloodmagic.ritual.types; package WayofTime.bloodmagic.ritual.types;
import java.util.function.Consumer; import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.ritual.*; import WayofTime.bloodmagic.ritual.*;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -14,7 +13,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import WayofTime.bloodmagic.BloodMagic;
import java.util.function.Consumer;
@RitualRegister("ellipsoid") @RitualRegister("ellipsoid")
public class RitualEllipsoid extends Ritual public class RitualEllipsoid extends Ritual
@ -133,7 +133,7 @@ public class RitualEllipsoid extends Ritual
itemHandler.extractItem(blockSlot, 1, false); itemHandler.extractItem(blockSlot, 1, false);
tileInventory.markDirty(); tileInventory.markDirty();
//TODO: //TODO:
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
k++; k++;
this.currentPos = new BlockPos(i, j, k); this.currentPos = new BlockPos(i, j, k);
return; return;

View file

@ -75,7 +75,7 @@ public class RitualExpulsion extends Ritual {
continue; continue;
if (teleportRandomly(player, teleportDistance)) if (teleportRandomly(player, teleportDistance))
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * 1000); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * 1000));
} }
whitelist.clear(); whitelist.clear();

View file

@ -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) { if (totalEffects > 0 && consumeRawWill) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWillDrain, true); WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWillDrain, true);
} }

View file

@ -67,7 +67,7 @@ public class RitualFelling extends Ritual {
} }
if (blockPosIterator.hasNext() && tileInventory != null) { if (blockPosIterator.hasNext() && tileInventory != null) {
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
currentPos = blockPosIterator.next(); currentPos = blockPosIterator.next();
IItemHandler inventory = Utils.getInventory(tileInventory, EnumFacing.DOWN); IItemHandler inventory = Utils.getInventory(tileInventory, EnumFacing.DOWN);
placeInInventory(world.getBlockState(currentPos), world, currentPos, inventory); placeInInventory(world.getBlockState(currentPos), world, currentPos, inventory);

View file

@ -141,7 +141,7 @@ public class RitualForsakenSoul extends Ritual {
} }
} }
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects));
} }
/** /**

View file

@ -80,7 +80,7 @@ public class RitualFullStomach extends Ritual {
} }
} }
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects));
} }
@Override @Override

View file

@ -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) { public double getPlantGrowthChanceForWill(double will) {

View file

@ -62,7 +62,7 @@ public class RitualHarvest extends Ritual {
} }
} }
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * harvested); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * harvested));
} }
@Override @Override

View file

@ -56,7 +56,7 @@ public class RitualJumping extends Ritual {
} }
} }
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects));
} }
@Override @Override

View file

@ -215,7 +215,7 @@ public class RitualLava extends Ritual {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrained, true); WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrained, true);
} }
masterRitualStone.getOwnerNetwork().syphon(lpDrain); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(lpDrain));
} }
@Override @Override

View file

@ -72,7 +72,7 @@ public class RitualMagnetic extends Ritual {
ItemStack checkStack = state.getBlock().getPickBlock(state, null, world, newPos, null); ItemStack checkStack = state.getBlock().getPickBlock(state, null, world, newPos, null);
if (isBlockOre(checkStack)) { if (isBlockOre(checkStack)) {
Utils.swapLocations(world, newPos, world, replacement); Utils.swapLocations(world, newPos, world, replacement);
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
k++; k++;
this.lastPos = new BlockPos(i, j, k); this.lastPos = new BlockPos(i, j, k);
return; return;

View file

@ -61,7 +61,7 @@ public class RitualMeteor extends Ritual {
entityItem.setDead(); entityItem.setDead();
if (destructiveWill >= destructiveWillDrain && currentEssence >= 1000000000) { if (destructiveWill >= destructiveWillDrain && currentEssence >= 1000000000) {
masterRitualStone.getOwnerNetwork().syphon(1000000); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(1000000));
} else { } else {
masterRitualStone.setActive(false); masterRitualStone.setActive(false);
} }

View file

@ -67,7 +67,7 @@ public class RitualPlacer extends Ritual {
world.setBlockState(blockPos, placeState); world.setBlockState(blockPos, placeState);
itemHandler.extractItem(invSlot, 1, false); itemHandler.extractItem(invSlot, 1, false);
tileEntity.markDirty(); tileEntity.markDirty();
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
break posLoop; // Break instead of return in case we add things later break posLoop; // Break instead of return in case we add things later
} }
} }

View file

@ -77,7 +77,7 @@ public class RitualPump extends Ritual {
blockPosIterator = liquidsCache.iterator(); blockPosIterator = liquidsCache.iterator();
if (blockPosIterator.hasNext()) { if (blockPosIterator.hasNext()) {
Pair<BlockPos, FluidStack> posInfo = blockPosIterator.next(); Pair<BlockPos, FluidStack> posInfo = blockPosIterator.next();
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost()); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost()));
fluidHandler.fill(posInfo.getRight(), true); fluidHandler.fill(posInfo.getRight(), true);
world.setBlockState(posInfo.getLeft(), Blocks.STONE.getDefaultState()); world.setBlockState(posInfo.getLeft(), Blocks.STONE.getDefaultState());
world.notifyBlockUpdate(posInfo.getLeft(), tankState, tankState, 3); world.notifyBlockUpdate(posInfo.getLeft(), tankState, tankState, 3);

View file

@ -140,7 +140,7 @@ public class RitualRegeneration extends Ritual {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true); WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true);
} }
masterRitualStone.getOwnerNetwork().syphon(totalCost); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(totalCost));
} }
@Override @Override

View file

@ -44,7 +44,7 @@ public class RitualWater extends Ritual {
} }
} }
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects));
} }
@Override @Override

View file

@ -105,7 +105,7 @@ public class RitualWellOfSuffering extends Ritual {
} }
} }
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost() * totalEffects); masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(getRefreshCost() * totalEffects));
} }
@Override @Override

View file

@ -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)));
} }
} }

View file

@ -1,8 +1,17 @@
package WayofTime.bloodmagic.tile; package WayofTime.bloodmagic.tile;
import java.util.ArrayList; import WayofTime.bloodmagic.api.event.BloodMagicCraftedEvent;
import java.util.List; 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.block.state.IBlockState;
import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -15,22 +24,10 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.items.ItemHandlerHelper;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import WayofTime.bloodmagic.api.event.BloodMagicCraftedEvent; import java.util.ArrayList;
import WayofTime.bloodmagic.api.impl.BloodMagicAPI; import java.util.List;
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;
public class TileAlchemyTable extends TileInventory implements ISidedInventory, ITickable 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 (orbStack.getItem() instanceof IBloodOrb)
{ {
if (NetworkHelper.syphonFromContainer(orbStack, requested)) if (NetworkHelper.syphonFromContainer(orbStack, SoulTicket.item(orbStack, world, pos, requested)))
{ {
return requested; return requested;
} }

View file

@ -4,13 +4,12 @@ import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.core.data.SoulTicket; import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.ritual.imperfect.IImperfectRitualStone; import WayofTime.bloodmagic.ritual.imperfect.IImperfectRitualStone;
import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual; import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitual;
import WayofTime.bloodmagic.tile.base.TileBase;
import WayofTime.bloodmagic.util.helper.NetworkHelper; import WayofTime.bloodmagic.util.helper.NetworkHelper;
import WayofTime.bloodmagic.util.helper.PlayerHelper; import WayofTime.bloodmagic.util.helper.PlayerHelper;
import WayofTime.bloodmagic.tile.base.TileBase;
import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nullable; 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) { 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 (imperfectRitual != null && BloodMagic.RITUAL_MANAGER.enabled(BloodMagic.RITUAL_MANAGER.getId(imperfectRitual), true)) {
if (!PlayerHelper.isFakePlayer(player) && !world.isRemote) { 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.onActivate(this, player)) {
if (imperfectRitual.isLightShow()) if (imperfectRitual.isLightShow())
getWorld().addWeatherEffect(new EntityLightningBolt(getWorld(), getPos().getX(), getPos().getY() + 2, getPos().getZ(), true)); getWorld().addWeatherEffect(new EntityLightningBolt(getWorld(), getPos().getX(), getPos().getY() + 2, getPos().getZ(), true));

View file

@ -147,7 +147,7 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS
if (ritual.activateRitual(this, activator, binding.getOwnerId())) { if (ritual.activateRitual(this, activator, binding.getOwnerId())) {
if (!isRedstoned() && (activator != null && !activator.capabilities.isCreativeMode)) if (!isRedstoned() && (activator != null && !activator.capabilities.isCreativeMode))
network.syphon(ritual.getActivationCost()); network.syphon(ticket(ritual.getActivationCost()));
if (activator != null) if (activator != null)
activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.activate"), true); activator.sendStatusMessage(new TextComponentTranslation("chat.bloodmagic.ritual.activate"), true);

View file

@ -1,6 +1,7 @@
package WayofTime.bloodmagic.tile; package WayofTime.bloodmagic.tile;
import WayofTime.bloodmagic.core.data.Binding; import WayofTime.bloodmagic.core.data.Binding;
import WayofTime.bloodmagic.core.data.SoulTicket;
import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.util.Constants;
import WayofTime.bloodmagic.event.TeleposeEvent; import WayofTime.bloodmagic.event.TeleposeEvent;
import WayofTime.bloodmagic.teleport.TeleportQueue; 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 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()))); 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; int blocksTransported = 0;
for (int i = -(focusLevel - 1); i <= (focusLevel - 1); i++) { 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<Entity> originalWorldEntities; List<Entity> originalWorldEntities;
List<Entity> focusWorldEntities; List<Entity> focusWorldEntities;

View file

@ -98,7 +98,7 @@ public class NetworkHelper {
* @param user - User of the item. * @param user - User of the item.
* @param toSyphon - Amount of LP to syphon * @param toSyphon - Amount of LP to syphon
* @return - Whether the action should be performed. * @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 @Deprecated
public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon) { public static boolean syphonAndDamage(SoulNetwork soulNetwork, EntityPlayer user, int toSyphon) {
@ -116,10 +116,10 @@ public class NetworkHelper {
* Syphons a player from within a container. * Syphons a player from within a container.
* *
* @param stack - ItemStack in the 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. * @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)) if (!(stack.getItem() instanceof IBindable))
return false; return false;
@ -129,9 +129,9 @@ public class NetworkHelper {
return false; return false;
SoulNetwork network = getSoulNetwork(binding); 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();
} }
/** /**