#1209: Clean up various patches
By: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
@@ -4,28 +4,28 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit start;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityCreeper extends EntityMonster implements PowerableMob {
|
||||
|
||||
private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT);
|
||||
@@ -218,9 +224,19 @@
|
||||
@@ -218,9 +224,20 @@
|
||||
@Override
|
||||
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
super.thunderHit(worldserver, entitylightning);
|
||||
- this.entityData.set(EntityCreeper.DATA_IS_POWERED, true);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ this.setPowered(true);
|
||||
+ // CraftBukkit end
|
||||
this.entityData.set(EntityCreeper.DATA_IS_POWERED, true);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setPowered(boolean powered) {
|
||||
+ this.entityData.set(EntityCreeper.DATA_IS_POWERED, powered);
|
||||
+ }
|
||||
@@ -34,22 +34,20 @@
|
||||
@Override
|
||||
protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
@@ -250,10 +266,18 @@
|
||||
@@ -250,10 +267,19 @@
|
||||
if (!this.level().isClientSide) {
|
||||
float f = this.isPowered() ? 2.0F : 1.0F;
|
||||
|
||||
- this.dead = true;
|
||||
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
|
||||
- this.discard();
|
||||
- this.spawnLingeringCloud();
|
||||
+ // CraftBukkit start
|
||||
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent(this, this.explosionRadius * f, false);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.dead = true;
|
||||
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
|
||||
+ this.discard();
|
||||
+ this.spawnLingeringCloud();
|
||||
+ // CraftBukkit end
|
||||
this.dead = true;
|
||||
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
|
||||
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
|
||||
this.discard();
|
||||
this.spawnLingeringCloud();
|
||||
+ // CraftBukkit start
|
||||
+ } else {
|
||||
+ swell = 0;
|
||||
+ }
|
||||
@@ -57,7 +55,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -264,6 +288,7 @@
|
||||
@@ -264,6 +290,7 @@
|
||||
if (!collection.isEmpty()) {
|
||||
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
|
||||
|
||||
@@ -65,7 +63,7 @@
|
||||
entityareaeffectcloud.setRadius(2.5F);
|
||||
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
||||
entityareaeffectcloud.setWaitTime(10);
|
||||
@@ -277,7 +302,7 @@
|
||||
@@ -277,7 +304,7 @@
|
||||
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
--- a/net/minecraft/world/entity/monster/EntityEnderman.java
|
||||
+++ b/net/minecraft/world/entity/monster/EntityEnderman.java
|
||||
@@ -114,7 +114,17 @@
|
||||
@@ -70,6 +70,11 @@
|
||||
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityEnderman extends EntityMonster implements IEntityAngerable {
|
||||
|
||||
private static final UUID SPEED_MODIFIER_ATTACKING_UUID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
|
||||
@@ -114,7 +119,17 @@
|
||||
|
||||
@Override
|
||||
public void setTarget(@Nullable EntityLiving entityliving) {
|
||||
- super.setTarget(entityliving);
|
||||
+ // CraftBukkit start - fire event
|
||||
+ setTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
+ setTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean setTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
|
||||
+ public boolean setTarget(EntityLiving entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
|
||||
+ if (!super.setTarget(entityliving, reason, fireEvent)) {
|
||||
+ return false;
|
||||
+ }
|
||||
@@ -19,7 +31,7 @@
|
||||
AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.MOVEMENT_SPEED);
|
||||
|
||||
if (entityliving == null) {
|
||||
@@ -129,6 +139,7 @@
|
||||
@@ -129,6 +144,7 @@
|
||||
attributemodifiable.addTransientModifier(EntityEnderman.SPEED_MODIFIER_ATTACKING);
|
||||
}
|
||||
}
|
||||
@@ -27,34 +39,27 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -487,9 +498,13 @@
|
||||
@@ -487,9 +503,11 @@
|
||||
if (iblockdata2 != null) {
|
||||
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition);
|
||||
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
|
||||
+ // CraftBukkit start - Place event
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2).isCancelled()) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2)) { // CraftBukkit - Place event
|
||||
world.setBlock(blockposition, iblockdata2, 3);
|
||||
world.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this.enderman, iblockdata2));
|
||||
this.enderman.setCarriedBlock((IBlockData) null);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ } // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -528,9 +543,13 @@
|
||||
@@ -528,9 +546,11 @@
|
||||
boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition);
|
||||
|
||||
if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) {
|
||||
- world.removeBlock(blockposition, false);
|
||||
- world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata));
|
||||
- this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
|
||||
+ // CraftBukkit start - Pickup event
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
|
||||
+ world.removeBlock(blockposition, false);
|
||||
+ world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata));
|
||||
+ this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.defaultBlockState())) { // CraftBukkit - Place event
|
||||
world.removeBlock(blockposition, false);
|
||||
world.gameEvent(GameEvent.BLOCK_DESTROY, blockposition, GameEvent.a.of(this.enderman, iblockdata));
|
||||
this.enderman.setCarriedBlock(iblockdata.getBlock().defaultBlockState());
|
||||
+ } // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
--- a/net/minecraft/world/entity/monster/EntityIllagerWizard.java
|
||||
+++ b/net/minecraft/world/entity/monster/EntityIllagerWizard.java
|
||||
@@ -155,6 +155,11 @@
|
||||
@@ -16,6 +16,10 @@
|
||||
import net.minecraft.world.entity.ai.goal.PathfinderGoal;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityIllagerWizard extends EntityIllagerAbstract {
|
||||
|
||||
private static final DataWatcherObject<Byte> DATA_SPELL_CASTING_ID = DataWatcher.defineId(EntityIllagerWizard.class, DataWatcherRegistry.BYTE);
|
||||
@@ -155,6 +159,11 @@
|
||||
public void tick() {
|
||||
--this.attackWarmupDelay;
|
||||
if (this.attackWarmupDelay == 0) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleEntitySpellCastEvent(EntityIllagerWizard.this, this.getSpell())) {
|
||||
+ if (!CraftEventFactory.handleEntitySpellCastEvent(EntityIllagerWizard.this, this.getSpell())) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
--- a/net/minecraft/world/entity/monster/EntityRavager.java
|
||||
+++ b/net/minecraft/world/entity/monster/EntityRavager.java
|
||||
@@ -170,7 +170,7 @@
|
||||
IBlockData iblockdata = this.level().getBlockState(blockposition);
|
||||
@@ -41,6 +41,10 @@
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityRavager extends EntityRaider {
|
||||
|
||||
private static final Predicate<Entity> NO_RAVAGER_AND_ALIVE = (entity) -> {
|
||||
@@ -171,6 +175,11 @@
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
- if (block instanceof BlockLeaves) {
|
||||
+ if (block instanceof BlockLeaves && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit
|
||||
if (block instanceof BlockLeaves) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
flag = this.level().destroyBlock(blockposition, true, this) || flag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,32 +5,30 @@
|
||||
import org.joml.Vector3f;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.util.CraftLocation;
|
||||
+import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityShulker extends EntityGolem implements VariantHolder<Optional<EnumColor>>, IMonster {
|
||||
|
||||
private static final UUID COVERED_ARMOR_MODIFIER_UUID = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F");
|
||||
@@ -408,6 +414,16 @@
|
||||
@@ -408,6 +414,14 @@
|
||||
EnumDirection enumdirection = this.findAttachableSurface(blockposition1);
|
||||
|
||||
if (enumdirection != null) {
|
||||
+ // CraftBukkit start
|
||||
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), CraftLocation.toBukkit(blockposition1, this.level().getWorld()));
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(teleport);
|
||||
+ if (!teleport.isCancelled()) {
|
||||
+ Location to = teleport.getTo();
|
||||
+ blockposition1 = BlockPosition.containing(to.getX(), to.getY(), to.getZ());
|
||||
+ } else {
|
||||
+ EntityTeleportEvent teleportEvent = CraftEventFactory.callEntityTeleportEvent(this, blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
|
||||
+ if (teleportEvent.isCancelled()) {
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ blockposition1 = CraftLocation.toBlockPosition(teleportEvent.getTo());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.unRide();
|
||||
this.setAttachFace(enumdirection);
|
||||
this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F);
|
||||
@@ -478,7 +494,7 @@
|
||||
@@ -478,7 +492,7 @@
|
||||
if (entityshulker != null) {
|
||||
entityshulker.setVariant(this.getVariant());
|
||||
entityshulker.moveTo(vec3d);
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
--- a/net/minecraft/world/entity/monster/EntitySilverfish.java
|
||||
+++ b/net/minecraft/world/entity/monster/EntitySilverfish.java
|
||||
@@ -175,6 +175,11 @@
|
||||
@@ -33,6 +33,10 @@
|
||||
import net.minecraft.world.level.block.BlockMonsterEggs;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntitySilverfish extends EntityMonster {
|
||||
|
||||
@Nullable
|
||||
@@ -175,6 +179,11 @@
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
if (block instanceof BlockMonsterEggs) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) {
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
world.destroyBlock(blockposition1, true, this.silverfish);
|
||||
} else {
|
||||
@@ -244,6 +249,11 @@
|
||||
@@ -244,6 +253,11 @@
|
||||
IBlockData iblockdata = world.getBlockState(blockposition);
|
||||
|
||||
if (BlockMonsterEggs.isCompatibleHostBlock(iblockdata)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, BlockMonsterEggs.infestedStateByHost(iblockdata)).isCancelled()) {
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, BlockMonsterEggs.infestedStateByHost(iblockdata))) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
Reference in New Issue
Block a user