Пример #1
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityPlayer,
      int side,
      float par7,
      float par8,
      float par9) {

    if (ConduitUtil.isToolEquipped(entityPlayer)) {
      if (entityPlayer.isSneaking()
          && entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
        IToolWrench wrench = (IToolWrench) entityPlayer.getCurrentEquippedItem().getItem();
        if (wrench.canWrench(entityPlayer, x, y, z)) {
          removedByPlayer(world, entityPlayer, x, y, z, false);
          if (entityPlayer.getCurrentEquippedItem().getItem() instanceof IToolWrench) {
            ((IToolWrench) entityPlayer.getCurrentEquippedItem().getItem())
                .wrenchUsed(entityPlayer, x, y, z);
          }
          return true;
        }
      }
    }
    if (entityPlayer.isSneaking()) {
      return false;
    }
    entityPlayer.openGui(EnderIO.instance, GuiHandler.GUI_ID_ENCHANTER, world, x, y, z);
    return true;
  }
Пример #2
0
 @SubscribeEvent
 public void onPlayerInteract(PlayerInteractEvent e) {
   EntityPlayer player = e.entityPlayer;
   if (player != null && !player.worldObj.isRemote) {
     ItemStack heldItem = player.getHeldItem();
     if (heldItem != null && heldItem.getItem() == IntegrationForestry.itemStickImpregnated) {
       if (e.action == Action.RIGHT_CLICK_AIR) {
         findTarget(player);
       } else if (e.action == Action.RIGHT_CLICK_BLOCK) {
         if (player.isSneaking() && e.world.blockExists(e.x, e.y, e.z)) {
           TileEntity te = e.world.getTileEntity(e.x, e.y, e.z);
           if (te instanceof IBeeHousing) {
             makeSwarm(e, player, ((IBeeHousing) te));
           } else {
             findTarget(player);
           }
         } else {
           findTarget(player);
         }
       }
     } else if (heldItem == null && e.action == Action.RIGHT_CLICK_BLOCK) {
       if (player.isSneaking() && e.world.blockExists(e.x, e.y, e.z)) {
         TileEntity te = e.world.getTileEntity(e.x, e.y, e.z);
         if (te instanceof IBeeHousing) {
           makeSwarm(e, player, ((IBeeHousing) te));
         }
       }
     }
   }
 }
Пример #3
0
  /** Called upon block activation (right click on the block.) */
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    TEHopper te = getHopperTE(world, x, y, z);
    if (world.isRemote) {
      if (te != null && te.pressBlock != null && player.isSneaking()) {
        te.pressBlock = null;
        te.pressCooldown = 0;
      }
      return true;
    } else {
      if (te != null && te.pressCooldown == 0) {
        player.openGui(TerraFirmaCraft.instance, 49, world, x, y, z);
      } else if (te != null && te.pressBlock != null && player.isSneaking()) {
        TFC_Core.giveItemToPlayer(te.pressBlock, player);
        te.pressBlock = null;
        te.pressCooldown = 0;
      }

      return true;
    }
  }
Пример #4
0
 @Override
 public boolean onItemUseFirst(
     ItemStack stack,
     EntityPlayer player,
     World world,
     int x,
     int y,
     int z,
     int side,
     float hitX,
     float hitY,
     float hitZ) {
   if (!player.isSneaking()) {
     DebugHelper.debug(player, world, x, y, z);
   } else if (world.getBlock(x, y, z) instanceof BlockBush) {
     if (player.isSneaking()) {
       world.getBlock(x, y, z).updateTick(world, x, y, z, world.rand);
     }
   } else {
     if (!world.isRemote) {
       EntityVillager entityvillager = new EntityVillagerFarmer(world, WorldGen.getVillagerId());
       entityvillager.setLocationAndAngles(
           (double) x + 0.5D, (double) y + 1, (double) z + 0.5D, 0.0F, 0.0F);
       world.spawnEntityInWorld(entityvillager);
     }
   }
   return false;
 }
