예제 #1
0
  @SuppressWarnings("unchecked")
  @Override
  public void updateChest(IBetterChest chest, int tick, World world, ItemStack item) {
    if (tick == 63) {
      AxisAlignedBB bounds =
          AxisAlignedBB.getBoundingBox(
              chest.getXPos() - Reference.Conf.FEED_RADIUS / 2,
              chest.getYPos() - Reference.Conf.FEED_HEIGHT / 2,
              chest.getZPos() - Reference.Conf.FEED_RADIUS / 2,
              chest.getXPos() + Reference.Conf.FEED_RADIUS / 2,
              chest.getYPos() + Reference.Conf.FEED_HEIGHT / 2,
              chest.getZPos() + Reference.Conf.FEED_RADIUS / 2);
      List<EntityAnimal> list = world.getEntitiesWithinAABB(EntityAnimal.class, bounds);

      for (EntityAnimal entity : list) {
        if (!entity.isEntityAlive() || entity.isChild()) continue;
        if (entity instanceof IShearable && !(entity instanceof EntityMooshroom)) {
          IShearable sheep = (EntitySheep) entity;
          if (sheep.isShearable(
              null, world, entity.serverPosX, entity.serverPosY, entity.serverPosZ)) {
            // If I ever implement that it uses Shears, then this would be the place to damage it.
            ArrayList<ItemStack> items =
                sheep.onSheared(
                    null, world, entity.serverPosX, entity.serverPosY, entity.serverPosZ, 1);
            for (ItemStack wool : items) {
              if (InvUtil.putIntoFirstSlot(chest, wool, false) != null) break;
            }
          }
        } else if (entity instanceof EntityCow) {
          ItemStack bucket = InvUtil.getFirstItem(chest, new ItemStack(Items.bucket), true);
          if (bucket != null) {
            if (InvUtil.putIntoFirstSlot(chest, new ItemStack(Items.milk_bucket), false) == null) {
              InvUtil.getFirstItem(chest, new ItemStack(Items.bucket), false);
            }
          }
          if (entity instanceof EntityMooshroom) {
            ItemStack bowl = InvUtil.getFirstItem(chest, new ItemStack(Items.bowl), true);
            if (bowl != null) {
              if (InvUtil.putIntoFirstSlot(chest, new ItemStack(Items.mushroom_stew), false)
                  == null) {
                InvUtil.getFirstItem(chest, new ItemStack(Items.bowl), false);
              }
            }
          }
        }
      }
    }
  }
예제 #2
0
  @SubscribeEvent
  public void interactEntityEvent(EntityInteractEvent event) {
    ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
    if (stack == null) return;
    if (!(event.target instanceof EntityAnimal)) return;

    EntityAnimal animal = (EntityAnimal) event.target;
    if (!animal.isChild()) {
      if (animal instanceof EntityPig) {
        if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
          setAnimalInLove(animal, event.entityPlayer, stack);
      } else if (animal instanceof EntityChicken)
        if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
          setAnimalInLove(animal, event.entityPlayer, stack);
    } else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
      feedBaby(animal, event.entityPlayer, stack);
  }