Пример #1
0
 @Override
 public void collide(net.minecraft.server.Entity entity) {
   // this method is called by both the entities involved - cancelling
   // it will not stop the NPC from moving.
   super.collide(entity);
   if (npc != null) Util.callCollisionEvent(npc, entity);
 }
Пример #2
0
 @Override
 public void g(double x, double y, double z) {
   if (npc == null) {
     super.g(x, y, z);
     return;
   }
   if (NPCPushEvent.getHandlerList().getRegisteredListeners().length == 0) {
     if (!npc.data().get(NPC.DEFAULT_PROTECTED_METADATA, true)) super.g(x, y, z);
     return;
   }
   Vector vector = new Vector(x, y, z);
   NPCPushEvent event = Util.callPushEvent(npc, vector);
   if (!event.isCancelled()) {
     vector = event.getCollisionVector();
     super.g(vector.getX(), vector.getY(), vector.getZ());
   }
   // when another entity collides, this method is called to push the
   // NPC so we prevent it from doing anything if the event is
   // cancelled.
 }
Пример #3
0
 @Override
 public void bb() {
   if (npc == null) super.bb();
   // check despawn method, we only want to despawn on chunk unload.
 }
Пример #4
0
 @Override
 public void bc() {
   super.bc();
   if (npc != null) npc.update();
 }
Пример #5
0
  private void f(World var1, BlockPosition var2) {
    ShapeDetector.ShapeDetectorCollection var3;
    int var4;
    int var6;
    if ((var3 = this.getDetectorSnowGolem().a(var1, var2)) != null) {
      for (var4 = 0; var4 < this.getDetectorSnowGolem().b(); ++var4) {
        ShapeDetectorBlock var5 = var3.a(0, var4, 0);
        var1.setTypeAndData(var5.d(), Blocks.AIR.getBlockData(), 2);
      }

      EntitySnowman var9 = new EntitySnowman(var1);
      BlockPosition var10 = var3.a(0, 2, 0).d();
      var9.setPositionRotation(
          (double) var10.getX() + 0.5D,
          (double) var10.getY() + 0.05D,
          (double) var10.getZ() + 0.5D,
          0.0F,
          0.0F);
      var1.addEntity(var9);

      for (var6 = 0; var6 < 120; ++var6) {
        var1.addParticle(
            EnumParticle.SNOW_SHOVEL,
            (double) var10.getX() + var1.random.nextDouble(),
            (double) var10.getY() + var1.random.nextDouble() * 2.5D,
            (double) var10.getZ() + var1.random.nextDouble(),
            0.0D,
            0.0D,
            0.0D,
            new int[0]);
      }

      for (var6 = 0; var6 < this.getDetectorSnowGolem().b(); ++var6) {
        ShapeDetectorBlock var7 = var3.a(0, var6, 0);
        var1.update(var7.d(), Blocks.AIR);
      }
    } else if ((var3 = this.getDetectorIronGolem().a(var1, var2)) != null) {
      for (var4 = 0; var4 < this.getDetectorIronGolem().c(); ++var4) {
        for (int var12 = 0; var12 < this.getDetectorIronGolem().b(); ++var12) {
          var1.setTypeAndData(var3.a(var4, var12, 0).d(), Blocks.AIR.getBlockData(), 2);
        }
      }

      BlockPosition var11 = var3.a(1, 2, 0).d();
      EntityIronGolem var13 = new EntityIronGolem(var1);
      var13.setPlayerCreated(true);
      var13.setPositionRotation(
          (double) var11.getX() + 0.5D,
          (double) var11.getY() + 0.05D,
          (double) var11.getZ() + 0.5D,
          0.0F,
          0.0F);
      var1.addEntity(var13);

      for (var6 = 0; var6 < 120; ++var6) {
        var1.addParticle(
            EnumParticle.SNOWBALL,
            (double) var11.getX() + var1.random.nextDouble(),
            (double) var11.getY() + var1.random.nextDouble() * 3.9D,
            (double) var11.getZ() + var1.random.nextDouble(),
            0.0D,
            0.0D,
            0.0D,
            new int[0]);
      }

      for (var6 = 0; var6 < this.getDetectorIronGolem().c(); ++var6) {
        for (int var14 = 0; var14 < this.getDetectorIronGolem().b(); ++var14) {
          ShapeDetectorBlock var8 = var3.a(var6, var14, 0);
          var1.update(var8.d(), Blocks.AIR);
        }
      }
    }
  }