13
0
geforkt von Mirrors/Paper

Add list of entities to EntityTransformEvent & move die calls

Dieser Commit ist enthalten in:
nathat890 2018-12-05 09:51:20 +11:00 committet von md_5
Ursprung 38e4c013b6
Commit 20fc5bea2c
6 geänderte Dateien mit 72 neuen und 39 gelöschten Zeilen

Datei anzeigen

@ -13,7 +13,7 @@
public class EntityMushroomCow extends EntityCow { public class EntityMushroomCow extends EntityCow {
public EntityMushroomCow(World world) { public EntityMushroomCow(World world) {
@@ -23,6 +29,14 @@ @@ -23,9 +29,17 @@
return true; return true;
} else if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) { } else if (itemstack.getItem() == Items.SHEARS && this.getAge() >= 0) {
@ -27,8 +27,12 @@
+ // CraftBukkit end + // CraftBukkit end
this.world.addParticle(Particles.u, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D); this.world.addParticle(Particles.u, this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D);
if (!this.world.isClientSide) { if (!this.world.isClientSide) {
this.die(); - this.die();
@@ -35,7 +49,12 @@ + // this.die(); // CraftBukkit - moved down
EntityCow entitycow = new EntityCow(this.world);
entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
@@ -35,7 +49,14 @@
entitycow.setCustomName(this.getCustomName()); entitycow.setCustomName(this.getCustomName());
} }
@ -38,6 +42,8 @@
+ return false; + return false;
+ } + }
+ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); + this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
+
+ this.die(); // CraftBukkit - from above
+ // CraftBukkit end + // CraftBukkit end
for (int i = 0; i < 5; ++i) { for (int i = 0; i < 5; ++i) {

Datei anzeigen

@ -28,31 +28,18 @@
} }
@Nullable @Nullable
@@ -149,6 +155,12 @@ @@ -157,7 +163,13 @@
if (!this.world.isClientSide && !this.dead) {
EntityPigZombie entitypigzombie = new EntityPigZombie(this.world);
+ // CraftBukkit start
+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
entitypigzombie.setSlot(EnumItemSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD));
entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
entitypigzombie.setNoAI(this.isNoAI());
@@ -157,7 +169,13 @@
entitypigzombie.setCustomNameVisible(this.getCustomNameVisible()); entitypigzombie.setCustomNameVisible(this.getCustomNameVisible());
} }
- this.world.addEntity(entitypigzombie); - this.world.addEntity(entitypigzombie);
+ // CraftBukkit start + // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitypigzombie, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) { + if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
+ return; + return;
+ } + }
+ // CraftBukkit end
+ // CraftBukkit - added a reason for spawning this creature + // CraftBukkit - added a reason for spawning this creature
+ this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); + this.world.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
+ // CraftBukkit end
this.die(); this.die();
} }
} }

Datei anzeigen

@ -1,10 +1,12 @@
--- a/net/minecraft/server/EntitySlime.java --- a/net/minecraft/server/EntitySlime.java
+++ b/net/minecraft/server/EntitySlime.java +++ b/net/minecraft/server/EntitySlime.java
@@ -1,6 +1,11 @@ @@ -1,6 +1,13 @@
package net.minecraft.server; package net.minecraft.server;
import javax.annotation.Nullable; import javax.annotation.Nullable;
+// CraftBukkit start +// CraftBukkit start
+import java.util.ArrayList;
+import java.util.List;
+import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTransformEvent; +import org.bukkit.event.entity.EntityTransformEvent;
+import org.bukkit.event.entity.SlimeSplitEvent; +import org.bukkit.event.entity.SlimeSplitEvent;
@ -12,7 +14,7 @@
public class EntitySlime extends EntityInsentient implements IMonster { public class EntitySlime extends EntityInsentient implements IMonster {
@@ -134,7 +139,7 @@ @@ -134,7 +141,7 @@
} }
public EntityTypes<? extends EntitySlime> P() { public EntityTypes<? extends EntitySlime> P() {
@ -21,7 +23,7 @@
} }
public void die() { public void die() {
@@ -143,6 +148,18 @@ @@ -143,6 +150,19 @@
if (!this.world.isClientSide && i > 1 && this.getHealth() <= 0.0F) { if (!this.world.isClientSide && i > 1 && this.getHealth() <= 0.0F) {
int j = 2 + this.random.nextInt(3); int j = 2 + this.random.nextInt(3);
@ -35,23 +37,29 @@
+ super.die(); + super.die();
+ return; + return;
+ } + }
+ List<EntityLiving> slimes = new ArrayList<>(j);
+ // CraftBukkit end + // CraftBukkit end
+ +
for (int k = 0; k < j; ++k) { for (int k = 0; k < j; ++k) {
float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F; float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F; float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
@@ -158,7 +175,13 @@ @@ -158,8 +178,18 @@
entityslime.setSize(i / 2, true); entityslime.setSize(i / 2, true);
entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F); entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
- this.world.addEntity(entityslime); - this.world.addEntity(entityslime);
+ +
+ // CraftBukkit start + slimes.add(entityslime); // CraftBukkit
+ if (CraftEventFactory.callEntityTransformEvent(this, entityslime, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { + }
+ continue; +
+ } + // CraftBukkit start
+ // CraftBukkit end + if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) {
+ this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason + return;
+ }
+ for (EntityLiving living : slimes) {
+ this.world.addEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
} }
+ // CraftBukkit end
} }
super.die();

