/**
  * Called before a block is broken. Return true to prevent default block harvesting.
  *
  * <p>Note: In SMP, this is called on both client and server sides!
  *
  * @param itemstack The current ItemStack
  * @param X The X Position
  * @param Y The X Position
  * @param Z The X Position
  * @param player The Player that is wielding the item
  * @return True to prevent harvesting, false to continue as normal
  */
 @Override
 public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) {
   Block block = player.getEntityWorld().getBlock(x, y, z);
   if (block == Blocks.dirt || block == Blocks.grass) {
     if (itemstack.getItemDamage() >= 2) itemstack.damageItem(-2, player);
     if (itemstack.getItemDamage() == 1) itemstack.damageItem(-1, player);
     if (!player.getEntityWorld().isRemote) {
       player.getEntityWorld().func_147480_a(x, y, z, false); // destroyBlock method
     }
     return true;
   }
   return false;
 }
예제 #2
0
    public TreeChopTask(ItemStack tool, BlockPos start, EntityPlayer player, int blocksPerTick) {
      this.world = player.getEntityWorld();
      this.player = player;
      this.tool = tool;
      this.blocksPerTick = blocksPerTick;

      this.blocks.add(start);
    }
예제 #3
0
 @Override
 public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
   player.openGui(
       DartCraft2.instance,
       Reference.GUIs.FORCE_BELT.ordinal(),
       player.getEntityWorld(),
       (int) player.posX,
       (int) player.posY,
       (int) player.posZ);
   return stack;
 }
  @Override
  @SideOnly(Side.CLIENT)
  public void renderHelmetOverlay(
      ItemStack stack,
      EntityPlayer player,
      ScaledResolution resolution,
      float partialTicks,
      boolean hasScreen,
      int mouseX,
      int mouseY) {
    NBTTagCompound nbt = getOrCreateTagCompound(stack);

    for (int i = 0; i < nbt.getInteger("moduleCount"); i++) {
      IArmorModule module = (IArmorModule) ModuleRegistry.getModule(nbt.getString("module" + i));

      if ((module != null) && (module.getArmorEffectType() == EnumArmorEffectType.HUD)) {
        module.applyModuleEffect(player.getEntityWorld(), player, stack);
      }
    }
  }
예제 #5
0
 private static void addAspect(
     EntityPlayer player, ScanResult scan, double chanceToIncrease, double increaseMult) {
   Thaumcraft.proxy
       .getResearchManager()
       .completeScannedObject(
           player, "@" + ScanManager.generateItemHash(Item.getItemById(scan.id), scan.meta));
   AspectList aspects =
       ThaumcraftCraftingManager.getObjectTags(
           new ItemStack(Item.getItemById(scan.id), 1, scan.meta));
   if (aspects != null) {
     PlayerKnowledge pk = Thaumcraft.proxy.getPlayerKnowledge();
     for (Aspect aspect : aspects.getAspects()) {
       if (pk.hasDiscoveredParentAspects(player.getCommandSenderName(), aspect)) {
         int amt = aspects.getAmount(aspect);
         if (chanceToIncrease > 0d && player.getEntityWorld().rand.nextDouble() < chanceToIncrease)
           amt = MathHelper.ceiling_double_int((double) amt * increaseMult);
         ScanManager.checkAndSyncAspectKnowledge(player, aspect, amt);
       }
     }
   }
 }
 /**
  * Equivalent code to the creative pick block
  *
  * @param target The client target vector
  * @param player The player trying to pick
  * @return the stack expected for the creative pick button
  */
 private static ItemStack getItemFromPointedAt(MovingObjectPosition target, EntityPlayer player) {
   if (target != null) {
     if (target.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
       BlockPos pos = target.getBlockPos();
       World world = player.getEntityWorld();
       Block block = world.getBlockState(pos).getBlock();
       if (block.isAir(world, pos)) {
         return null;
       }
       return block.getPickBlock(target, world, pos);
     } else {
       if (target.typeOfHit != MovingObjectPosition.MovingObjectType.ENTITY
           || target.entityHit == null
           || !player.capabilities.isCreativeMode) {
         return null;
       }
       return target.entityHit.getPickedResult(target);
     }
   }
   return null;
 }
