Пример #1
0
 @Override
 public void onEntityCollidedWithBlock(
     World world, BlockPos pos, IBlockState state, Entity entity) {
   if (entity instanceof EntityDog) {
     EntityDog dog = (EntityDog) entity;
     dog.forceShake = true;
   }
 }
Пример #2
0
  @Override
  public void onEntityCollidedWithBlock(World world, BlockPos pos, Entity entity) {
    TileEntityFoodBowl foodBowl = (TileEntityFoodBowl) world.getTileEntity(pos);
    List list = null;
    list =
        world.getEntitiesWithinAABB(
            EntityDog.class,
            new AxisAlignedBB(
                pos.getX(),
                pos.getY() + 0.5D,
                pos.getZ(),
                pos.getX() + 1,
                pos.getY() + 0.5D + 0.05000000074505806D,
                pos.getZ() + 1));

    if (list != null && list.size() > 0) {
      for (int l = 0; l < list.size(); l++) {
        EntityDog entitydtdoggy = (EntityDog) list.get(l);
        // TODO entitydtdoggy.saveposition.setBowlX(x);
        // TODO entitydtdoggy.saveposition.setBowlY(y);
        // TODO entitydtdoggy.saveposition.setBowlZ(z);
      }
    }

    if (entity instanceof EntityItem) {
      EntityItem entityItem = (EntityItem) entity;

      if (TileEntityHopper.func_145898_a(foodBowl, entityItem))
        world.playSoundEffect(
            pos.getX() + 0.5D,
            pos.getX() + 0.5D,
            pos.getZ() + 0.5D,
            "random.pop",
            0.25F,
            ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
    }

    List list2 = null;
    list2 =
        world.getEntitiesWithinAABB(
            EntityDog.class,
            new AxisAlignedBB(
                pos.getX(),
                pos.getY() + 0.5D,
                pos.getZ(),
                pos.getX() + 1,
                pos.getY() + 0.5D + 0.05000000074505806D,
                pos.getZ() + 1));

    if (list2 != null && list2.size() > 0) {
      TileEntity tileentity1 = world.getTileEntity(pos);

      if (!(tileentity1 instanceof TileEntityFoodBowl)) {
        return;
      }

      TileEntityFoodBowl tileentitydogfoodbowl1 = (TileEntityFoodBowl) tileentity1;

      for (int j1 = 0; j1 < list2.size(); j1++) {
        EntityDog entitydtdoggy1 = (EntityDog) list2.get(j1);

        if (entitydtdoggy1.getDogHunger() <= 60
            && tileentitydogfoodbowl1.getFirstDogFoodStack(entitydtdoggy1) >= 0) {
          tileentitydogfoodbowl1.feedDog(
              entitydtdoggy1, tileentitydogfoodbowl1.getFirstDogFoodStack(entitydtdoggy1), 1);
        }
      }
    }
  }