Пример #5
0
  @SubscribeEvent
  public void playerTick(TickEvent.PlayerTickEvent event) {
    EntityPlayer player = event.player;
    TPlayerStats stats = TPlayerStats.get(player);

    // Wall climb
    if (stats.climbWalls) {
      double motionX = player.posX - player.lastTickPosX;
      double motionZ = player.posZ - player.lastTickPosZ;
      double motionY = player.posY - player.lastTickPosY - 0.762;
      if (motionY > 0.0D && (motionX == 0D || motionZ == 0D)) {
        player.fallDistance = 0.0F;
      }
    }

    // Feet changes
    ItemStack feet = player.getCurrentArmor(0);
    if (feet != null) {
      if (feet.getItem() instanceof IModifyable && !player.isSneaking()) {
        NBTTagCompound tag =
            feet.getTagCompound().getCompoundTag(((IModifyable) feet.getItem()).getBaseTagName());
        int sole = tag.getInteger("Slimy Soles");
        if (sole > 0) {
          if (!player.isSneaking() && player.onGround && prevMotionY < -0.4)
            player.motionY = -prevMotionY * (Math.min(0.99, sole * 0.2));
        }
      }
      prevMotionY = player.motionY;
    }
    if (feet != prevFeet) {
      if (prevFeet != null && prevFeet.getItem() instanceof TravelGear) player.stepHeight -= 0.6f;
      if (feet != null && feet.getItem() instanceof TravelGear) player.stepHeight += 0.6f;
      prevFeet = feet;
    }
    // TODO: Proper minimap support
    /*ItemStack stack = player.inventory.getStackInSlot(8);
    if (stack != null && stack.getItem() instanceof ItemMap)
    {
        stack.getItem().onUpdate(stack, player.worldObj, player, 8, true);
    }*/
    if (!player.isPlayerSleeping()) {
      ItemStack chest = player.getCurrentArmor(2);
      if (chest == null || !(chest.getItem() instanceof IModifyable)) {
        if (!morphLoaded || !morphed) PlayerAbilityHelper.setEntitySize(player, 0.6F, 1.8F);
      } else {
        NBTTagCompound tag =
            chest.getTagCompound().getCompoundTag(((IModifyable) chest.getItem()).getBaseTagName());
        int dodge = tag.getInteger("Perfect Dodge");
        if (dodge > 0) {
          if (!morphLoaded || !morphed)
            PlayerAbilityHelper.setEntitySize(
                player, Math.max(0.15F, 0.6F - (dodge * 0.09f)), 1.8F - (dodge * 0.04f));
        }
      }
    }
  }
Пример #6
0
  public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
    DimensionalLinkEntry[] entries = readEntries(itemStack);
    if (player.isSneaking()) {
      if (!world.isRemote) {
        int dimID = world.provider.dimensionId;
        DimensionalLinkEntry alreadyHasForThisWorld = null;
        for (DimensionalLinkEntry entry : entries)
          if (entry.dimID == dimID) alreadyHasForThisWorld = entry;
        if (alreadyHasForThisWorld != null) removeEntry(itemStack, alreadyHasForThisWorld.dimID);
        addEntry(
            itemStack,
            new DimensionalLinkEntry(
                dimID,
                (int) Math.floor(player.posX),
                (int) Math.floor(player.posY),
                (int) Math.floor(player.posZ)));

        player.addChatMessage(EnumChatFormatting.DARK_GREEN + "Warp point for this world set.");
      }
    } else {
      int dimID = world.provider.dimensionId;
      DimensionalLinkEntry link = null;
      for (DimensionalLinkEntry entry : entries) if (entry.dimID == dimID) link = entry;
      if (link != null) {
        double targetX = link.x + 0.5D;
        double targetY = link.y + 1.0D;
        double targetZ = link.z + 0.5D;
        EAVector3 targetVec = new EAVector3(targetX, targetY, targetZ);
        EAVector3 playerVec = EAVector3.fromEntityCenter(player);
        double distance = targetVec.subtract(playerVec).mag();
        int rfToConsume = (int) (distance * 2500.0D);
        if ((getEnergyStored(itemStack) >= rfToConsume)
            || ((player.capabilities.isCreativeMode) && (ensureCooldown(itemStack)))) {
          for (int i = 0; i < 128; i++) {
            world.spawnParticle(
                "portal",
                targetX,
                targetY,
                targetZ,
                world.rand.nextGaussian(),
                0.0D,
                world.rand.nextGaussian());
          }

          if (!world.isRemote) {
            if (!player.capabilities.isCreativeMode) extractEnergy(itemStack, rfToConsume, false);
            player.setPositionAndUpdate(targetX, targetY, targetZ);
            player.addChatMessage(EnumChatFormatting.DARK_GREEN + "Teleported.");
          }
        } else {
          player.addChatMessage(EnumChatFormatting.DARK_RED + "Not enough energy.");
        }
      } else {
        player.addChatMessage(
            EnumChatFormatting.DARK_RED + "Warp point is not set for this world.");
      }
    }

    return itemStack;
  }
