use of com.bewitchment.common.item.ItemTaglock in project Bewitchment by Um-Mitternacht.
the class ItemPoppet method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
EnumHand otherHand = hand == EnumHand.MAIN_HAND ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND;
if (!player.getHeldItem(hand).hasTagCompound() && player.getHeldItem(otherHand).getItem() instanceof ItemTaglock && player.getHeldItem(otherHand).hasTagCompound() && player.getHeldItem(otherHand).getTagCompound().hasKey("boundId") && player.getHeldItem(otherHand).getTagCompound().hasKey("boundName")) {
ItemStack result = player.getHeldItem(hand);
ItemStack taglock = player.getHeldItem(otherHand);
result.setTagCompound(new NBTTagCompound());
result.getTagCompound().setString("boundId", taglock.getTagCompound().getString("boundId"));
result.getTagCompound().setString("boundName", taglock.getTagCompound().getString("boundName"));
player.setHeldItem(hand, result);
player.getHeldItem(otherHand).shrink(1);
if (world.isRemote)
world.playSound(player, player.getPosition(), SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.NEUTRAL, 10.0F, 1.0F);
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand));
}
return super.onItemRightClick(world, player, hand);
}
use of com.bewitchment.common.item.ItemTaglock in project Bewitchment by Um-Mitternacht.
the class TileEntityBrazier method activate.
@Override
public boolean activate(World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing face) {
IBlockState state = world.getBlockState(pos);
if (!state.getValue(BlockBrazier.LIT)) {
if (!player.isSneaking()) {
if (player.getHeldItem(hand).getItem() instanceof ItemFlintAndSteel) {
if (!isEmpty(handler)) {
world.setBlockState(pos, state.withProperty(BlockBrazier.LIT, true));
if (player.world.isRemote)
player.world.playSound(player, pos, SoundEvents.ENTITY_BLAZE_SHOOT, SoundCategory.BLOCKS, 1.0F, 1.0F);
getIncense();
if (incense == null)
curse(player);
clearBrazier();
markDirty();
return true;
}
return false;
} else {
int slot = getFirstEmptySlot(handler);
if (slot != -1) {
Item heldItem = player.getHeldItem(hand).getItem();
if (heldItem.getContainerItem() != null)
Util.giveItem(player, new ItemStack(heldItem.getContainerItem()));
else if (heldItem instanceof ItemTaglock)
Util.giveItem(player, new ItemStack(ModObjects.taglock));
player.inventory.setItemStack(handler.insertItem(slot, player.inventory.decrStackSize(player.inventory.currentItem, 1), false));
markDirty();
world.notifyBlockUpdate(pos, state, state, 3);
return true;
}
}
} else
return false;
} else if (player.getHeldItem(hand).getItem() instanceof ItemSpade) {
stopBurning();
return true;
}
return super.activate(world, pos, player, hand, face);
}
use of com.bewitchment.common.item.ItemTaglock in project Bewitchment by Um-Mitternacht.
the class RitualTeleport method onFinished.
@Override
public void onFinished(World world, BlockPos altarPos, BlockPos effectivePos, EntityPlayer caster, ItemStackHandler inventory) {
world.playSound(null, effectivePos, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.BLOCKS, 0.7f, 0.7f);
BlockPos pos0 = null;
int dimension = 0;
if (world.getTileEntity(effectivePos) instanceof TileEntityGlyph) {
for (int i = 0; i < inventory.getSlots(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack.getItem() instanceof ItemWaystone) {
pos0 = BlockPos.fromLong(stack.getTagCompound().getLong("location"));
dimension = stack.getTagCompound().getInteger("dimension");
stack.damageItem(1, caster);
break;
}
if (stack.getItem() instanceof ItemTaglock) {
for (Entity entity : world.loadedEntityList) {
if (entity.getPersistentID().equals(UUID.fromString(stack.getTagCompound().getString("boundId")))) {
pos0 = entity.getPosition();
dimension = entity.dimension;
stack.shrink(1);
break;
}
}
}
}
}
if (pos0 == null || dimension != world.provider.getDimension())
return;
for (Entity entity : world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(effectivePos).grow(3))) {
world.playSound(null, entity.getPosition(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
if (entity instanceof EntityPlayer)
Util.teleportPlayer((EntityPlayer) entity, pos0.getX() + 0.5, pos0.getY(), pos0.getZ() + 0.5);
else
entity.setPositionAndUpdate(pos0.getX() + 0.5, pos0.getY(), pos0.getZ() + 0.5);
world.playSound(null, entity.getPosition(), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
}
}
Aggregations