mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 08:00:02 +03:00
77 lines
3.4 KiB
Diff
77 lines
3.4 KiB
Diff
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityEgg.java
|
|
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityEgg.java
|
|
@@ -1,7 +1,8 @@
|
|
package net.minecraft.entity.projectile;
|
|
|
|
+import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
-import net.minecraft.entity.passive.EntityChicken;
|
|
+import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.init.Items;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.util.DamageSource;
|
|
@@ -11,6 +12,10 @@
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
+import org.bukkit.entity.Ageable;
|
|
+import org.bukkit.entity.EntityType;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.player.PlayerEggThrowEvent;
|
|
|
|
public class EntityEgg extends EntityThrowable
|
|
{
|
|
@@ -57,22 +62,44 @@
|
|
|
|
if (!this.world.isRemote)
|
|
{
|
|
- if (this.rand.nextInt(8) == 0)
|
|
+ boolean hatching = this.rand.nextInt(8) == 0;
|
|
+ if (/*this.rand.nextInt(8) == 0*/ true)
|
|
{
|
|
- int i = 1;
|
|
+ byte i = 1;
|
|
|
|
if (this.rand.nextInt(32) == 0)
|
|
{
|
|
i = 4;
|
|
}
|
|
|
|
- for (int j = 0; j < i; ++j)
|
|
- {
|
|
- EntityChicken entitychicken = new EntityChicken(this.world);
|
|
- entitychicken.setGrowingAge(-24000);
|
|
- entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
|
|
- this.world.spawnEntity(entitychicken);
|
|
+// for (int j = 0; j < i; ++j) {
|
|
+// EntityChicken entitychicken = new EntityChicken(this.world);
|
|
+ if (!hatching) {
|
|
+ i = 0;
|
|
}
|
|
+ EntityType hatchingType = EntityType.CHICKEN;
|
|
+
|
|
+ Entity shooter = this.getThrower();
|
|
+ if (shooter instanceof EntityPlayer) {
|
|
+ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, i, hatchingType);
|
|
+ this.world.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ i = event.getNumHatches();
|
|
+ hatching = event.isHatching();
|
|
+ hatchingType = event.getHatchingType();
|
|
+ }
|
|
+// entitychicken.setGrowingAge(-24000);
|
|
+// entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
|
|
+// this.world.spawnEntity(entitychicken);
|
|
+ if (hatching) {
|
|
+ for (int k = 0; k < i; ++k) {
|
|
+ Entity entity = world.getWorld().createEntity(new org.bukkit.Location(world.getWorld(), this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F), hatchingType.getEntityClass());
|
|
+ if (entity.getBukkitEntity() instanceof Ageable) {
|
|
+ ((Ageable) entity.getBukkitEntity()).setBaby();
|
|
+ }
|
|
+ world.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
this.world.setEntityState(this, (byte)3);
|