Пример #7
0
  @Override
  public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) {
    if (player.isSneaking()) {
      long ticksSinceBlink = EnderIO.proxy.getTickCount() - lastBlickTick;
      if (ticksSinceBlink < 0) {
        lastBlickTick = -1;
      }
      if (Config.travelStaffBlinkEnabled
          && world.isRemote
          && ticksSinceBlink >= Config.travelStaffBlinkPauseTicks) {
        if (TravelController.instance.doBlink(equipped, player)) {
          player.swingItem();
          lastBlickTick = EnderIO.proxy.getTickCount();
        }
      }
      return equipped;
    }

    if (world.isRemote) {
      TravelController.instance.activateTravelAccessable(
          equipped, world, player, TravelSource.STAFF);
    }
    player.swingItem();
    return equipped;
  }
 public boolean onBlockActivated(
     World aWorld,
     int aX,
     int aY,
     int aZ,
     EntityPlayer aPlayer,
     int aSide,
     float par1,
     float par2,
     float par3) {
   TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
   if ((tTileEntity == null) || (aPlayer.isSneaking())) {
     return false;
   }
   if ((tTileEntity instanceof IGregTechTileEntity)) {
     if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) {
       return false;
     }
     if ((!aWorld.isRemote) && (!((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer))) {
       return true;
     }
     return ((IGregTechTileEntity) tTileEntity)
         .onRightclick(aPlayer, (byte) aSide, par1, par2, par3);
   }
   return false;
 }
Пример #9
0
 /** Called when the blocks is activated. We are using it to open our GUI */
 @Override
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer player,
     int par6,
     float par7,
     float par8,
     float par9) {
   if (!player.isSneaking()) {
     DummyTile us = (DummyTile) world.getTileEntity(x, y, z);
     if (us.getCore() != null)
       player.openGui(
           Bookshelf.instance,
           0,
           world,
           us.getCore().xCoord,
           us.getCore().yCoord,
           us.getCore().zCoord);
     return true;
   }
   return true;
 }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (player.isSneaking()) {
      return false;
    }

    TileEntity te = world.getBlockTileEntity(x, y, z);
    if (te instanceof TileEntityReactorRedstonePort) {
      if (!((TileEntityReactorRedstonePort) te).isConnected()) {
        return false;
      }

      if (!world.isRemote) ((TileEntityReactorRedstonePort) te).sendRedstoneUpdate();

      if (!world.isRemote) {
        player.openGui(BRLoader.instance, 0, world, x, y, z);
      }
      return true;
    }

    return false;
  }
Пример #11
0
  @Override
  public boolean interactFirst(EntityPlayer par1EntityPlayer) {
    ItemStack useItem = par1EntityPlayer.getCurrentEquippedItem();
    if (useItem != null) {
      if (useItem.getItem() == BambooInit.itembamboo) {
        dataWatcher.updateObject(
            IS_MIRROR_ROTE,
            (byte) (dataWatcher.getWatchableObjectByte(IS_MIRROR_ROTE) == 0 ? 1 : 0));
      }

      if (useItem.getItem() == BambooInit.tudura) {
        if (par1EntityPlayer.isSneaking()) {
          if (dataWatcher.getWatchableObjectByte(SIZE) > 1) {
            dataWatcher.updateObject(SIZE, (byte) (dataWatcher.getWatchableObjectByte(SIZE) - 1));
          }
        } else {
          if (dataWatcher.getWatchableObjectByte(SIZE) < 2) {
            dataWatcher.updateObject(SIZE, (byte) (dataWatcher.getWatchableObjectByte(SIZE) + 1));
          }
        }
      }
    }

    return false;
  }
