@SideOnly(Side.CLIENT)
 /** A randomly called display update to be able to add particles or other items for display */
 public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
   if (par5Random.nextInt(100) == 0) {
     par1World.playSound(
         (double) par2 + 0.5D,
         (double) par3 + 0.5D,
         (double) par4 + 0.5D,
         Sound.portal,
         0.5F,
         par5Random.nextFloat() * 0.4F + 0.8F,
         false);
   }
   for (int l = 0; l < 4; ++l) {
     double d0 = (double) ((float) par2 + par5Random.nextFloat());
     double d1 = (double) ((float) par3 + par5Random.nextFloat());
     double d2 = (double) ((float) par4 + par5Random.nextFloat());
     double d3 = 0.0D;
     double d4 = 0.0D;
     double d5 = 0.0D;
     int i1 = par5Random.nextInt(2) * 2 - 1;
     d3 = ((double) par5Random.nextFloat() - 0.5D) * 0.5D;
     d4 = ((double) par5Random.nextFloat() - 0.5D) * 0.5D;
     d5 = ((double) par5Random.nextFloat() - 0.5D) * 0.5D;
     if (par1World.getBlockId(par2 - 1, par3, par4) != this.blockID
         && par1World.getBlockId(par2 + 1, par3, par4) != this.blockID) {
       d0 = (double) par2 + 0.5D + 0.25D * (double) i1;
       d3 = (double) (par5Random.nextFloat() * 2.0F * (float) i1);
     } else {
       d2 = (double) par4 + 0.5D + 0.25D * (double) i1;
       d5 = (double) (par5Random.nextFloat() * 2.0F * (float) i1);
     }
   }
 }
  public ActionResult<ItemStack> onItemRightClick(
      ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
    if (playerIn.fishEntity != null) {
      int i = playerIn.fishEntity.handleHookRetraction();
      itemStackIn.damageItem(i, playerIn);
      playerIn.swingArm(hand);
    } else {
      worldIn.playSound(
          (EntityPlayer) null,
          playerIn.posX,
          playerIn.posY,
          playerIn.posZ,
          SoundEvents.ENTITY_BOBBER_THROW,
          SoundCategory.NEUTRAL,
          0.5F,
          0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

      if (!worldIn.isRemote) {
        worldIn.spawnEntityInWorld(new EntityFishHook(worldIn, playerIn));
      }

      playerIn.swingArm(hand);
      playerIn.addStat(StatList.getObjectUseStats(this));
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
  }
  @Override
  public ActionResult<ItemStack> onItemRightClick(
      ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
    if (!playerIn.capabilities.isCreativeMode) {
      --itemStackIn.stackSize;
    }

    worldIn.playSound(
        null,
        playerIn.posX,
        playerIn.posY,
        playerIn.posZ,
        SoundEvents.ENTITY_SNOWBALL_THROW,
        SoundCategory.NEUTRAL,
        0.5F,
        0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote) {
      ThrowballType type =
          ThrowballType.values()[itemStackIn.getMetadata() % ThrowballType.values().length];
      launchThrowball(worldIn, playerIn, type, hand);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
  }
Example #4
0
  @Override
  public ActionResult<ItemStack> onItemRightClick(
      ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {

    if (!playerIn.capabilities.isCreativeMode) {
      itemStackIn.damageItem(1, playerIn);
      if (itemStackIn.getItemDamage() == 0) {
        itemStackIn = new ItemStack(ModItems.staff);
      }
    }

    worldIn.playSound(
        (EntityPlayer) null,
        playerIn.posX,
        playerIn.posY,
        playerIn.posZ,
        SoundEvents.ENTITY_SNOWBALL_THROW,
        SoundCategory.NEUTRAL,
        0.5F,
        0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote) {
      EntityLargeSnowBall snowball = new EntityLargeSnowBall(worldIn, playerIn);
      snowball.setHeadingFromThrower(
          playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
      worldIn.spawnEntityInWorld(snowball);
    }

    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
  }
  @Override
  public void onBlockDestroyedByPlayer(World world, int x, int y, int z, int p_149664_5_) {
    super.onBlockDestroyedByPlayer(world, x, y, z, p_149664_5_);

    if (world.isRemote) {
      FxSystemElectricArc.spawnArc(world, x + 0.5f, y + 0.5f, z + 0.5f, .3, 7);
      world.playSound(
          x,
          y,
          z,
          "advancedrocketry:ElectricShockSmall",
          .7f,
          0.975f + world.rand.nextFloat() * 0.05f,
          false);
    }
  }
  @Override
  public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
    super.randomDisplayTick(world, x, y, z, rand);

    if (world.getTotalWorldTime() % 100 == 0
        && world.getBiomeGenForCoords(x, z) == AdvancedRocketryBiomes.stormLandsBiome) {
      FxSystemElectricArc.spawnArc(world, x + 0.5f, y + 0.5f, z + 0.5f, .3, 7);
      world.playSound(
          x,
          y,
          z,
          "advancedrocketry:ElectricShockSmall",
          .7f,
          0.975f + world.rand.nextFloat() * 0.05f,
          false);
    }
  }
  protected void dispenseItem(World world, BlockPos pos) {
    world.withTileEntity(
        pos,
        TileEntityDispenser.class,
        var4 -> {
          int var5 = var4.func_146017_i();

          if (var5 < 0) {
            world.playSound(1001, pos, 0);
          } else {
            ItemStack var6 = var4.get(var5);
            IBehaviorDispenseItem var7 = this.getDispenserLogic(var6);

            if (var7 != IBehaviorDispenseItem.itemDispenseBehaviorProvider) {
              ItemStack var8 = var7.dispense(new BlockSource(world, pos), var6);
              var4.set(var5, var8.stackSize == 0 ? null : var8);
            }
          }
        });
  }
Example #8
0
  @Nonnull
  @Override
  public ActionResult<ItemStack> onItemRightClick(
      @Nonnull ItemStack stack, World world, EntityPlayer player, EnumHand hand) {
    if (!world.isRemote) {
      int offset = 3 + this.getCharge(stack);
      AxisAlignedBB box = player.getEntityBoundingBox().expand(offset, offset, offset);
      world.playSound(
          null,
          player.posX,
          player.posY,
          player.posZ,
          PESounds.POWER,
          SoundCategory.PLAYERS,
          1.0F,
          1.0F);
      WorldHelper.freezeInBoundingBox(world, box, player, false);
    }

    return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
  }
  @Override
  @SideOnly(Side.CLIENT)

  /** A randomly called display update to be able to add particles or other items for display */
  public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    if (par5Random.nextInt(100) == 0) {
      par1World.playSound(
          par2 + 0.5D,
          par3 + 0.5D,
          par4 + 0.5D,
          "portal.portal",
          0.5F,
          par5Random.nextFloat() * 0.4F + 0.8F,
          false);
    }

    for (int l = 0; l < 4; ++l) {
      double d0 = par2 + par5Random.nextFloat();
      double d1 = par3 + par5Random.nextFloat();
      double d2 = par4 + par5Random.nextFloat();
      double d3 = 0.0D;
      double d4 = 0.0D;
      double d5 = 0.0D;
      int i1 = par5Random.nextInt(2) * 2 - 1;
      d3 = (par5Random.nextFloat() - 0.5D) * 0.5D;
      d4 = (par5Random.nextFloat() - 0.5D) * 0.5D;
      d5 = (par5Random.nextFloat() - 0.5D) * 0.5D;

      if (par1World.getBlockId(par2 - 1, par3, par4) != this.blockID
          && par1World.getBlockId(par2 + 1, par3, par4) != this.blockID) {
        d0 = par2 + 0.5D + 0.25D * i1;
        d3 = par5Random.nextFloat() * 2.0F * i1;
      } else {
        d2 = par4 + 0.5D + 0.25D * i1;
        d5 = par5Random.nextFloat() * 2.0F * i1;
      }

      LCParticles.spawnParticle(par1World, "xenportal", d0, d1, d2, d3, d4, d5);
    }
  }
 public boolean onBlockActivated(
     World worldIn,
     BlockPos pos,
     IBlockState state,
     EntityPlayer playerIn,
     EnumHand hand,
     @Nullable ItemStack heldItem,
     EnumFacing side,
     float hitX,
     float hitY,
     float hitZ) {
   if (!playerIn.capabilities.allowEdit) {
     return false;
   } else {
     state = state.cycleProperty(MODE);
     float f = state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT ? 0.55F : 0.5F;
     worldIn.playSound(
         playerIn, pos, SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.BLOCKS, 0.3F, f);
     worldIn.setBlockState(pos, state, 2);
     this.onStateChange(worldIn, pos, state);
     return true;
   }
 }
 @Override
 public ActionResult<ItemStack> onItemRightClick(
     ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) {
   worldIn.playSound(
       (EntityPlayer) null,
       playerIn.posX,
       playerIn.posY,
       playerIn.posZ,
       SoundEvents.ENTITY_ENDERPEARL_THROW,
       SoundCategory.NEUTRAL,
       0.5F,
       0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
   playerIn.getCooldownTracker().setCooldown(this, cooldown);
   if (!worldIn.isRemote) {
     EntityEnderPearl entityenderpearl = new EntityEnderPearl(worldIn, playerIn);
     // func_184538_a
     entityenderpearl.setHeadingFromThrower(
         playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
     worldIn.spawnEntityInWorld(entityenderpearl);
   }
   super.onUse(itemStackIn, playerIn, worldIn, hand);
   return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
 }
  /** A randomly called display update to be able to add particles or other items for display */
  @SideOnly(Side.CLIENT)
  public void randomDisplayTick(World w, int x, int y, int z, Random rand) {
    if (rand.nextInt(100) == 0) {
      w.playSound(
          (double) x + 0.5D,
          (double) y + 0.5D,
          (double) z + 0.5D,
          "portal.portal",
          0.5F,
          rand.nextFloat() * 0.4F + 0.8F,
          false);
    }

    for (int l = 0; l < 4; ++l) {
      double d0 = (double) ((float) x + rand.nextFloat());
      double d1 = (double) ((float) y + rand.nextFloat());
      double d2 = (double) ((float) z + rand.nextFloat());
      double d3 = ((double) rand.nextFloat() - 0.5D) * 0.5D;
      double d4 = ((double) rand.nextFloat() - 0.5D) * 0.5D;
      double d5 = ((double) rand.nextFloat() - 0.5D) * 0.5D;

      w.spawnParticle("portal", d0, d1, d2, d3, d4, d5);
    }
  }
Example #13
0
  @Override
  public boolean onBlockActivated(
      World world,
      BlockPos pos,
      IBlockState state,
      EntityPlayer playerIn,
      EnumHand hand,
      @Nullable ItemStack heldItem,
      EnumFacing face,
      float clickX,
      float clickY,
      float clickZ) {
    super.onBlockActivated(
        world, pos, state, playerIn, hand, heldItem, face, clickX, clickY, clickZ); // EIO

    world.notifyBlockUpdate(
        pos, state, state,
        3); // markBlockForUpdate( pos ); // Makes the server call getDescriptionPacket for a full
            // data sync
    if (activeFace(state) != face) {
      return false;
    }

    if (!world.isRemote) {
      double faceX = 0;
      double faceY = 0;

      switch (face.ordinal()) {
        case 0: // bottom
          switch (state.getValue(FACING).getHorizontalIndex()) {
            case 0: // south
              faceX = clickX;
              faceY = 1 - clickZ;
              break;
            case 1: // west
              faceX = clickZ;
              faceY = clickX;
              break;
            case 2: // north
              faceX = 1 - clickX;
              faceY = clickZ;
              break;
            case 3: // east
              faceX = 1 - clickZ;
              faceY = 1 - clickX;
              break;
          }
          break;
        case 1: // top
          switch (state.getValue(FACING).getHorizontalIndex()) {
            case 0: // south
              faceX = clickX;
              faceY = clickZ;
              break;
            case 1: // west
              faceX = clickZ;
              faceY = 1 - clickX;
              break;
            case 2: // north
              faceX = 1 - clickX;
              faceY = 1 - clickZ;
              break;
            case 3: // east
              faceX = 1 - clickZ;
              faceY = clickX;
              break;
          }
          break;
        case 2: // north
          faceX = 1 - clickX;
          faceY = 1 - clickY;
          break;
        case 3: // south
          faceX = clickX;
          faceY = 1 - clickY;
          break;
        case 4: // west
          faceX = clickZ;
          faceY = 1 - clickY;
          break;
        case 5: // east
          faceX = 1 - clickZ;
          faceY = 1 - clickY;
      }

      double bezel = 2.0 / 16;
      int button = -1;
      if ((faceX > bezel) && (faceX < (1 - bezel)) && (faceY > bezel) && (faceY < (1 - bezel))) {
        int bx = (int) ((faceX - bezel) * 16 / 3);
        int by = (int) ((faceY - bezel) * 16 / 3);
        // LogHelper.info("bx " + bx + " by " + by + " button " + button + " bezel " + bezel);
        button = bx + 4 * by;
      }
      if (button != -1) {
        // LogHelper.info("Playing sound");
        world.playSound(
            null, pos, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.BLOCKS, 0.2F, 0.7F);
      }

      TileEntity tile = world.getTileEntity(pos);
      if (tile != null && tile instanceof TileEntityButtons) {
        TileEntityButtons buttonPanel = (TileEntityButtons) tile;
        buttonPanel.setSignal(button, 30); // reset button countdown
      }

      world.notifyNeighborsOfStateChange(pos, this);
      // world.markAndNotifyBlock(x,y,z,world.getChunkFromBlockCoords(x,z),this,this,3);
    }

    return true;
  }
Example #14
0
  /**
   * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
   * world, entityPlayer
   */
  @Override
  public ItemStack onItemRightClick(ItemStack bucket, World world, EntityPlayer user) {
    boolean flag = this.isFull == Blocks.air;
    MovingObjectPosition movingobjectposition =
        this.getMovingObjectPositionFromPlayer(world, user, flag);

    if (movingobjectposition == null) {
      return bucket;
    } else {
      if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
        int x = movingobjectposition.blockX;
        int y = movingobjectposition.blockY;
        int z = movingobjectposition.blockZ;

        if (!world.canMineBlock(user, x, y, z)) {
          return bucket;
        }

        if (flag) {
          if (!user.canPlayerEdit(x, y, z, movingobjectposition.sideHit, bucket)) {
            return bucket;
          }

          Material material = world.getBlock(x, y, z).getMaterial();
          int l = world.getBlockMetadata(x, y, z);

          if (material == Material.water && l == 0) {
            world.setBlockToAir(x, y, z);
            return this.createNewInstance(bucket, user, ToolListMF.bucketwood_water, 0);
          }

          if (material == Material.lava && l == 0) {
            world.playSound(x + 0.5, y + 0.5, z + 0.5, "random.fizz", 1.0F, 1.0F, true);
            world.spawnParticle("largeSmoke", x + 0.5, y + 1F, z + 0.5, 0F, 0.5F, 0F);
            return this.createNewInstance(bucket, user, Items.coal, 1);
          }
        } else {
          if (this.isFull == Blocks.air) {
            return new ItemStack(ToolListMF.bucketwood_empty);
          }

          if (movingobjectposition.sideHit == 0) {
            --y;
          }

          if (movingobjectposition.sideHit == 1) {
            ++y;
          }

          if (movingobjectposition.sideHit == 2) {
            --z;
          }

          if (movingobjectposition.sideHit == 3) {
            ++z;
          }

          if (movingobjectposition.sideHit == 4) {
            --x;
          }

          if (movingobjectposition.sideHit == 5) {
            ++x;
          }

          if (!user.canPlayerEdit(x, y, z, movingobjectposition.sideHit, bucket)) {
            return bucket;
          }

          if (this.tryPlaceContainedLiquid(world, x, y, z) && !user.capabilities.isCreativeMode) {
            return new ItemStack(ToolListMF.bucketwood_empty);
          }
        }
      }

      return bucket;
    }
  }
 @SideOnly(Side.CLIENT)
 public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
   if (par5Random.nextInt(24) == 0) {
     par1World.playSound(
         par2 + 0.5F,
         par3 + 0.5F,
         par4 + 0.5F,
         "fire.fire",
         1.0F + par5Random.nextFloat(),
         par5Random.nextFloat() * 0.7F + 0.3F,
         false);
   }
   if ((!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4))
       && (!Main.TutorialFire1.canBlockCatchFire(
           par1World, par2, par3 - 1, par4, ForgeDirection.UP))) {
     if (Main.TutorialFire1.canBlockCatchFire(
         par1World, par2 - 1, par3, par4, ForgeDirection.EAST)) {
       for (int l = 0; l < 2; l++) {
         float f = par2 + par5Random.nextFloat() * 0.1F;
         float f1 = par3 + par5Random.nextFloat();
         float f2 = par4 + par5Random.nextFloat();
         par1World.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D);
       }
     }
     if (Main.TutorialFire1.canBlockCatchFire(
         par1World, par2 + 1, par3, par4, ForgeDirection.WEST)) {
       for (int l = 0; l < 2; l++) {
         float f = par2 + 1 - par5Random.nextFloat() * 0.1F;
         float f1 = par3 + par5Random.nextFloat();
         float f2 = par4 + par5Random.nextFloat();
         par1World.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D);
       }
     }
     if (Main.TutorialFire1.canBlockCatchFire(
         par1World, par2, par3, par4 - 1, ForgeDirection.SOUTH)) {
       for (int l = 0; l < 2; l++) {
         float f = par2 + par5Random.nextFloat();
         float f1 = par3 + par5Random.nextFloat();
         float f2 = par4 + par5Random.nextFloat() * 0.1F;
         par1World.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D);
       }
     }
     if (Main.TutorialFire1.canBlockCatchFire(
         par1World, par2, par3, par4 + 1, ForgeDirection.NORTH)) {
       for (int l = 0; l < 2; l++) {
         float f = par2 + par5Random.nextFloat();
         float f1 = par3 + par5Random.nextFloat();
         float f2 = par4 + 1 - par5Random.nextFloat() * 0.1F;
         par1World.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D);
       }
     }
     if (Main.TutorialFire1.canBlockCatchFire(
         par1World, par2, par3 + 1, par4, ForgeDirection.DOWN)) {
       for (int l = 0; l < 2; l++) {
         float f = par2 + par5Random.nextFloat();
         float f1 = par3 + 1 - par5Random.nextFloat() * 0.1F;
         float f2 = par4 + par5Random.nextFloat();
         par1World.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D);
       }
     }
   } else {
     for (int l = 0; l < 3; l++) {
       float f = par2 + par5Random.nextFloat();
       float f1 = par3 + par5Random.nextFloat() * 0.5F + 0.5F;
       float f2 = par4 + par5Random.nextFloat();
       par1World.spawnParticle("largesmoke", f, f1, f2, 0.0D, 0.0D, 0.0D);
     }
   }
 }
  /**
   * Called when the player stops using an Item (stops holding the right mouse button).
   *
   * @param timeLeft The amount of ticks left before the using would have been complete
   */
  @Override
  public void onPlayerStoppedUsing(
      ItemStack stack, World worldIn, EntityLivingBase playerIn, int timeLeft) {
    if (playerIn instanceof EntityPlayer) {
      EntityPlayer player = (EntityPlayer) playerIn;

      int itemUseDuration = this.getMaxItemUseDuration(stack) - timeLeft;
      itemUseDuration =
          net.minecraftforge.event.ForgeEventFactory.onArrowLoose(
              stack,
              worldIn,
              player,
              itemUseDuration,
              isUsableByPlayer(stack, (EntityPlayer) playerIn));

      if (isUsableByPlayer(stack, player)) {
        float arrowDamage = getArrowDamage(itemUseDuration);
        // I don't understand why this is done, but ItemBow does it, so we'll do it
        if ((double) arrowDamage < 0.1D) {
          return;
        }

        //            MEMLogger.info("ItemCustomBow onPlayerStoppedUsing(): f = " + arrowDamage + ";
        // j = " + itemUseDuration + "; timeLeft = " + timeLeft);

        EntityArrow entityarrow = getNewEntityArrow(worldIn, player, itemUseDuration);
        //	            FFQLogger.info("Created a(n) " + entityarrow.getName() + " [damage: " +
        // entityarrow.getDamage() + "]");

        entityarrow.setIsCritical(shotIsCritical(itemUseDuration, arrowDamage));
        //            if (entityarrow.getIsCritical()) {
        //                MEMLogger.info("ItemCustomBow onPlayerStoppedUsing(): PEW! PEW!");
        //            }

        applyEnchantments(entityarrow, stack);
        initializeArrowVelocity(entityarrow, player, arrowDamage);

        takeDamage(1, stack, player);

        worldIn.playSound(
            player.posX,
            player.posY,
            player.posZ,
            SoundEvents.ENTITY_ARROW_SHOOT,
            SoundCategory.HOSTILE,
            1.0F,
            (1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + arrowDamage * 0.5F),
            true);

        if (hasInfiniteArrows(stack, player)) {
          entityarrow.pickupStatus = EntityArrow.PickupStatus.CREATIVE_ONLY;
        } else {
          this.consumeAmmo(stack, worldIn, player);
        }

        player.addStat(StatList.getObjectUseStats(this));

        if (!worldIn.isRemote) {
          worldIn.spawnEntityInWorld(entityarrow);
        }
      }
    }
  }
