use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.
the class ItemBloodOrb method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
BloodOrb orb = getOrb(stack);
if (orb == null)
return ActionResult.newResult(EnumActionResult.FAIL, stack);
if (world == null)
return super.onItemRightClick(world, player, hand);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
if (PlayerHelper.isFakePlayer(player))
return super.onItemRightClick(world, player, hand);
if (!stack.hasTagCompound())
return super.onItemRightClick(world, player, hand);
Binding binding = getBinding(stack);
if (binding == null)
return super.onItemRightClick(world, player, hand);
if (world.isRemote)
return super.onItemRightClick(world, player, hand);
SoulNetwork ownerNetwork = NetworkHelper.getSoulNetwork(binding);
if (binding.getOwnerId().equals(player.getGameProfile().getId()))
ownerNetwork.setOrbTier(orb.getTier());
// Add LP to owner's network
ownerNetwork.add(200, orb.getCapacity());
// Hurt whoever is using it
ownerNetwork.hurtPlayer(player, 200);
return super.onItemRightClick(world, player, hand);
}
use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.
the class ItemSigilVoid method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos blockPos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
if (PlayerHelper.isFakePlayer(player))
return EnumActionResult.FAIL;
if (world.isRemote || player.isSneaking() || isUnusable(stack)) {
return EnumActionResult.FAIL;
}
if (!world.canMineBlockBody(player, blockPos)) {
return EnumActionResult.FAIL;
}
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
TileEntity tile = world.getTileEntity(blockPos);
if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
FluidStack amount = handler.drain(1000, false);
if (amount != null && amount.amount > 0 && network.syphonAndDamage(player, getLpUsed())) {
handler.drain(1000, true);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
BlockPos newPos = blockPos.offset(side);
if (!player.canPlayerEdit(newPos, side, stack)) {
return EnumActionResult.FAIL;
}
if (world.getBlockState(newPos).getBlock() instanceof IFluidBlock && network.syphonAndDamage(player, getLpUsed())) {
world.setBlockToAir(newPos);
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.
the class ItemSigilBloodLight method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (stack.getItem() instanceof ISigil.Holding)
stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
if (PlayerHelper.isFakePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, stack);
RayTraceResult mop = this.rayTrace(world, player, false);
if (getCooldownRemainder(stack) > 0)
return super.onItemRightClick(world, player, hand);
if (mop != null && mop.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos blockPos = mop.getBlockPos().offset(mop.sideHit);
if (world.isAirBlock(blockPos)) {
world.setBlockState(blockPos, RegistrarBloodMagicBlocks.BLOOD_LIGHT.getDefaultState());
if (!world.isRemote) {
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
network.syphonAndDamage(player, getLpUsed());
}
resetCooldown(stack);
player.swingArm(hand);
return super.onItemRightClick(world, player, hand);
}
} else {
if (!world.isRemote) {
SoulNetwork network = NetworkHelper.getSoulNetwork(getBinding(stack));
world.spawnEntity(new EntityBloodLight(world, player));
network.syphonAndDamage(player, getLpUsed());
}
resetCooldown(stack);
}
return super.onItemRightClick(world, player, hand);
}
use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.
the class TileAlchemyTable method getContainedLp.
public int getContainedLp() {
ItemStack orbStack = getStackInSlot(orbSlot);
if (!orbStack.isEmpty()) {
if (orbStack.getItem() instanceof IBloodOrb) {
NBTTagCompound itemTag = orbStack.getTagCompound();
if (itemTag == null) {
return 0;
}
String ownerUUID = itemTag.getString(Constants.NBT.OWNER_UUID);
if (Strings.isNullOrEmpty(ownerUUID)) {
return 0;
}
SoulNetwork network = NetworkHelper.getSoulNetwork(ownerUUID);
return network.getCurrentEssence();
}
}
return 0;
}
use of WayofTime.bloodmagic.core.data.SoulNetwork in project BloodMagic by WayofTime.
the class ItemLivingArmour method damageArmor.
@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
int preDamage = stack.getItemDamage();
if (source.isUnblockable()) {
return;
}
if (damage > this.getMaxDamage(stack) - this.getDamage(stack)) {
// TODO: Syphon a load of LP.
if (entity.getEntityWorld().isRemote && entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
SoulNetwork network = NetworkHelper.getSoulNetwork(player);
network.syphonAndDamage(player, damage * 100);
}
return;
}
stack.damageItem(damage, entity);
int receivedDamage = stack.getItemDamage() - preDamage;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (LivingArmour.hasFullSet(player)) {
LivingArmour armour = ItemLivingArmour.getLivingArmour(stack);
if (armour != null) {
StatTrackerRepairing.incrementCounter(armour, receivedDamage);
}
}
}
} else {
stack.damageItem(damage, entity);
}
// TODO Armour shouldn't get damaged... for now
return;
}
Aggregations