Search in sources :

Example 1 with ItemTaglock

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);
}
Also used : ActionResult(net.minecraft.util.ActionResult) EnumActionResult(net.minecraft.util.EnumActionResult) EnumHand(net.minecraft.util.EnumHand) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) ItemTaglock(com.bewitchment.common.item.ItemTaglock)

Example 2 with ItemTaglock

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);
}
Also used : Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) ItemSpade(net.minecraft.item.ItemSpade) ItemFlintAndSteel(net.minecraft.item.ItemFlintAndSteel) ItemStack(net.minecraft.item.ItemStack) ItemTaglock(com.bewitchment.common.item.ItemTaglock)

Example 3 with ItemTaglock

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);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) TileEntityGlyph(com.bewitchment.common.block.tile.entity.TileEntityGlyph) ItemWaystone(com.bewitchment.common.item.ItemWaystone) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) ItemTaglock(com.bewitchment.common.item.ItemTaglock)

Aggregations

ItemTaglock (com.bewitchment.common.item.ItemTaglock)3 ItemStack (net.minecraft.item.ItemStack)3 TileEntityGlyph (com.bewitchment.common.block.tile.entity.TileEntityGlyph)1 ItemWaystone (com.bewitchment.common.item.ItemWaystone)1 IBlockState (net.minecraft.block.state.IBlockState)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Item (net.minecraft.item.Item)1 ItemFlintAndSteel (net.minecraft.item.ItemFlintAndSteel)1 ItemSpade (net.minecraft.item.ItemSpade)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ActionResult (net.minecraft.util.ActionResult)1 EnumActionResult (net.minecraft.util.EnumActionResult)1 EnumHand (net.minecraft.util.EnumHand)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1