Пример #12
0
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (player.isSneaking()) return false;

    TileEntityLimekiln tileEntity = (TileEntityLimekiln) world.getBlockTileEntity(x, y, z);

    if (tileEntity != null) {
      if (tileEntity.facing != ForgeDirection.getOrientation(par6).getOpposite()) {
        tileEntity.facing = ForgeDirection.getOrientation(par6).getOpposite();
      }

      if (!tileEntity.getIsValid()) {
        if (tileEntity.checkIfProperlyFormed()) {
          tileEntity.convertDummies();
        }
      }
      // Check if the multi-block structure has been formed.
      if (tileEntity.getIsValid())
        player.openGui(ConcreteCore.instance, ConfigHandler.GUIIDs.limekiln, world, x, y, z);
    }

    return true;
  }
Пример #13
0
 public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
   if (player.isSneaking()) {
     ItemStack newStack = new ItemStack(ModObjects.heartWand, 1, stack.getItemDamage() + 1);
     if (newStack.getItemDamage() >= 3) {
       newStack.setItemDamage(0);
     }
     return newStack;
   } else {
     ItemStack container;
     switch (stack.getItemDamage()) {
       case 0:
         container = LifeSystem.findFilledLifeContainer(player.inventory.mainInventory);
         if (container != null && player.getHealth() < player.getMaxHealth()) {
           if (((ILifeContainer) container.getItem()).takeLife(container, 1) > 0) {
             player.heal(1f);
             player.addStat(ModAchievements.useLP, 1);
           }
         }
         break;
       case 1:
         break;
       case 2:
         container = LifeSystem.findEmptyLifeContainer(player.inventory.mainInventory);
         if (container != null && player.attackEntityFrom(ModObjects.sacrifice, 1f)) {
           if (((ILifeContainer) container.getItem()).addLife(container, 1) > 0) {
             player.addStat(ModAchievements.useHeartWand, 1);
           }
         }
         break;
     }
   }
   return stack;
 }
  /** Called upon block activation (right click on the block.) */
  public boolean onBlockActivated(
      World var1,
      int var2,
      int var3,
      int var4,
      EntityPlayer var5,
      int var6,
      float var7,
      float var8,
      float var9) {
    if (var1.isRemote) {
      return true;
    } else if (var5.isSneaking()) {
      return false;
    } else {
      FF_TileEntityMetalFurnace var10 =
          (FF_TileEntityMetalFurnace) var1.getBlockTileEntity(var2, var3, var4);

      if (var10 != null) {
        var5.openGui(MetallurgyFantasy.instance, 0, var1, var2, var3, var4);
      }

      return true;
    }
  }
  @SideOnly(Side.CLIENT)
  /**
   * When this method is called, your block should register all the icons it needs with the given
   * IconRegister. This is the only chance you get to register icons.
   */
  /** Called upon block activation (right click on the block.) */
  public boolean onBlockActivated(
      World par1World,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    TileEntity tileentity = par1World.getBlockTileEntity(x, y, z);

    if (tileentity == null || player.isSneaking()) {
      return false;
    }

    player.openGui(VgTutorial.instance, 0, par1World, x, y, z);

    return true;
  }
Пример #16
0
 @Override
 public ActionResult<ItemStack> onItemRightClick(
     ItemStack tape, World world, EntityPlayer player, EnumHand hand) {
   if (world.isRemote) {
     if (Minecraft.getMinecraft().objectMouseOver != null) {
       if (player.isSneaking()) {
         xa = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getX();
         ya = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getY();
         za = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getZ();
         if (world.getTileEntity(new BlockPos(xa, ya, za)) != null) {
           System.out.println(world.getTileEntity(new BlockPos(xa, ya, za)));
         }
       } else {
         xb = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getX();
         yb = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getY();
         zb = Minecraft.getMinecraft().objectMouseOver.getBlockPos().getZ();
         block =
             world
                 .getBlockState(Minecraft.getMinecraft().objectMouseOver.getBlockPos())
                 .getBlock();
         countAxis(player);
       }
     }
   }
   return new ActionResult(EnumActionResult.PASS, tape);
 }