예제 #7
0
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (!world.isRemote) {
      int id = player.worldObj.provider.dimensionId;
      RfToolsDimensionManager dimensionManager =
          RfToolsDimensionManager.getDimensionManager(player.worldObj);
      DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
      if (dimensionInformation == null) {
        Logging.message(player, "Not an RFTools dimension!");
      } else {
        String name = dimensionInformation.getName();
        DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
        int power = storage != null ? storage.getEnergyLevel(id) : 0;

        Logging.message(
            player,
            EnumChatFormatting.BLUE
                + "Name: "
                + name
                + " (Id "
                + id
                + ")"
                + EnumChatFormatting.YELLOW
                + "    Power: "
                + power
                + " RF");
        if (player.isSneaking()) {
          Logging.message(
              player,
              EnumChatFormatting.RED
                  + "Description: "
                  + dimensionInformation.getDescriptor().getDescriptionString());
          System.out.println(
              "Description:  = " + dimensionInformation.getDescriptor().getDescriptionString());
        }
      }
      return stack;
    }
    return stack;
  }
예제 #8
0
  @Override
  public void addInformation(
      ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    int id = player.worldObj.provider.dimensionId;
    RfToolsDimensionManager dimensionManager =
        RfToolsDimensionManager.getDimensionManager(player.worldObj);
    DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
    if (dimensionInformation == null) {
      list.add("Not an RFTools dimension!");
    } else {
      if (System.currentTimeMillis() - lastTime > 500) {
        lastTime = System.currentTimeMillis();
        PacketHandler.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
      }
      String name = dimensionInformation.getName();
      DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
      int power = storage != null ? storage.getEnergyLevel(id) : 0;

      list.add(EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")");

      list.add(EnumChatFormatting.YELLOW + "Power: " + power + " RF");
    }
  }
  public ContainerPortableDynamic(
      EntityPlayer player,
      InventoryPlayer inventoryPlayer,
      InventoryItem inventoryItem,
      Map<Integer, Integer> map) {
    this.inventory = inventoryItem;
    this.research = map;
    isRemote = player.getEntityWorld().isRemote;

    this.addSlotToContainer(new SlotPortableCrafting(this, inventory, 0, 25, 9, isRemote));
    this.addSlotToContainer(new SlotPortableCrafting(this, inventory, 1, 79, 9, isRemote));
    this.addSlotToContainer(
        new SlotPortableResult(player, inventory, this, new int[] {0, 1}, 2, 134, 9, isRemote));

    this.addSlotToContainer(new SlotPortableCrafting(this, inventory, 3, 25, 35, isRemote));
    this.addSlotToContainer(new SlotPortableCrafting(this, inventory, 4, 79, 35, isRemote));
    this.addSlotToContainer(
        new SlotPortableResult(player, inventory, this, new int[] {3, 4}, 5, 134, 35, isRemote));

    addSlotToContainer(new SlotPortableCrafting(this, inventory, 6, 20 + 0 * 32, 61, isRemote));
    addSlotToContainer(new SlotPortableCrafting(this, inventory, 7, 20 + 1 * 32, 61, isRemote));
    addSlotToContainer(new SlotPortableCrafting(this, inventory, 8, 20 + 2 * 32, 61, isRemote));
    this.addSlotToContainer(
        new SlotPortableResult(player, inventory, this, new int[] {6, 7, 8}, 9, 134, 61, isRemote));

    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 9; ++j) {
        this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
      }
    }

    for (int i = 0; i < 9; ++i) {
      this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
    }
    onItemCrafted();
  }