Example #17
0
  @SubscribeEvent(priority = EventPriority.HIGHEST)
  public void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) {

    World world = event.getWorld();
    BlockPos pos = event.getPos();

    if (world.isRemote) return;

    TileEntity tileEntity = world.getTileEntity(pos);
    if (tileEntity instanceof TileEntityLockable) {
      TileEntityLockable tileEntityLockable = (TileEntityLockable) tileEntity;

      EntityPlayerMP player = (EntityPlayerMP) event.getEntityPlayer();

      ItemStack current = player.getHeldItemMainhand();
      if (tileEntityLockable.isLocked()) {
        if (current != null && current.getItem() == ZeiyoItems.key) {
          String unlockPass = new StringBuilder(current.getDisplayName()).reverse().toString();

          if (tileEntityLockable.getLockCode().getLock().equals(unlockPass)) {
            tileEntityLockable.setLockCode(new LockCode(""));
            world.playSound(
                (EntityPlayer) null,
                player.posX,
                player.posY,
                player.posZ,
                SoundEvents.UI_BUTTON_CLICK,
                SoundCategory.BLOCKS,
                0.5F,
                world.rand.nextFloat() * 0.1F + 0.9F);
            player.addChatComponentMessage(
                new TextComponentTranslation("text.key.successOnUnlock", new Object[0]), true);

          } else if (!tileEntityLockable.getLockCode().getLock().equals(current.getDisplayName())) {
            world.playSound(
                (EntityPlayer) null,
                player.posX,
                player.posY,
                player.posZ,
                SoundEvents.UI_BUTTON_CLICK,
                SoundCategory.BLOCKS,
                0.5F,
                world.rand.nextFloat() * 0.1F + 0.9F);
            player.addChatComponentMessage(
                new TextComponentTranslation("text.key.errorOnKey", new Object[0]), true);
            event.setCanceled(true);
          }
        } else {
          world.playSound(
              (EntityPlayer) null,
              player.posX,
              player.posY,
              player.posZ,
              SoundEvents.UI_BUTTON_CLICK,
              SoundCategory.BLOCKS,
              0.5F,
              world.rand.nextFloat() * 0.1F + 0.9F);
          player.addChatComponentMessage(
              new TextComponentTranslation("text.key.errorOnBlock", new Object[0]), true);
          event.setCanceled(true);
        }
      } else {
        if (current != null && current.getItem() == ZeiyoItems.key) {
          if (!current
              .getDisplayName()
              .equals(I18n.translateToLocal(current.getItem().getUnlocalizedName() + ".name"))) {
            tileEntityLockable.setLockCode(new LockCode(current.getDisplayName()));
            world.playSound(
                (EntityPlayer) null,
                player.posX,
                player.posY,
                player.posZ,
                SoundEvents.UI_BUTTON_CLICK,
                SoundCategory.BLOCKS,
                0.5F,
                world.rand.nextFloat() * 0.1F + 0.9F);
            player.addChatComponentMessage(
                new TextComponentTranslation("text.key.successOnLock", new Object[0]), true);

          } else {

            player.addChatComponentMessage(
                new TextComponentTranslation("text.key.errorOnKeyName", new Object[0]), true);
          }
          event.setCanceled(true);
        }
      }
    }
  }