Datei anzeigen

@ -96,7 +96,16 @@
} }
} }
@@ -372,7 +405,12 @@ @@ -362,7 +395,7 @@
EntityZombieVillager entityzombievillager = new EntityZombieVillager(this.world);
entityzombievillager.u(entityvillager);
- this.world.kill(entityvillager);
+ // this.world.kill(entityvillager); // CraftBukkit - moved down
entityzombievillager.prepare(this.world.getDamageScaler(new BlockPosition(entityzombievillager)), new EntityZombie.GroupDataZombie(false, null), (NBTTagCompound) null);
entityzombievillager.setProfession(entityvillager.getProfession());
entityzombievillager.setBaby(entityvillager.isBaby());
@@ -372,7 +405,13 @@
entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible()); entityzombievillager.setCustomNameVisible(entityvillager.getCustomNameVisible());
} }
@ -105,12 +114,13 @@
+ if (CraftEventFactory.callEntityTransformEvent(this, entityzombievillager, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) { + if (CraftEventFactory.callEntityTransformEvent(this, entityzombievillager, EntityTransformEvent.TransformReason.INFECTION).isCancelled()) {
+ return; + return;
+ } + }
+ // CraftBukkit end + this.world.kill(entityvillager); // CraftBukkit - from above
+ this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason + this.world.addEntity(entityzombievillager, CreatureSpawnEvent.SpawnReason.INFECTION); // CraftBukkit - add SpawnReason
+ // CraftBukkit end
this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0); this.world.a((EntityHuman) null, 1026, new BlockPosition(this), 0);
} }
@@ -422,7 +460,7 @@ @@ -422,7 +461,7 @@
entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F); entitychicken1.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, 0.0F);
entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null); entitychicken1.prepare(difficultydamagescaler, (GroupDataEntity) null, (NBTTagCompound) null);
entitychicken1.s(true); entitychicken1.s(true);
@ -119,7 +129,7 @@
this.startRiding(entitychicken1); this.startRiding(entitychicken1);
} }
} }
@@ -495,7 +533,7 @@ @@ -495,7 +534,7 @@
} }
public void die(DamageSource damagesource) { public void die(DamageSource damagesource) {
@ -128,7 +138,7 @@
if (damagesource.getEntity() instanceof EntityCreeper) { if (damagesource.getEntity() instanceof EntityCreeper) {
EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity(); EntityCreeper entitycreeper = (EntityCreeper) damagesource.getEntity();
@@ -508,6 +546,7 @@ @@ -508,6 +547,7 @@
} }
} }
} }

Datei anzeigen

@ -47,7 +47,15 @@
this.world.broadcastEntityEffect(this, (byte) 16); this.world.broadcastEntityEffect(this, (byte) 16);
} }
@@ -123,7 +135,12 @@ @@ -116,14 +128,20 @@
entityvillager.setAgeRaw(-24000);
}
- this.world.kill(this);
+ // this.world.kill(this); // CraftBukkit - moved down
entityvillager.setNoAI(this.isNoAI());
if (this.hasCustomName()) {
entityvillager.setCustomName(this.getCustomName());
entityvillager.setCustomNameVisible(this.getCustomNameVisible()); entityvillager.setCustomNameVisible(this.getCustomNameVisible());
} }
@ -56,12 +64,13 @@
+ if (CraftEventFactory.callEntityTransformEvent(this, entityvillager, EntityTransformEvent.TransformReason.CURED).isCancelled()) { + if (CraftEventFactory.callEntityTransformEvent(this, entityvillager, EntityTransformEvent.TransformReason.CURED).isCancelled()) {
+ return; + return;
+ } + }
+ // CraftBukkit end + this.world.kill(this); // CraftBukkit - from above
+ this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason + this.world.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CURED); // CraftBukkit - add SpawnReason
+ // CraftBukkit end
if (this.bD != null) { if (this.bD != null) {
EntityHuman entityhuman = this.world.b(this.bD); EntityHuman entityhuman = this.world.b(this.bD);
@@ -132,7 +149,7 @@ @@ -132,7 +150,7 @@
} }
} }

Datei anzeigen

@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.event;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -303,8 +304,20 @@ public class CraftEventFactory {
/** /**
* EntityTransformEvent * EntityTransformEvent
*/ */
public static EntityTransformEvent callEntityTransformEvent(EntityLiving original, EntityLiving converted, EntityTransformEvent.TransformReason convertType) { public static EntityTransformEvent callEntityTransformEvent(EntityLiving original, EntityLiving coverted, EntityTransformEvent.TransformReason transformReason) {
EntityTransformEvent event = new EntityTransformEvent(original.getBukkitEntity(), converted.getBukkitEntity(), convertType); return callEntityTransformEvent(original, Collections.singletonList(coverted), transformReason);
}
/**
* EntityTransformEvent
*/
public static EntityTransformEvent callEntityTransformEvent(EntityLiving original, List<EntityLiving> convertedList, EntityTransformEvent.TransformReason convertType) {
List<org.bukkit.entity.Entity> list = new ArrayList<>();
for (EntityLiving entityLiving : convertedList) {
list.add(entityLiving.getBukkitEntity());
}
EntityTransformEvent event = new EntityTransformEvent(original.getBukkitEntity(), list, convertType);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
return event; return event;