3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 22:10:10 +01:00

updated EntityEgg

Dieser Commit ist enthalten in:
Taylor Kelly 2011-01-11 03:44:39 -05:00
Ursprung 94bccb6f92
Commit 6a34f200ae

Datei anzeigen

@ -1,9 +1,12 @@
package net.minecraft.server; package net.minecraft.server;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import org.bukkit.MobType;
import org.bukkit.craftbukkit.CraftPlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerEggThrowEvent;
public class EntityEgg extends Entity { public class EntityEgg extends Entity {
@ -150,20 +153,69 @@ public class EntityEgg extends Entity {
; ;
} }
} }
if (!this.l.z && W.nextInt(8) == 0) {
byte byte0 = 1;
if (W.nextInt(32) == 0) { // Craftbukkit start
byte0 = 4; boolean hatching = !this.l.z && W.nextInt(8) == 0;
byte numHatching = (hatching && W.nextInt(32) == 0) ? (byte) 4 : (byte) 1;
if (!hatching) {
numHatching = 0;
} }
for (int k = 0; k < byte0; k++) { MobType type = MobType.CHICKEN;
EntityChicken entitychicken = new EntityChicken(this.l);
entitychicken.c(p, q, r, v, 0.0F); if (aj instanceof EntityPlayerMP) {
this.l.a(entitychicken); CraftServer server = ((WorldServer) l).getServer();
CraftPlayer player = new CraftPlayer(server, (EntityPlayerMP) aj);
PlayerEggThrowEvent event = new PlayerEggThrowEvent(Type.PLAYER_EGG_THROW, player, hatching, numHatching, type);
server.getPluginManager().callEvent(event);
hatching = event.isHatching();
numHatching = event.getNumHatches();
type = event.getHatchType();
} }
if (hatching) {
for (int k = 0; k < numHatching; k++) {
Entity entity = null;
switch (type) {
case CHICKEN:
entity = new EntityChicken(this.l);
break;
case COW:
entity = new EntityCow(this.l);
break;
case CREEPER:
entity = new EntityCreeper(this.l);
break;
case GHAST:
entity = new EntityGhast(this.l);
break;
case PIG:
entity = new EntityPig(this.l);
break;
case PIG_ZOMBIE:
entity = new EntityPigZombie(this.l);
break;
case SHEEP:
entity = new EntitySheep(this.l);
break;
case SKELETON:
entity = new EntitySkeleton(this.l);
break;
case SPIDER:
entity = new EntitySpider(this.l);
break;
case ZOMBIE:
entity = new EntityZombie(this.l);
break;
default:
entity = new EntityChicken(this.l);
break;
} }
entity.c(p, q, r, v, 0.0F);
this.l.a(entity);
}
}
// Craftbukkit stop
for (int j = 0; j < 8; j++) { for (int j = 0; j < 8; j++) {
this.l.a("snowballpoof", p, q, r, 0.0D, 0.0D, 0.0D); this.l.a("snowballpoof", p, q, r, 0.0D, 0.0D, 0.0D);
} }
@ -235,4 +287,3 @@ public class EntityEgg extends Entity {
} }
} }
} }