Пример #17
0
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer player,
     int side,
     float hitX,
     float hitY,
     float hitZ) {
   if (!world.isRemote) {
     DMPedestalTile tile = ((DMPedestalTile) world.getTileEntity(x, y, z));
     if (player.isSneaking()) {
       player.openGui(PECore.instance, Constants.PEDESTAL_GUI, world, x, y, z);
     } else {
       if (tile.getItemStack() != null && tile.getItemStack().getItem() instanceof IPedestalItem) {
         tile.setActive(!tile.getActive());
       }
       PELogger.logDebug("Pedestal: " + (tile.getActive() ? "ON" : "OFF"));
     }
     PacketHandler.sendToAllAround(
         new ClientSyncPedestalPKT(tile),
         new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32));
   }
   return true;
 }
Пример #18
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hit_x,
      float hit_y,
      float hit_z) {
    if (!player.isSneaking()) return true;
    TileReagentPurifier te = (TileReagentPurifier) world.getTileEntity(x, y, z);

    ForgeDirection newOut = ForgeDirection.getOrientation(side);

    if (newOut != te.getOutputSide()) {
      te.setOwner(player.getGameProfile().getId());
      te.setOutputSide(newOut);
      world.markBlockForUpdate(x, y, z);
      te.markDirty();
      return true;
    }
    return true;
  }
Пример #19
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float par7,
      float par8,
      float par9) {
    int meta = world.getBlockMetadata(x, y, z);

    if (ToolHelper.isWrench(player.getCurrentEquippedItem()) && player.isSneaking()) {
      TileEntity tile = world.getTileEntity(x, y, z);

      if (tile != null && tile instanceof IWrenchable) {
        IWrenchable wrenchable = (IWrenchable) tile;

        wrenchable.setFacing(ToolHelper.getOppositeSide((short) side));
        return true;
      }
    } else {
      return super.onBlockActivated(world, x, y, z, player, side, par7, par8, par9);
    }

    return false;
  }
 @Override
 public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
   if (entityPlayer.isSneaking()) {
     return true;
   }
   return false;
 }
