Rewrite Binding system to be fully automated
No more manual handling of binding items to players. Retains all previous functionality. I have tested on both the Client and Server and it seems to work just fine. If any issues arise from this, do not hesitate to yell at me. The deprecated methods will be removed after beta.
This commit is contained in:
parent
e219b50589
commit
8c1eaddb97
14 changed files with 152 additions and 165 deletions
|
@ -154,52 +154,6 @@ public class ItemBindable extends Item implements IBindable
|
|||
tooltip.add(TextHelper.localizeEffect("tooltip.BloodMagic.currentOwner", PlayerHelper.getUsernameFromStack(stack)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
BindableHelper.checkAndSetItemOwner(stack, player);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
BindableHelper.checkAndSetItemOwner(stack, player);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void damagePlayer(World world, EntityPlayer player, int damage)
|
||||
{
|
||||
if (world != null)
|
||||
{
|
||||
double posX = player.posX;
|
||||
double posY = player.posY;
|
||||
double posZ = player.posZ;
|
||||
world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
|
||||
float f = 1.0F;
|
||||
float f1 = f * 0.6F + 0.4F;
|
||||
float f2 = f * f * 0.7F - 0.5F;
|
||||
float f3 = f * f * 0.6F - 0.7F;
|
||||
for (int l = 0; l < 8; ++l)
|
||||
world.spawnParticle(EnumParticleTypes.REDSTONE, posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), f1, f2, f3);
|
||||
}
|
||||
for (int i = 0; i < damage; i++)
|
||||
{
|
||||
player.attackEntityFrom(BloodMagicAPI.getDamageSource(), 0F); // Emulate
|
||||
// an
|
||||
// attack
|
||||
player.setHealth(player.getHealth() - 1);
|
||||
|
||||
if (player.getHealth() <= 0.0005)
|
||||
{
|
||||
player.inventory.dropAllItems();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getLPUsed()
|
||||
{
|
||||
return this.lpUsed;
|
||||
|
|
|
@ -45,8 +45,6 @@ public class ItemBloodOrb extends ItemBindable implements IBloodOrb, IBindable
|
|||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
super.onItemRightClick(stack, world, player);
|
||||
|
||||
if (world == null)
|
||||
return stack;
|
||||
|
||||
|
|
|
@ -37,8 +37,6 @@ public class ItemBoundSword extends ItemSword implements IBindable
|
|||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
BindableHelper.checkAndSetItemOwner(stack, player);
|
||||
|
||||
if (!player.isSneaking() && getActivated(stack))
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
|
||||
|
|
|
@ -110,8 +110,6 @@ public class ItemBoundTool extends ItemBindable
|
|||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
BindableHelper.checkAndSetItemOwner(stack, player);
|
||||
|
||||
// if (!world.isRemote)
|
||||
{
|
||||
if (player.isSneaking())
|
||||
|
@ -136,15 +134,6 @@ public class ItemBoundTool extends ItemBindable
|
|||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonNetwork(stack, player, getLPUsed()))
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
|
|
|
@ -52,16 +52,13 @@ public class ItemTelepositionFocus extends ItemBindable
|
|||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (BindableHelper.checkAndSetItemOwner(stack, player))
|
||||
if (player.isSneaking())
|
||||
{
|
||||
if (player.isSneaking())
|
||||
{
|
||||
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, false);
|
||||
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, false);
|
||||
|
||||
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
setBlockPos(stack, world, mop.getBlockPos());
|
||||
}
|
||||
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
setBlockPos(stack, world, mop.getBlockPos());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,14 +48,6 @@ public class ItemSigilBase extends ItemBindable implements ISigil
|
|||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
super.onItemRightClick(stack, world, player);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)
|
||||
|
|
|
@ -23,22 +23,17 @@ public class ItemSigilBloodLight extends ItemSigilBase
|
|||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonNetwork(stack, player, getLPUsed() * 5) && !world.isRemote)
|
||||
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||
|
||||
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, false);
|
||||
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
|
||||
|
||||
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
||||
{
|
||||
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
|
||||
|
||||
if (world.isAirBlock(blockPos))
|
||||
{
|
||||
world.setBlockState(blockPos, ModBlocks.bloodLight.getDefaultState());
|
||||
}
|
||||
} else
|
||||
{
|
||||
world.spawnEntityInWorld(new EntityBloodLight(world, player));
|
||||
}
|
||||
if (world.isAirBlock(blockPos))
|
||||
world.setBlockState(blockPos, ModBlocks.bloodLight.getDefaultState());
|
||||
} else
|
||||
{
|
||||
world.spawnEntityInWorld(new EntityBloodLight(world, player));
|
||||
}
|
||||
|
||||
return stack;
|
||||
|
@ -52,15 +47,10 @@ public class ItemSigilBloodLight extends ItemSigilBase
|
|||
if (world.isRemote)
|
||||
return false;
|
||||
|
||||
if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonNetwork(stack, player, getLPUsed()))
|
||||
{
|
||||
BlockPos newPos = blockPos.offset(side);
|
||||
BlockPos newPos = blockPos.offset(side);
|
||||
|
||||
if (world.isAirBlock(newPos))
|
||||
{
|
||||
world.setBlockState(newPos, ModBlocks.bloodLight.getDefaultState());
|
||||
}
|
||||
}
|
||||
if (world.isAirBlock(newPos))
|
||||
world.setBlockState(newPos, ModBlocks.bloodLight.getDefaultState());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ItemSigilLava extends ItemSigilBase
|
|||
{
|
||||
super.onItemUse(stack, player, world, blockPos, side, hitX, hitY, hitZ);
|
||||
|
||||
if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack))
|
||||
if (world.isRemote || player.isSneaking() || isUnusable(stack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ public class ItemSigilToggleable extends ItemSigilBase
|
|||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
BindableHelper.checkAndSetItemOwner(stack, player);
|
||||
if (!world.isRemote && !isUnusable(stack))
|
||||
{
|
||||
if (player.isSneaking())
|
||||
|
@ -52,12 +51,7 @@ public class ItemSigilToggleable extends ItemSigilBase
|
|||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
super.onItemUse(stack, player, world, blockPos, side, hitX, hitY, hitZ);
|
||||
|
||||
if (BindableHelper.checkAndSetItemOwner(stack, player) && ItemBindable.syphonNetwork(stack, player, getLPUsed()))
|
||||
return onSigilUse(stack, player, world, blockPos, side, hitX, hitY, hitZ);
|
||||
|
||||
return false;
|
||||
return ItemBindable.syphonNetwork(stack, player, getLPUsed()) && onSigilUse(stack, player, world, blockPos, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
public boolean onSigilUse(ItemStack itemStack, EntityPlayer player, World world, BlockPos blockPos, EnumFacing side, float hitX, float hitY, float hitZ)
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ItemSigilVoid extends ItemSigilBase
|
|||
{
|
||||
super.onItemUse(stack, player, world, blockPos, side, hitX, hitY, hitZ);
|
||||
|
||||
if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack))
|
||||
if (world.isRemote || player.isSneaking() || isUnusable(stack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class ItemSigilWater extends ItemSigilBase
|
|||
{
|
||||
super.onItemUse(stack, player, world, blockPos, side, hitX, hitY, hitZ);
|
||||
|
||||
if (world.isRemote || !BindableHelper.checkAndSetItemOwner(stack, player) || player.isSneaking() || isUnusable(stack))
|
||||
if (world.isRemote || player.isSneaking() || isUnusable(stack))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue