Пример #1
0
 @Override
 public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) {
   if (item != null && item.getItemName().equals("item.Necronomicon")) {
     player.addStat(AchievementNecromancy.NecronomiconAchieve, 1);
   }
   if (item != null && item.getItemName().equals("tile.Sewing Machine")) {
     player.addStat(AchievementNecromancy.SewingAchieve, 1);
   }
   if (item != null && item.itemID == new ItemStack(ItemNecromancy.bucketBlood).itemID) {
     player.inventory.addItemStackToInventory(
         new ItemStack(net.minecraft.item.Item.glassBottle, 8));
   }
   if (item != null
       && item.itemID == ItemGeneric.getItemStackFromName("Jar of Blood").itemID
       && item.getItemDamage()
           == ItemGeneric.getItemStackFromName("Jar of Blood").getItemDamage()) {
     player.inventory.addItemStackToInventory(new ItemStack(net.minecraft.item.Item.bucketEmpty));
   }
   if (item != null && item.getItemName().equals("tile.skullWall")) {
     Necromancy.loggerNecromancy.info(
         craftMatrix.getStackInSlot(0) + " is in " + craftMatrix.getStackInSlot(0).getItemName());
     item.stackTagCompound.setString("Base", craftMatrix.getStackInSlot(1).getItemName());
     item.stackTagCompound.setString(
         "Skull1", ItemNecroSkull.skullTypes[craftMatrix.getStackInSlot(1).getItemDamage()]);
     item.stackTagCompound.setString(
         "Skull2", ItemNecroSkull.skullTypes[craftMatrix.getStackInSlot(4).getItemDamage()]);
     item.stackTagCompound.setString(
         "Skull3", ItemNecroSkull.skullTypes[craftMatrix.getStackInSlot(5).getItemDamage()]);
   }
 }
Пример #2
0
 public static void addToWhiteList(ItemStack seed, ItemStack plant) {
   String l = plant.getItemName() + "_OmniPlantExternal";
   String l2 =
       plant.itemID
           + ","
           + plant.stackSize
           + ","
           + plant.getItemDamage()
           + ","
           + seed.itemID
           + ","
           + seed.getItemDamage();
   PfF.Core.config.get(cat2, l, l2);
   PfF.Core.config.addCustomCategoryComment(
       cat2, "Syntax: grown item id, grown item amount, grown item meta, seed id, seed meta");
   PfF.Core.config.save();
 }
  @Override
  public void runChoreAI() {
    owner.isFollowing = false;
    owner.isStaying = false;

    // Calculate interval based on the axe in the inventory.
    ItemStack axeStack = owner.inventory.getBestItemOfType(ItemAxe.class);

    if (owner instanceof EntityPlayerChild) {
      if (axeStack != null) {
        String itemName = axeStack.getItemName();

        if (itemName.contains("Wood")) {
          treeCutInterval = 40;
        } else if (itemName.contains("Stone")) {
          treeCutInterval = 30;
        } else if (itemName.contains("Iron")) {
          treeCutInterval = 25;
        } else if (itemName.contains("Diamond")) {
          treeCutInterval = 10;
        } else if (itemName.contains("Gold")) {
          treeCutInterval = 5;
        }

        // Unrecognized item type
        else {
          treeCutInterval = 25;
        }
      }

      // Fists
      else {
        treeCutInterval = 50;
      }
    }

    // A villager will cut with an iron axe.
    else {
      treeCutInterval = 25;
    }

    // Create a list to store coordinates containing wood.
    List<Coordinates> coordinatesContainingWood;

    // Check if a specific tree was selected.
    if (treeType != -1) {
      // Get only wood blocks whose metadata matches the tree type.
      coordinatesContainingWood =
          LogicHelper.getNearbyBlockCoordinatesWithMetadata(
              owner, Block.wood.blockID, treeType, 10);
    }

    // All trees should be cut.
    else {
      coordinatesContainingWood =
          LogicHelper.getNearbyBlockCoordinates(owner, Block.wood.blockID, 10);
    }

    // Check if they need some tree coordinates.
    if (!hasTreeCoordinates) {
      // Check that there's actually some in the list.
      if (coordinatesContainingWood.isEmpty()) {
        if (!owner.worldObj.isRemote) {
          if (!hasDoneWork) {
            owner.say(
                LanguageHelper.getString(
                    owner, "notify.child.chore.interrupted.woodcutting.notrees", false));
          } else {
            owner.say(
                LanguageHelper.getString(owner, "notify.child.chore.finished.woodcutting", false));
          }
        }

        endChore();
        return;
      } else {
        hasTreeCoordinates = true;

        Coordinates coordinatesOfBlock = null;
        Double distance = null;

        // Get the coordinates of the nearest valid wood block found of the specified ID.
        for (Coordinates coords : coordinatesContainingWood) {
          if (distance != null) {
            Double thisDistance =
                LogicHelper.getDistanceToXYZ(
                    owner.posX, owner.posY, owner.posZ, coords.x, coords.y, coords.z);

            if (thisDistance < distance) {
              coordinatesOfBlock = coords;
            }
          } else {
            if (owner.worldObj.getBlockId((int) coords.x, (int) coords.y - 1, (int) coords.z)
                    == Block.dirt.blockID
                || owner.worldObj.getBlockId((int) coords.x, (int) coords.y - 1, (int) coords.z)
                    == Block.grass.blockID) {
              distance =
                  LogicHelper.getDistanceToXYZ(
                      owner.posX, owner.posY, owner.posZ, coords.x, coords.y, coords.z);
              coordinatesOfBlock = coords;
            }
          }
        }

        if (coordinatesOfBlock != null) {
          treeCoordinatesX = coordinatesOfBlock.x;
          treeCoordinatesY = coordinatesOfBlock.y;
          treeCoordinatesZ = coordinatesOfBlock.z;

          // Calculate the lowest log.
          int distanceFromY = 0;

          while (distanceFromY != 10) {
            int blockId =
                owner.worldObj.getBlockId(
                    (int) treeCoordinatesX,
                    (int) treeCoordinatesY - distanceFromY,
                    (int) treeCoordinatesZ);

            if (blockId != Block.wood.blockID) {
              distanceFromY--;
              break;
            }

            distanceFromY++;
          }

          currentLogCoordinatesX = treeCoordinatesX;
          currentLogCoordinatesY = treeCoordinatesY - distanceFromY;
          currentLogCoordinatesZ = treeCoordinatesZ;
        }

        // A valid tree wasn't found.
        else {
          if (!owner.worldObj.isRemote) {
            owner.say(
                LanguageHelper.getString(
                    owner, "notify.child.chore.interrupted.woodcutting.notrees", false));
          }

          endChore();
          return;
        }
      }
    }

    // If they don't need tree coordinates, continue working.
    else {
      // Get the coordinates of all leaf blocks adjacent to the entity.
      List<Coordinates> leafBlockCoordinates =
          LogicHelper.getNearbyBlocksBottomTop(owner, Block.leaves.blockID, 1, 1);

      // Loop through each coordinate in the list and remove the leaves.
      for (Coordinates coords : leafBlockCoordinates) {
        owner.worldObj.setBlock((int) coords.x, (int) coords.y, (int) coords.z, 0);
      }

      // Check if they need to move to the tree to cut.
      if (!(owner.getDistance(treeCoordinatesX, owner.posY, treeCoordinatesZ) <= 2.5)) {
        // Set their path.
        AbstractEntity.faceCoordinates(owner, treeCoordinatesX, treeCoordinatesY, treeCoordinatesZ);

        if (!owner.worldObj.isRemote) {
          if (owner.getNavigator().noPath()) {
            owner
                .getNavigator()
                .setPath(
                    owner
                        .getNavigator()
                        .getPathToXYZ(treeCoordinatesX, treeCoordinatesY, treeCoordinatesZ),
                    0.3F);
          }
        }
      }

      // They don't need to move to the tree, so begin cutting.
      else {
        // Make sure the log they're going to cut exists, or the log above.
        if (owner.worldObj.getBlockId(
                    (int) currentLogCoordinatesX,
                    (int) currentLogCoordinatesY,
                    (int) currentLogCoordinatesZ)
                == Block.wood.blockID
            || owner.worldObj.getBlockId(
                    (int) currentLogCoordinatesX,
                    (int) currentLogCoordinatesY + 1,
                    (int) currentLogCoordinatesZ)
                == Block.wood.blockID) {
          // Check the ticks vs the interval to see if the log should be removed.
          if (treeCutTicks >= treeCutInterval) {
            treeCutTicks = 0;
            owner.damageHeldItem();

            ItemStack stackToAdd = new ItemStack(Block.wood, 1, treeType);
            stackToAdd.damageItem(treeType, owner);
            owner.inventory.addItemStackToInventory(stackToAdd);

            // Remove the block and increase Y by 1.
            if (!owner.worldObj.isRemote) {
              owner.worldObj.setBlock(
                  (int) currentLogCoordinatesX,
                  (int) currentLogCoordinatesY,
                  (int) currentLogCoordinatesZ,
                  0);
            }

            currentLogCoordinatesY++;

            // Remember they've done work.
            hasDoneWork = true;

            // Increment stat and check for achievement on children.
            if (owner instanceof EntityPlayerChild) {
              EntityPlayerChild child = (EntityPlayerChild) owner;

              child.woodChopped += 1;

              if (child.woodChopped >= 100) {
                EntityPlayer player = child.worldObj.getPlayerEntityByName(child.ownerPlayerName);

                if (player != null) {
                  player.triggerAchievement(MCA.instance.achievementChildWoodcut);
                }
              }
            }
          }

          // It's not time to remove the log, swing the axe and increment ticks.
          else {
            AbstractEntity.faceCoordinates(
                owner, currentLogCoordinatesX, currentLogCoordinatesY, currentLogCoordinatesZ);
            owner.swingItem();
            treeCutTicks++;
          }
        }

        // The log being cut doesn't exist. Get another one.
        else {
          hasTreeCoordinates = false;
        }
      }
    }
  }
Пример #4
0
 public static void addToWhiteList(ItemStack item) {
   String l = item.getItemName() + "_OmniPlant";
   String l2 = item.itemID + "," + item.stackSize + "," + item.getItemDamage();
   PfF.Core.config.get(cat, l, l2);
   PfF.Core.config.addCustomCategoryComment(cat, "Syntax: ID, amount, meta");
 }
Пример #5
0
 public static boolean isStackAnEmptyTestTube(ItemStack itemstack) {
   return itemstack.getItemName().contains("minechem.itemTestTube");
 }
Пример #6
0
 public static boolean isStackAMolecule(ItemStack itemstack) {
   return itemstack.getItemName().contains("minechem.itemMolecule");
 }
Пример #7
0
 public static boolean isStackAnElement(ItemStack itemstack) {
   return itemstack.getItemName().contains("minechem.itemElement");
 }
Пример #8
0
 public static boolean isStackAChemical(ItemStack itemstack) {
   return itemstack.getItemName().contains("minechem.itemElement")
       || itemstack.getItemName().contains("minechem.itemMolecule");
 }