Fixed many sigils using the wrong stack for their logic (#1102)
This is why you use custom methods for things like this instead of MC methods
This commit is contained in:
parent
41c2f37042
commit
216bdb2d2e
|
@ -1,8 +1,12 @@
|
||||||
package WayofTime.bloodmagic.api.iface;
|
package WayofTime.bloodmagic.api.iface;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for all {@link WayofTime.bloodmagic.api.impl.ItemSigil} <b>EXCEPT</b>
|
* Used for all {@link WayofTime.bloodmagic.api.impl.ItemSigil} <b>EXCEPT</b>
|
||||||
* Sigils of Holdings.
|
* Sigils of Holdings.
|
||||||
|
@ -12,4 +16,10 @@ public interface ISigil
|
||||||
boolean performArrayEffect(World world, BlockPos pos);
|
boolean performArrayEffect(World world, BlockPos pos);
|
||||||
|
|
||||||
boolean hasArrayEffect();
|
boolean hasArrayEffect();
|
||||||
|
|
||||||
|
interface Holding
|
||||||
|
{
|
||||||
|
@Nonnull
|
||||||
|
ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.api.impl;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.api.Constants;
|
import WayofTime.bloodmagic.api.Constants;
|
||||||
import WayofTime.bloodmagic.api.iface.IActivatable;
|
import WayofTime.bloodmagic.api.iface.IActivatable;
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||||
|
@ -49,6 +50,8 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
||||||
|
@ -67,6 +70,8 @@ public class ItemSigilToggleable extends ItemSigil implements IActivatable
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (Strings.isNullOrEmpty(getOwnerUUID(stack)) || player.isSneaking()) // Make sure Sigils are bound before handling. Also ignores while toggling state
|
if (Strings.isNullOrEmpty(getOwnerUUID(stack)) || player.isSneaking()) // Make sure Sigils are bound before handling. Also ignores while toggling state
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package WayofTime.bloodmagic.item.sigil;
|
package WayofTime.bloodmagic.item.sigil;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -29,6 +30,8 @@ public class ItemSigilAir extends ItemSigilBase implements ISentientSwordEffectP
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package WayofTime.bloodmagic.item.sigil;
|
package WayofTime.bloodmagic.item.sigil;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -34,6 +35,8 @@ public class ItemSigilBloodLight extends ItemSigilBase
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package WayofTime.bloodmagic.item.sigil;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
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;
|
||||||
|
@ -47,6 +48,8 @@ public class ItemSigilDivination extends ItemSigilBase implements IAltarReader
|
||||||
// world.spawnEntityInWorld(fred);
|
// world.spawnEntityInWorld(fred);
|
||||||
// }
|
// }
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
|
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package WayofTime.bloodmagic.item.sigil;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||||
import WayofTime.bloodmagic.client.key.KeyBindings;
|
import WayofTime.bloodmagic.client.key.KeyBindings;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
@ -30,7 +31,9 @@ import WayofTime.bloodmagic.util.helper.TextHelper;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
|
|
||||||
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAltarReader, ISigil.Holding
|
||||||
{
|
{
|
||||||
public static final int inventorySize = 5;
|
public static final int inventorySize = 5;
|
||||||
|
|
||||||
|
@ -128,6 +131,13 @@ public class ItemSigilHolding extends ItemSigilBase implements IKeybindable, IAl
|
||||||
return ActionResult.newResult(EnumActionResult.PASS, stack);
|
return ActionResult.newResult(EnumActionResult.PASS, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public ItemStack getHeldItem(ItemStack holdingStack, EntityPlayer player)
|
||||||
|
{
|
||||||
|
return getInternalInventory(holdingStack).get(getCurrentItemOrdinal(holdingStack));
|
||||||
|
}
|
||||||
|
|
||||||
public void saveInventory(ItemStack itemStack, List<ItemStack> inventory)
|
public void saveInventory(ItemStack itemStack, List<ItemStack> inventory)
|
||||||
{
|
{
|
||||||
NBTTagCompound itemTag = itemStack.getTagCompound();
|
NBTTagCompound itemTag = itemStack.getTagCompound();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package WayofTime.bloodmagic.item.sigil;
|
package WayofTime.bloodmagic.item.sigil;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -31,6 +32,8 @@ public class ItemSigilLava extends ItemSigilBase
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package WayofTime.bloodmagic.item.sigil;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
import WayofTime.bloodmagic.util.helper.NumeralHelper;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
|
@ -33,6 +34,8 @@ public class ItemSigilSeer extends ItemSigilBase implements IAltarReader
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item.sigil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.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;
|
||||||
|
@ -50,6 +51,8 @@ public class ItemSigilTeleposition extends ItemSigilBase
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
||||||
|
@ -71,6 +74,8 @@ public class ItemSigilTeleposition extends ItemSigilBase
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.item.sigil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -69,6 +70,8 @@ public class ItemSigilTransposition extends ItemSigilBase
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return EnumActionResult.FAIL;
|
return EnumActionResult.FAIL;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package WayofTime.bloodmagic.item.sigil;
|
package WayofTime.bloodmagic.item.sigil;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -29,6 +30,8 @@ public class ItemSigilVoid extends ItemSigilBase
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package WayofTime.bloodmagic.item.sigil;
|
package WayofTime.bloodmagic.item.sigil;
|
||||||
|
|
||||||
|
import WayofTime.bloodmagic.api.iface.ISigil;
|
||||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||||
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
||||||
import net.minecraft.block.BlockCauldron;
|
import net.minecraft.block.BlockCauldron;
|
||||||
|
@ -34,6 +35,8 @@ public class ItemSigilWater extends ItemSigilBase
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
|
||||||
{
|
{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
if (stack.getItem() instanceof ISigil.Holding)
|
||||||
|
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
|
||||||
if (PlayerHelper.isFakePlayer(player))
|
if (PlayerHelper.isFakePlayer(player))
|
||||||
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
return ActionResult.newResult(EnumActionResult.FAIL, stack);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue