Пример #1
0
 public override bool AttackEntityFrom(net.minecraft.src.Entity entity, int i)
 {
     if (worldObj.singleplayerWorld || isDead)
     {
         return(true);
     }
     forwardDirection = -forwardDirection;
     field_9167_b     = 10;
     SetBeenAttacked();
     damageTaken += i * 10;
     if (damageTaken > 40)
     {
         if (riddenByEntity != null)
         {
             riddenByEntity.MountEntity(this);
         }
         SetEntityDead();
         DropItemWithOffset(net.minecraft.src.Item.MINECART.ID, 1, 0.0F);
         if (minecartType == 1)
         {
             net.minecraft.src.EntityMinecart entityminecart = this;
             for (int j = 0; j < entityminecart.GetSizeInventory(); j++)
             {
                 net.minecraft.src.ItemStack itemstack = entityminecart.GetStackInSlot(j);
                 if (itemstack == null)
                 {
                     continue;
                 }
                 float f  = rand.NextFloat() * 0.8F + 0.1F;
                 float f1 = rand.NextFloat() * 0.8F + 0.1F;
                 float f2 = rand.NextFloat() * 0.8F + 0.1F;
                 do
                 {
                     if (itemstack.stackSize <= 0)
                     {
                         goto label0_continue;
                     }
                     int k = rand.Next(21) + 10;
                     if (k > itemstack.stackSize)
                     {
                         k = itemstack.stackSize;
                     }
                     itemstack.stackSize -= k;
                     net.minecraft.src.EntityItem entityitem = new net.minecraft.src.EntityItem(worldObj
                                                                                                , posX + (double)f, posY + (double)f1, posZ + (double)f2, new net.minecraft.src.ItemStack
                                                                                                    (itemstack.itemID, k, itemstack.GetItemDamage()));
                     float f3 = 0.05F;
                     entityitem.motionX = (float)rand.NextGaussian() * f3;
                     entityitem.motionY = (float)rand.NextGaussian() * f3 + 0.2F;
                     entityitem.motionZ = (float)rand.NextGaussian() * f3;
                     worldObj.AddEntity(entityitem);
                 }while (true);
                 label0_continue :;
             }
             label0_break :;
             DropItemWithOffset(net.minecraft.src.Block.CHEST.ID, 1, 0.0F);
         }
         else
         {
             if (minecartType == 2)
             {
                 DropItemWithOffset(net.minecraft.src.Block.FURNACE.ID, 1, 0.0F);
             }
         }
     }
     return(true);
 }
Пример #2
0
 private net.minecraft.src.Packet GetSpawnPacket()
 {
     if (trackedEntity is net.minecraft.src.EntityItem)
     {
         net.minecraft.src.EntityItem          entityitem          = (net.minecraft.src.EntityItem)trackedEntity;
         net.minecraft.src.Packet21PickupSpawn packet21pickupspawn = new net.minecraft.src.Packet21PickupSpawn
                                                                         (entityitem);
         entityitem.posX = (double)packet21pickupspawn.xPosition / 32D;
         entityitem.posY = (double)packet21pickupspawn.yPosition / 32D;
         entityitem.posZ = (double)packet21pickupspawn.zPosition / 32D;
         return(packet21pickupspawn);
     }
     if (trackedEntity is net.minecraft.src.EntityPlayerMP)
     {
         // CRAFTBUKKIT start - limit name length to 16 characters
         if (((EntityPlayerMP)this.trackedEntity).username.Length > 16)
         {
             ((EntityPlayerMP)this.trackedEntity).username = ((EntityPlayerMP)this.trackedEntity).username.Substring(0, 16);
         }
         // CRAFTBUKKIT end
         return(new net.minecraft.src.Packet20NamedEntitySpawn((net.minecraft.src.EntityPlayer)trackedEntity));
     }
     if (trackedEntity is net.minecraft.src.EntityMinecart)
     {
         net.minecraft.src.EntityMinecart entityminecart = (net.minecraft.src.EntityMinecart
                                                            )trackedEntity;
         if (entityminecart.minecartType == 0)
         {
             return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 10));
         }
         if (entityminecart.minecartType == 1)
         {
             return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 11));
         }
         if (entityminecart.minecartType == 2)
         {
             return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 12));
         }
     }
     if (trackedEntity is net.minecraft.src.EntityBoat)
     {
         return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 1));
     }
     if (trackedEntity is net.minecraft.src.IAnimals)
     {
         return(new net.minecraft.src.Packet24MobSpawn((net.minecraft.src.EntityLiving)trackedEntity
                                                       ));
     }
     if (trackedEntity is net.minecraft.src.EntityFish)
     {
         return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 90));
     }
     if (trackedEntity is net.minecraft.src.EntityArrow)
     {
         net.minecraft.src.EntityLiving entityliving = ((net.minecraft.src.EntityArrow)trackedEntity
                                                        ).owner;
         return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 60, entityliving
                                                           == null ? trackedEntity.entityId : entityliving.entityId));
     }
     if (trackedEntity is net.minecraft.src.EntitySnowball)
     {
         return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 61));
     }
     if (trackedEntity is net.minecraft.src.EntityFireball)
     {
         net.minecraft.src.EntityFireball       entityfireball       = (net.minecraft.src.EntityFireball)trackedEntity;
         net.minecraft.src.Packet23VehicleSpawn packet23vehiclespawn = new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 63, ((net.minecraft.src.EntityFireball)trackedEntity).owner?.entityId ?? 1); // CRAFTBUKKIT -- added check for null shooter
         packet23vehiclespawn.motionX = (int)(entityfireball.field_9199_b * 8000D);
         packet23vehiclespawn.motionY = (int)(entityfireball.field_9198_c * 8000D);
         packet23vehiclespawn.motionZ = (int)(entityfireball.field_9196_d * 8000D);
         return(packet23vehiclespawn);
     }
     if (trackedEntity is net.minecraft.src.EntityEgg)
     {
         return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 62));
     }
     if (trackedEntity is net.minecraft.src.EntityTNTPrimed)
     {
         return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 50));
     }
     if (trackedEntity is net.minecraft.src.EntityFallingSand)
     {
         net.minecraft.src.EntityFallingSand entityfallingsand = (net.minecraft.src.EntityFallingSand
                                                                  )trackedEntity;
         if (entityfallingsand.blockID == net.minecraft.src.Block.SAND.ID)
         {
             return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 70));
         }
         if (entityfallingsand.blockID == net.minecraft.src.Block.GRAVEL.ID)
         {
             return(new net.minecraft.src.Packet23VehicleSpawn(trackedEntity, 71));
         }
     }
     if (trackedEntity is net.minecraft.src.EntityPainting)
     {
         return(new net.minecraft.src.Packet25EntityPainting((net.minecraft.src.EntityPainting
                                                              )trackedEntity));
     }
     else
     {
         throw new System.ArgumentException((new java.lang.StringBuilder()).Append("Don't know how to add ").Append(trackedEntity.GetType()).Append("!").ToString());
     }
 }