Пример #21
0
  @Override
  public boolean onBlockActivated(
      World world,
      BlockPos pos,
      IBlockState state,
      EntityPlayer player,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    TileEntityPedestal pedestal = (TileEntityPedestal) world.getTileEntity(pos);
    if (pedestal == null) return false;

    if (player.getCurrentEquippedItem() == null) {
      if (player.isSneaking()) {
        ItemStack copy = pedestal.getStackInSlot(0);
        player.setCurrentItemOrArmor(0, copy);
        pedestal.setInventorySlotContents(0, null);
        return false;
      } else {
        return false;
      }
    } else {
      return InventoryHelper.tryAddingPlayerCurrentItem(player, pedestal);
    }
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int posX,
      int posY,
      int posZ,
      EntityPlayer player,
      int side,
      float blockX,
      float blockY,
      float blockZ) {
    TileEntity tileEntity = world.getTileEntity(posX, posY, posZ);

    if (tileEntity != null && tileEntity instanceof TileEntityLocker) {
      TileEntityLocker tileEntityLocker = (TileEntityLocker) tileEntity;

      if (!player.isSneaking()) {
        tileEntityLocker.openGui(player);
      } else {
        tileEntityLocker.setOpen(!tileEntityLocker.isOpen());
      }
    }

    return true;
  }
 public void onInteract(World world, int x, int y, int z, EntityPlayer ep) {
   LaserEffectTile te = (LaserEffectTile) world.getTileEntity(x, y, z);
   if (DragonAPICore.isReikasComputer() && ReikaObfuscationHelper.isDeObfEnvironment()) {
     ItemStack is = ep.getCurrentEquippedItem();
     if (ChromaItems.SHARD.matchWith(is)) {
       int dmg = is.getItemDamage() % 16;
       if (dmg == CrystalElement.RED.ordinal()) {
         te.color.red = !te.color.red;
       } else if (dmg == CrystalElement.GREEN.ordinal()) {
         te.color.green = !te.color.green;
       } else if (dmg == CrystalElement.BLUE.ordinal()) {
         te.color.blue = !te.color.blue;
       }
       world.markBlockForUpdate(x, y, z);
       return;
     } else if (!this.isOmniDirectional() && is != null && is.getItem() == Items.diamond) {
       te.rotateable = !te.rotateable;
       world.markBlockForUpdate(x, y, z);
       return;
     } else if (te instanceof TargetTile && is != null && is.getItem() == Items.glowstone_dust) {
       ((TargetTile) te).trigger(!((TargetTile) te).isTriggered(), true, false);
       return;
     } else if (te instanceof PrismTile && is != null && is.getItem() == Items.emerald) {
       ((PrismTile) te).timer++;
       return;
     }
     if (this == EMITTER && !ep.isSneaking()) {
       te.fire();
       return;
     }
   }
   if (!this.isOmniDirectional() && !world.isRemote) te.rotate();
 }
 @Override
 protected boolean removedByPlayer(EntityPlayer player, boolean willHarvest) {
   if (player.worldObj.isRemote) {
     return false;
   }
   MovingObjectPosition hit = ItemSculptingTool.doRayTrace(player);
   if (hit == null || hit.subHit == -1 || parts.size() < 1) {
     return super.removedByPlayer(player, willHarvest);
   }
   Coord here = getCoord();
   ClayState state = getState();
   // If it's solid, break it.
   // If we're sneaking & creative, break it
   boolean shouldDestroy = player.isSneaking() || parts.size() == 1;
   if (player.capabilities.isCreativeMode) {
     if (shouldDestroy) {
       return super.removedByPlayer(player, willHarvest);
     } else {
       removeLump(hit.subHit);
       return true;
     }
   }
   shouldDestroy |= state != ClayState.WET;
   if (shouldDestroy) {
     InvUtil.spawnItemStack(here, getItem());
     here.setAir();
   } else {
     removeLump(hit.subHit);
     InvUtil.spawnItemStack(here, new ItemStack(Items.clay_ball));
   }
   return false;
 }
  /** Called upon block activation (right click on the block.) */
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (par1World.isRemote) {
      return true;
    } else {
      TileEntity var10 = par1World.getBlockTileEntity(par2, par3, par4);
      if (var10 == null || par5EntityPlayer.isSneaking()) {

        return false;
      }

      if (var10 != null && var10 instanceof TileEntityMysticFurnace) {
        par5EntityPlayer.openGui(MysticAdditions.instance, 0, par1World, par2, par3, par4);
      }

      return true;
    }
  }
Пример #26
0
  @Override
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (par5EntityPlayer.isSneaking()) {
      TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4);

      if (altar.manaToGet == 0)
        for (int i = altar.getSizeInventory() - 1; i >= 0; i--) {
          ItemStack stackAt = altar.getStackInSlot(i);
          if (stackAt != null) {
            ItemStack copy = stackAt.copy();
            if (!par5EntityPlayer.inventory.addItemStackToInventory(copy))
              par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false);
            altar.setInventorySlotContents(i, null);
            par1World.func_147453_f(par2, par3, par4, this);
            break;
          }
        }
    } else {
      ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
      if (stack != null)
        return ((TileRuneAltar) par1World.getTileEntity(par2, par3, par4))
            .addItem(par5EntityPlayer, stack);
    }
    return false;
  }
Пример #27
0
  public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
    if (playerIn.isSneaking()) {
      if (!playerIn.capabilities.isCreativeMode) {
        --itemStackIn.stackSize;
      }

      worldIn.playSoundAtEntity(
          playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

      if (!worldIn.isRemote) {
        // EntityEnchantedEbonheart

        worldIn.spawnEntityInWorld(new EntityEnchantedEbonheart(worldIn, playerIn));

        // EntityEnchantedEbonheart entityenchantedebonheart = new EntityEnchantedEbonheart(worldIn,
        // playerIn);
        // entityenchantedebonheart.setHeadingFromThrower(playerIn, playerIn.rotationPitch,
        // playerIn.rotationYaw, -20.0F, 0.7F, 1.0F);
        // worldIn.spawnEntityInWorld(entityenchantedebonheart);

        // EntityExpBottle entityexpbottle = new EntityExpBottle(worldIn, playerIn);
        // entityexpbottle.func_184538_a(playerIn, playerIn.rotationPitch, playerIn.rotationYaw,
        // -20.0F, 0.7F, 1.0F);
        // worldIn.spawnEntityInWorld(entityexpbottle);
      }

      playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
      return itemStackIn;
    }
    return itemStackIn;
  }
 private boolean onPlayerPlaceBlock(
     PlayerControllerMP controller,
     EntityPlayer player,
     ItemStack offhand,
     BlockPos pos,
     EnumFacing l,
     Vec3 hitVec) {
   final World worldObj = player.worldObj;
   if (!worldObj.getWorldBorder().contains(pos)) {
     return false;
   }
   float f = (float) hitVec.xCoord - (float) pos.getX();
   float f1 = (float) hitVec.yCoord - (float) pos.getY();
   float f2 = (float) hitVec.zCoord - (float) pos.getZ();
   boolean flag = false;
   if (!controller.isSpectatorMode()) {
     if (offhand.getItem().onItemUseFirst(offhand, player, worldObj, pos, l, f, f1, f2)) {
       return true;
     }
     if (!player.isSneaking()
         || player.getCurrentEquippedItem() == null
         || player.getCurrentEquippedItem().getItem().doesSneakBypassUse(worldObj, pos, player)) {
       IBlockState b = worldObj.getBlockState(pos);
       if (!b.getBlock().isAir(worldObj, pos)
           && b.getBlock().onBlockActivated(worldObj, pos, b, player, l, f, f1, f2)) {
         flag = true;
       }
     }
     if (!flag && offhand.getItem() instanceof ItemBlock) {
       ItemBlock itemblock = (ItemBlock) offhand.getItem();
       if (!itemblock.canPlaceBlockOnSide(worldObj, pos, l, player, offhand)) {
         return false;
       }
     }
   }
   Battlegear.packetHandler.sendPacketToServer(
       new OffhandPlaceBlockPacket(pos, l, offhand, f, f1, f2).generatePacket());
   if (flag || controller.isSpectatorMode()) {
     return true;
   } else if (offhand == null) {
     return false;
   } else {
     if (controller.isInCreativeMode()) {
       int i1 = offhand.getMetadata();
       int j1 = offhand.stackSize;
       boolean flag1 = offhand.onItemUse(player, worldObj, pos, l, f, f1, f2);
       offhand.setItemDamage(i1);
       offhand.stackSize = j1;
       return flag1;
     } else {
       if (!offhand.onItemUse(player, worldObj, pos, l, f, f1, f2)) {
         return false;
       }
       if (offhand.stackSize <= 0) {
         ForgeEventFactory.onPlayerDestroyItem(player, offhand);
       }
       return true;
     }
   }
 }
  @Override
  public ItemStack onItemRightClick(ItemStack essentiaCell, World world, EntityPlayer player) {
    // Ensure the player is sneaking(holding shift)
    if (!player.isSneaking()) {
      return essentiaCell;
    }

    // TODO: SaveProvider??
    // Get the handler
    IMEInventoryHandler<IAEFluidStack> handler =
        AEApi.instance()
            .registries()
            .cell()
            .getCellInventory(essentiaCell, null, StorageChannel.FLUIDS);

    // Is it the correct handler type?
    if (!(handler instanceof HandlerItemEssentiaCell)) {
      return essentiaCell;
    }

    // Cast
    HandlerItemEssentiaCell cellHandler = (HandlerItemEssentiaCell) handler;

    // If the cell is empty, and the player can hold the casing
    if ((cellHandler.usedBytes() == 0)
        && (player.inventory.addItemStackToInventory(
            ItemEnum.STORAGE_CASING.getItemStackWithSize(1)))) {
      // Return the storage component
      return ItemEnum.STORAGE_COMPONENT.getItemStackWithDamage(essentiaCell.getItemDamage());
    }

    // Can not remove storage component, return the current cell as is.
    return essentiaCell;
  }
Пример #30
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (player.isSneaking()) return true;
    else if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) return true;
    else {
      if (!world.isRemote) {
        TileEntityMagneticChest tileMagneticChest =
            (TileEntityMagneticChest) world.getTileEntity(x, y, z);

        if (tileMagneticChest != null) {
          player.displayGUIChest(tileMagneticChest);
        }
      }

      return true;
    }
  }