#1209: Clean up various patches

By: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
CraftBukkit/Spigot 2023-06-24 17:15:05 +10:00
parent 0f9e7a497e
commit b97cc9b99f
71 changed files with 662 additions and 719 deletions

View File

@ -18,34 +18,3 @@
d1 = Double.MAX_VALUE;
CommandSpreadPlayers.a[] acommandspreadplayers_a1 = acommandspreadplayers_a;
int k = acommandspreadplayers_a.length;
@@ -301,7 +301,7 @@
for (boolean flag2 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir(); blockposition_mutableblockposition.getY() > iblockaccess.getMinBuildHeight(); flag2 = flag1) {
blockposition_mutableblockposition.move(EnumDirection.DOWN);
- flag1 = iblockaccess.getBlockState(blockposition_mutableblockposition).isAir();
+ flag1 = getBlockState(iblockaccess, blockposition_mutableblockposition).isAir(); // CraftBukkit
if (!flag1 && flag2 && flag) {
return blockposition_mutableblockposition.getY() + 1;
}
@@ -314,7 +314,7 @@
public boolean isSafe(IBlockAccess iblockaccess, int i) {
BlockPosition blockposition = BlockPosition.containing(this.x, (double) (this.getSpawnY(iblockaccess, i) - 1), this.z);
- IBlockData iblockdata = iblockaccess.getBlockState(blockposition);
+ IBlockData iblockdata = getBlockState(iblockaccess, blockposition); // CraftBukkit
return blockposition.getY() < i && !iblockdata.liquid() && !iblockdata.is(TagsBlock.FIRE);
}
@@ -323,5 +323,12 @@
this.x = MathHelper.nextDouble(randomsource, d0, d2);
this.z = MathHelper.nextDouble(randomsource, d1, d3);
}
+
+ // CraftBukkit start - add a version of getBlockState which force loads chunks
+ private static IBlockData getBlockState(IBlockAccess iblockaccess, BlockPosition position) {
+ ((WorldServer) iblockaccess).getChunkSource().getChunk(position.getX() >> 4, position.getZ() >> 4, true);
+ return iblockaccess.getBlockState(position);
+ }
+ // CraftBukkit end
}
}

View File

@ -113,22 +113,15 @@
if (!collection.isEmpty()) {
consumer.accept(new PacketPlayOutUpdateAttributes(this.entity.getId(), collection));
}
@@ -300,8 +339,14 @@
@@ -300,6 +339,7 @@
if (!list.isEmpty()) {
consumer.accept(new PacketPlayOutEntityEquipment(this.entity.getId(), list));
}
+ ((EntityLiving) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending
}
+ // CraftBukkit start - Fix for nonsensical head yaw
+ this.yHeadRotp = MathHelper.floor(this.entity.getYHeadRot() * 256.0F / 360.0F);
+ consumer.accept(new PacketPlayOutEntityHeadRotation(this.entity, (byte) yHeadRotp));
+ // CraftBukkit end
+
if (!this.entity.getPassengers().isEmpty()) {
consumer.accept(new PacketPlayOutMount(this.entity));
}
@@ -333,6 +378,11 @@
@@ -333,6 +373,11 @@
Set<AttributeModifiable> set = ((EntityLiving) this.entity).getAttributes().getDirtyAttributes();
if (!set.isEmpty()) {

View File

@ -329,7 +329,7 @@
if (enuminteractionresult.consumesAction()) {
CriterionTriggers.ITEM_USED_ON_BLOCK.trigger(entityplayer, blockposition, itemstack1);
@@ -342,17 +538,17 @@
@@ -342,7 +538,7 @@
}
}
@ -338,18 +338,6 @@
ItemActionContext itemactioncontext = new ItemActionContext(entityplayer, enumhand, movingobjectpositionblock);
EnumInteractionResult enuminteractionresult1;
if (this.isCreative()) {
int i = itemstack.getCount();
- enuminteractionresult1 = itemstack.useOn(itemactioncontext);
+ enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand);
itemstack.setCount(i);
} else {
- enuminteractionresult1 = itemstack.useOn(itemactioncontext);
+ enuminteractionresult1 = itemstack.useOn(itemactioncontext, enumhand);
}
if (enuminteractionresult1.consumesAction()) {
@@ -360,10 +556,10 @@
}

View File

@ -1,6 +1,11 @@
--- a/net/minecraft/server/players/JsonList.java
+++ b/net/minecraft/server/players/JsonList.java
@@ -54,7 +54,7 @@
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.server.players;
import com.google.common.collect.Lists;
@@ -54,7 +55,7 @@
@Nullable
public V get(K k0) {
this.removeExpired();
@ -9,20 +14,7 @@
}
public void remove(K k0) {
@@ -76,6 +76,12 @@
return (String[]) this.map.keySet().toArray(new String[0]);
}
+ // CraftBukkit start
+ public Collection<V> getValues() {
+ return this.map.values();
+ }
+ // CraftBukkit end
+
public boolean isEmpty() {
return this.map.size() < 1;
}
@@ -93,7 +99,7 @@
@@ -93,7 +94,7 @@
Iterator iterator = this.map.values().iterator();
while (iterator.hasNext()) {
@ -31,7 +23,7 @@
if (v0.hasExpired()) {
list.add(v0.getUser());
@@ -103,7 +109,7 @@
@@ -103,7 +104,7 @@
iterator = list.iterator();
while (iterator.hasNext()) {
@ -40,7 +32,7 @@
this.map.remove(this.getKeyForUser(k0));
}
@@ -118,7 +124,7 @@
@@ -118,7 +119,7 @@
public void save() throws IOException {
JsonArray jsonarray = new JsonArray();
@ -49,7 +41,7 @@
JsonObject jsonobject = new JsonObject();
Objects.requireNonNull(jsonlistentry);
@@ -165,7 +171,7 @@
@@ -165,7 +166,7 @@
JsonListEntry<K> jsonlistentry = this.createEntry(jsonobject);
if (jsonlistentry.getUser() != null) {

View File

@ -1,12 +1,13 @@
--- a/net/minecraft/world/effect/MobEffectList.java
+++ b/net/minecraft/world/effect/MobEffectList.java
@@ -19,6 +19,13 @@
@@ -19,6 +19,14 @@
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.player.EntityHuman;
+// CraftBukkit start
+import net.minecraft.network.protocol.game.PacketPlayOutUpdateHealth;
+import net.minecraft.server.level.EntityPlayer;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
+// CraftBukkit end
@ -14,7 +15,7 @@
public class MobEffectList {
private final Map<AttributeBase, AttributeModifier> attributeModifiers = Maps.newHashMap();
@@ -55,26 +62,37 @@
@@ -55,26 +63,35 @@
public void applyEffectTick(EntityLiving entityliving, int i) {
if (this == MobEffects.REGENERATION) {
if (entityliving.getHealth() < entityliving.getMaxHealth()) {
@ -37,14 +38,12 @@
+ // CraftBukkit start
+ EntityHuman entityhuman = (EntityHuman) entityliving;
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
+
+ org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, i + 1 + oldFoodLevel);
+
+ if (!event.isCancelled()) {
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
+ }
+
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel));
+ ((CraftPlayer) entityhuman.getBukkitEntity()).sendHealthUpdate();
+ // CraftBukkit end
}
} else if ((this != MobEffects.HEAL || entityliving.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entityliving.isInvertedHealAndHarm())) {
@ -57,7 +56,7 @@
}
}
@@ -95,7 +113,7 @@
@@ -95,7 +112,7 @@
}
} else {
j = (int) (d0 * (double) (4 << i) + 0.5D);

View File

@ -432,16 +432,31 @@
this.level().addFreshEntity(entityitem);
return entityitem;
}
@@ -2013,7 +2300,7 @@
@@ -2025,7 +2312,22 @@
}
this.setPose(EntityPose.STANDING);
this.vehicle = entity;
- this.vehicle.addPassenger(this);
+ if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit
entity.getIndirectPassengersStream().filter((entity2) -> {
return entity2 instanceof EntityPlayer;
}).forEach((entity2) -> {
@@ -2044,7 +2331,7 @@
protected boolean canRide(Entity entity) {
- return !this.isShiftKeyDown() && this.boardingCooldown <= 0;
+ // CraftBukkit start
+ boolean result = !this.isShiftKeyDown() && this.boardingCooldown <= 0;
+ if (result) {
+ if (entity.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof LivingEntity) {
+ VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), (LivingEntity) this.getBukkitEntity());
+ // Suppress during worldgen
+ if (this.valid) {
+ Bukkit.getPluginManager().callEvent(event);
+ }
+ if (event.isCancelled()) {
+ return false;
+ }
+ }
+ }
+ return result;
+ // CraftBukkit end
}
protected boolean canEnterPose(EntityPose entitypose) {
@@ -2044,7 +2346,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@ -450,44 +465,8 @@
}
}
@@ -2053,10 +2340,31 @@
this.removeVehicle();
}
- protected void addPassenger(Entity entity) {
+ protected boolean addPassenger(Entity entity) { // CraftBukkit
if (entity.getVehicle() != this) {
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
} else {
+ // CraftBukkit start
+ com.google.common.base.Preconditions.checkState(!entity.passengers.contains(this), "Circular entity riding! %s %s", this, entity);
+
+ CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
+ Entity orig = craft == null ? null : craft.getHandle();
+ if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
+ VehicleEnterEvent event = new VehicleEnterEvent(
+ (Vehicle) getBukkitEntity(),
+ entity.getBukkitEntity()
+ );
+ // Suppress during worldgen
+ if (this.valid) {
+ Bukkit.getPluginManager().callEvent(event);
+ }
+ CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
+ Entity n = craftn == null ? null : craftn.getHandle();
+ if (event.isCancelled() || n != orig) {
+ return false;
+ }
+ }
+ // CraftBukkit end
if (this.passengers.isEmpty()) {
this.passengers = ImmutableList.of(entity);
} else {
@@ -2073,12 +2381,32 @@
this.gameEvent(GameEvent.ENTITY_MOUNT, entity);
@@ -2075,10 +2377,29 @@
}
+ return true; // CraftBukkit
}
- protected void removePassenger(Entity entity) {
@ -517,7 +496,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -2090,6 +2418,7 @@
@@ -2090,6 +2411,7 @@
entity.boardingCooldown = 60;
this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity);
}
@ -525,7 +504,7 @@
}
protected boolean canAddPassenger(Entity entity) {
@@ -2156,14 +2485,20 @@
@@ -2156,14 +2478,20 @@
if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getServer();
@ -549,7 +528,7 @@
this.level().getProfiler().pop();
}
@@ -2283,6 +2618,13 @@
@@ -2283,6 +2611,13 @@
}
public void setSwimming(boolean flag) {
@ -563,7 +542,7 @@
this.setSharedFlag(4, flag);
}
@@ -2332,8 +2674,12 @@
@@ -2332,8 +2667,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
}
@ -577,7 +556,7 @@
}
public boolean getSharedFlag(int i) {
@@ -2352,7 +2698,7 @@
@@ -2352,7 +2691,7 @@
}
public int getMaxAirSupply() {
@ -586,7 +565,7 @@
}
public int getAirSupply() {
@@ -2360,7 +2706,18 @@
@@ -2360,7 +2699,18 @@
}
public void setAirSupply(int i) {
@ -606,7 +585,7 @@
}
public int getTicksFrozen() {
@@ -2387,11 +2744,41 @@
@@ -2387,11 +2737,41 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -650,7 +629,7 @@
}
public void onAboveBubbleCol(boolean flag) {
@@ -2556,15 +2943,38 @@
@@ -2556,15 +2936,38 @@
@Nullable
public Entity changeDimension(WorldServer worldserver) {
@ -691,7 +670,7 @@
this.level().getProfiler().popPush("reloading");
Entity entity = this.getType().create(worldserver);
@@ -2573,9 +2983,17 @@
@@ -2573,9 +2976,17 @@
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setDeltaMovement(shapedetectorshape.speed);
worldserver.addDuringTeleport(entity);
@ -711,7 +690,7 @@
}
this.removeAfterChangingDimensions();
@@ -2596,20 +3014,34 @@
@@ -2596,20 +3007,34 @@
@Nullable
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
@ -751,7 +730,7 @@
IBlockData iblockdata = this.level().getBlockState(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d;
@@ -2626,8 +3058,8 @@
@@ -2626,8 +3051,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
}
@ -762,7 +741,7 @@
}
} else {
BlockPosition blockposition1;
@@ -2637,8 +3069,14 @@
@@ -2637,8 +3062,14 @@
} else {
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
}
@ -778,7 +757,7 @@
}
}
@@ -2646,8 +3084,23 @@
@@ -2646,8 +3077,23 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
}
@ -804,7 +783,7 @@
}
public boolean canChangeDimensions() {
@@ -2767,6 +3220,12 @@
@@ -2767,6 +3213,12 @@
}
}
@ -817,7 +796,7 @@
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
float f2 = MathHelper.clamp(f1, -90.0F, 90.0F);
@@ -2901,7 +3360,26 @@
@@ -2901,7 +3353,26 @@
}
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@ -845,7 +824,7 @@
}
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
@@ -3212,6 +3690,11 @@
@@ -3212,6 +3683,11 @@
vec3d = vec3d.add(vec3d1);
++k1;
}

View File

@ -13,30 +13,25 @@
public class EntityAreaEffectCloud extends Entity implements TraceableEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -129,6 +135,22 @@
@@ -44,7 +50,7 @@
private static final float DEFAULT_RADIUS = 3.0F;
public static final float DEFAULT_WIDTH = 6.0F;
public static final float HEIGHT = 0.5F;
- private PotionRegistry potion;
+ public PotionRegistry potion; // CraftBukkit - private -> public
public List<MobEffect> effects;
private final Map<Entity, Integer> victims;
private int duration;
@@ -112,7 +118,7 @@
}
+ // CraftBukkit start accessor methods
+ public void refreshEffects() {
+ if (!this.fixedColor) {
+ this.getEntityData().set(EntityAreaEffectCloud.DATA_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, this.effects)));
+ }
+ }
+
+ public String getPotionType() {
+ return ((MinecraftKey) BuiltInRegistries.POTION.getKey(this.potion)).toString();
+ }
+
+ public void setPotionType(String string) {
+ setPotion(BuiltInRegistries.POTION.get(new MinecraftKey(string)));
+ }
+ // CraftBukkit end
+
public int getColor() {
return (Integer) this.getEntityData().get(EntityAreaEffectCloud.DATA_COLOR);
}
@@ -263,6 +285,7 @@
- private void updateColor() {
+ public void updateColor() { // Craftbukkit - private -> public
if (this.potion == Potions.EMPTY && this.effects.isEmpty()) {
this.getEntityData().set(EntityAreaEffectCloud.DATA_COLOR, 0);
} else {
@@ -263,6 +269,7 @@
if (!list1.isEmpty()) {
Iterator iterator1 = list1.iterator();
@ -44,7 +39,7 @@
while (iterator1.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator1.next();
@@ -272,6 +295,17 @@
@@ -272,6 +279,17 @@
double d8 = d6 * d6 + d7 * d7;
if (d8 <= (double) (f * f)) {
@ -62,7 +57,7 @@
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
Iterator iterator2 = list.iterator();
@@ -281,7 +315,7 @@
@@ -281,7 +299,7 @@
if (mobeffect1.getEffect().isInstantenous()) {
mobeffect1.getEffect().applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else {

View File

@ -382,7 +382,7 @@
this.hurtCurrentlyUsedShield(f);
f2 = f;
f = 0.0F;
@@ -1163,27 +1371,46 @@
@@ -1163,23 +1371,33 @@
this.walkAnimation.setSpeed(1.5F);
boolean flag1 = true;
@ -421,20 +421,7 @@
this.hurtHelmet(damagesource, f);
f *= 0.75F;
}
+ // CraftBukkit start
+ if (this instanceof EntityAnimal) {
+ ((EntityAnimal) this).resetLove();
+ if (this instanceof EntityTameableAnimal) {
+ ((EntityTameableAnimal) this).setOrderedToSit(false);
+ }
+ }
+ // CraftBukkit end
+
Entity entity1 = damagesource.getEntity();
if (entity1 != null) {
@@ -1297,19 +1524,32 @@
@@ -1297,19 +1515,32 @@
EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length;
@ -471,7 +458,7 @@
EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
@@ -1317,14 +1557,16 @@
@@ -1317,14 +1548,16 @@
}
this.setHealth(1.0F);
@ -493,7 +480,7 @@
}
}
@@ -1433,14 +1675,22 @@
@@ -1433,14 +1666,22 @@
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
@ -518,7 +505,7 @@
this.level().addFreshEntity(entityitem);
}
}
@@ -1460,21 +1710,40 @@
@@ -1460,21 +1701,40 @@
boolean flag = this.lastHurtByPlayerTime > 0;
@ -548,7 +535,7 @@
+ return i;
+ } else {
+ return 0;
}
+ }
+ }
+ // CraftBukkit end
+
@ -557,12 +544,12 @@
+ if (true && !(this instanceof net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time
+ EntityExperienceOrb.award((WorldServer) this.level(), this.position(), this.expToDrop);
+ this.expToDrop = 0;
+ }
}
+ // CraftBukkit end
}
@@ -1565,6 +1834,28 @@
@@ -1565,6 +1825,28 @@
return itemstack.getEatingSound();
}
@ -591,7 +578,7 @@
public Optional<BlockPosition> getLastClimbablePos() {
return this.lastClimbablePos;
}
@@ -1611,9 +1902,14 @@
@@ -1611,9 +1893,14 @@
int i = this.calculateFallDamage(f, f1);
if (i > 0) {
@ -607,7 +594,7 @@
return true;
} else {
return flag;
@@ -1665,7 +1961,7 @@
@@ -1665,7 +1952,7 @@
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) {
@ -616,7 +603,7 @@
f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
}
@@ -1678,7 +1974,8 @@
@@ -1678,7 +1965,8 @@
} else {
int i;
@ -626,7 +613,7 @@
i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -1711,16 +2008,125 @@
@@ -1711,16 +1999,125 @@
}
}
@ -645,7 +632,10 @@
+ public Double apply(Double f) {
+ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !EntityLiving.this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
+ return -(f - (f * 0.75F));
+
- f = Math.max(f - this.getAbsorptionAmount(), 0.0F);
- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f));
- float f2 = f1 - f;
+ }
+ return -0.0;
+ }
@ -713,9 +703,6 @@
+
+ f = (float) event.getFinalDamage();
- f = Math.max(f - this.getAbsorptionAmount(), 0.0F);
- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f));
- float f2 = f1 - f;
+ // Resistance
+ if (event.getDamage(DamageModifier.RESISTANCE) < 0) {
+ float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE);
@ -727,7 +714,7 @@
+ }
+ }
+ }
+
+ // Apply damage to helmet
+ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
+ this.hurtHelmet(damagesource, f);
@ -760,7 +747,7 @@
if (f2 > 0.0F && f2 < 3.4028235E37F) {
Entity entity = damagesource.getEntity();
@@ -1731,13 +2137,47 @@
@@ -1731,13 +2128,47 @@
}
}
@ -810,7 +797,7 @@
}
public CombatTracker getCombatTracker() {
@@ -1758,8 +2198,18 @@
@@ -1758,8 +2189,18 @@
}
public final void setArrowCount(int i) {
@ -830,7 +817,7 @@
public final int getStingerCount() {
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
@@ -2001,6 +2451,12 @@
@@ -2001,6 +2442,12 @@
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
@ -843,7 +830,7 @@
@Override
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
@@ -2238,6 +2694,7 @@
@@ -2238,6 +2685,7 @@
}
if (this.onGround() && !this.level().isClientSide) {
@ -851,7 +838,7 @@
this.setSharedFlag(7, false);
}
} else {
@@ -2809,6 +3266,7 @@
@@ -2809,6 +3257,7 @@
}
if (!this.level().isClientSide) {
@ -859,7 +846,7 @@
this.setSharedFlag(7, flag);
}
@@ -2968,14 +3426,21 @@
@@ -2968,14 +3417,21 @@
@Override
public boolean isPickable() {
@ -883,7 +870,7 @@
@Override
public float getYHeadRot() {
return this.yHeadRot;
@@ -3170,7 +3635,26 @@
@@ -3170,7 +3626,26 @@
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
this.triggerItemUseEffects(this.useItem, 16);
@ -911,7 +898,7 @@
if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack);
@@ -3248,6 +3732,12 @@
@@ -3248,6 +3723,12 @@
}
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
@ -924,7 +911,7 @@
double d3 = this.getX();
double d4 = this.getY();
double d5 = this.getZ();
@@ -3272,16 +3762,41 @@
@@ -3272,16 +3753,41 @@
}
if (flag2) {
@ -969,7 +956,7 @@
} else {
if (flag) {
world.broadcastEntityEvent(this, (byte) 46);
@@ -3291,7 +3806,7 @@
@@ -3291,7 +3797,7 @@
((EntityCreature) this).getNavigation().stop();
}
@ -978,7 +965,7 @@
}
}
@@ -3374,7 +3889,7 @@
@@ -3374,7 +3880,7 @@
}
public void stopSleeping() {
@ -987,7 +974,7 @@
World world = this.level();
java.util.Objects.requireNonNull(world);
@@ -3408,7 +3923,7 @@
@@ -3408,7 +3914,7 @@
@Nullable
public EnumDirection getBedOrientation() {
@ -996,7 +983,7 @@
return blockposition != null ? BlockBed.getBedOrientation(this.level(), blockposition) : null;
}
@@ -3456,7 +3971,7 @@
@@ -3456,7 +3962,7 @@
Pair<MobEffect, Float> pair = (Pair) iterator.next();
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {

View File

@ -1,17 +1,18 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
@@ -26,6 +26,10 @@
@@ -26,6 +26,11 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import net.minecraft.world.level.block.Blocks;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class BehaviorFarm extends Behavior<EntityVillager> {
private static final int HARVEST_DURATION = 200;
@@ -81,8 +85,8 @@
@@ -81,8 +86,8 @@
protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) {
if (i > this.nextOkStartTime && this.aboveFarmlandPos != null) {
@ -22,37 +23,29 @@
}
}
@@ -102,7 +106,11 @@
@@ -102,7 +107,9 @@
Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock();
if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) {
- worldserver.destroyBlock(this.aboveFarmlandPos, true, entityvillager);
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ worldserver.destroyBlock(this.aboveFarmlandPos, true, entityvillager);
+ }
+ // CraftBukkit end
+ if (CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, Blocks.AIR.defaultBlockState())) { // CraftBukkit
worldserver.destroyBlock(this.aboveFarmlandPos, true, entityvillager);
+ } // CraftBukkit
}
if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) {
@@ -119,9 +127,13 @@
@@ -119,9 +126,11 @@
ItemBlock itemblock = (ItemBlock) item;
IBlockData iblockdata1 = itemblock.getBlock().defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
- flag = true;
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1).isCancelled()) {
+ worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
+ worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
+ flag = true;
+ }
+ // CraftBukkit end
+ if (CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1)) { // CraftBukkit
worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
+ } // CraftBukkit
}
}
@@ -141,8 +153,8 @@
@@ -141,8 +150,8 @@
this.aboveFarmlandPos = this.getValidFarmland(worldserver);
if (this.aboveFarmlandPos != null) {
this.nextOkStartTime = i + 20L;

View File

@ -1,26 +1,39 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
@@ -116,11 +116,16 @@
@@ -18,6 +18,11 @@
import net.minecraft.world.entity.npc.EntityVillager;
import net.minecraft.world.level.pathfinder.PathEntity;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+// CraftBukkit end
+
public class BehaviorMakeLove extends Behavior<EntityVillager> {
private static final int INTERACT_DIST_SQR = 5;
@@ -116,11 +121,17 @@
if (entityvillager2 == null) {
return Optional.empty();
} else {
- entityvillager.setAge(6000);
- entityvillager1.setAge(6000);
+ // CraftBukkit start - call EntityBreedEvent
entityvillager2.setAge(-24000);
entityvillager2.moveTo(entityvillager.getX(), entityvillager.getY(), entityvillager.getZ(), 0.0F, 0.0F);
- worldserver.addFreshEntityWithPassengers(entityvillager2);
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) {
+ // CraftBukkit start - call EntityBreedEvent
+ if (CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) {
+ return Optional.empty();
+ }
+ // CraftBukkit end
+ // Move age setting down
+ entityvillager.setAge(6000);
+ entityvillager1.setAge(6000);
+ worldserver.addFreshEntityWithPassengers(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
+ worldserver.addFreshEntityWithPassengers(entityvillager2, CreatureSpawnEvent.SpawnReason.BREEDING);
+ // CraftBukkit end
worldserver.broadcastEntityEvent(entityvillager2, (byte) 12);
return Optional.of(entityvillager2);
}
@@ -129,6 +134,6 @@
@@ -129,6 +140,6 @@
private void giveBedToChild(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) {
GlobalPos globalpos = GlobalPos.of(worldserver.dimension(), blockposition);

View File

@ -11,23 +11,21 @@
public class PathfinderGoalEatTile extends PathfinderGoal {
private static final int EAT_ANIMATION_TICKS = 40;
@@ -64,7 +68,8 @@
@@ -64,7 +68,7 @@
BlockPosition blockposition = this.mob.blockPosition();
if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) {
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ // CraftBukkit
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
this.level.destroyBlock(blockposition, false);
}
@@ -73,7 +78,8 @@
@@ -73,7 +77,7 @@
BlockPosition blockposition1 = blockposition.below();
if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) {
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ // CraftBukkit
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
this.level.levelEvent(2001, blockposition1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState()));
this.level.setBlock(blockposition1, Blocks.DIRT.defaultBlockState(), 2);
}

View File

@ -6,28 +6,24 @@
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTeleportEvent;
+// CraftBukkit end
+
public class PathfinderGoalFollowOwner extends PathfinderGoal {
public static final int TELEPORT_WHEN_DISTANCE_IS = 12;
@@ -122,7 +128,18 @@
@@ -122,7 +128,14 @@
} else if (!this.canTeleportTo(new BlockPosition(i, j, k))) {
return false;
} else {
- this.tamable.moveTo((double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot());
+ // CraftBukkit start
+ CraftEntity entity = this.tamable.getBukkitEntity();
+ Location to = new Location(entity.getWorld(), (double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot());
+ EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
+ this.tamable.level().getCraftServer().getPluginManager().callEvent(event);
+ EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this.tamable, (double) i + 0.5D, (double) j, (double) k + 0.5D);
+ if (event.isCancelled()) {
+ return false;
+ }
+ to = event.getTo();
+
+ Location to = event.getTo();
+ this.tamable.moveTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
+ // CraftBukkit end
this.navigation.stop();

View File

@ -1,34 +0,0 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.java
@@ -10,6 +10,10 @@
import net.minecraft.world.level.IBlockAccess;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import net.minecraft.world.entity.EntityLiving;
+// CraftBukkit end
+
public class PathfinderGoalPanic extends PathfinderGoal {
public static final int WATER_CHECK_DISTANCE_VERTICAL = 1;
@@ -80,6 +84,12 @@
@Override
public boolean canContinueToUse() {
+ // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly
+ if ((this.mob.tickCount - this.mob.lastHurtByMobTimestamp) > 100) {
+ this.mob.setLastHurtByMob((EntityLiving) null);
+ return false;
+ }
+ // CraftBukkit end
return !this.mob.getNavigation().isDone();
}
@@ -89,6 +99,6 @@
return !iblockaccess.getBlockState(blockposition).getCollisionShape(iblockaccess, blockposition).isEmpty() ? null : (BlockPosition) BlockPosition.findClosestMatch(entity.blockPosition(), i, 1, (blockposition1) -> {
return iblockaccess.getFluidState(blockposition1).is(TagsFluid.WATER);
- }).orElse((Object) null);
+ }).orElse(null); // CraftBukkit - decompile error
}
}

View File

@ -6,21 +6,18 @@
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.entity.EntityInteractEvent;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
private final Block blockToRemove;
@@ -96,6 +101,14 @@
@@ -96,6 +101,11 @@
}
if (this.ticksSinceReachedGoal > 60) {
+ // CraftBukkit start - Step on eggs
+ EntityInteractEvent event = new EntityInteractEvent(this.removerMob.getBukkitEntity(), CraftBlock.at(world, blockposition1));
+ world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) event);
+
+ if (event.isCancelled()) {
+ if (!CraftEventFactory.callEntityInteractEvent(this.removerMob, CraftBlock.at(world, blockposition1))) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.java
@@ -22,7 +22,7 @@
@@ -21,7 +21,7 @@
@Override
public boolean canUse() {
if (!this.mob.isTame()) {
- return false;
+ return this.mob.isOrderedToSit() && this.mob.getTarget() == null; // CraftBukkit - Allow sitting for wild animals
- if (!this.mob.isTame()) {
+ if (false && !this.mob.isTame()) { // CraftBukkit - Allow sitting for wild animals
return false;
} else if (this.mob.isInWaterOrBubble()) {
return false;
} else if (!this.mob.onGround()) {

View File

@ -1,12 +1,23 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java
@@ -62,7 +62,8 @@
@@ -7,6 +7,11 @@
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class PathfinderGoalTame extends PathfinderGoal {
private final EntityHorseAbstract horse;
@@ -62,7 +67,7 @@
int i = this.horse.getTemper();
int j = this.horse.getMaxTemper();
- if (j > 0 && this.horse.getRandom().nextInt(j) < i) {
+ // CraftBukkit - fire EntityTameEvent
+ if (j > 0 && this.horse.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) {
+ if (j > 0 && this.horse.getRandom().nextInt(j) < i && !CraftEventFactory.callEntityTameEvent(this.horse, ((CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { // CraftBukkit - fire EntityTameEvent
this.horse.tameWithName((EntityHuman) entity);
return;
}

View File

@ -1,15 +1,17 @@
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.java
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.java
@@ -11,6 +11,8 @@
@@ -11,6 +11,10 @@
import net.minecraft.world.level.pathfinder.PathPoint;
import net.minecraft.world.scores.ScoreboardTeamBase;
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
+// CraftBukkit start
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public abstract class PathfinderGoalTarget extends PathfinderGoal {
private static final int EMPTY_REACH_CACHE = 0;
@@ -69,7 +71,7 @@
@@ -69,7 +73,7 @@
}
}
@ -18,7 +20,7 @@
return true;
}
}
@@ -89,7 +91,7 @@
@@ -89,7 +93,7 @@
@Override
public void stop() {

View File

@ -1,67 +1,47 @@
--- a/net/minecraft/world/entity/ambient/EntityBat.java
+++ b/net/minecraft/world/entity/ambient/EntityBat.java
@@ -28,6 +28,8 @@
@@ -28,6 +28,10 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class EntityBat extends EntityAmbient {
public static final float FLAP_DEGREES_PER_TICK = 74.48451F;
@@ -140,16 +142,24 @@
@@ -139,13 +143,13 @@
this.yHeadRot = (float) this.random.nextInt(360);
}
if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
+ this.setResting(false);
+ if (!flag) {
+ this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
+ }
+ }
+ // CraftBukkit End
+ }
+ } else {
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
- if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
+ if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
if (!flag) {
this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
}
}
- } else {
- this.setResting(false);
- if (!flag) {
- this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
- }
+ // CraftBukkit End - Call BatToggleSleepEvent
}
} else {
if (this.targetPosition != null && (!this.level().isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level().getMinBuildHeight())) {
@@ -173,7 +183,11 @@
+ } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
if (!flag) {
this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
@@ -172,7 +176,7 @@
this.zza = 0.5F;
this.setYRot(this.getYRot() + f1);
if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1)) {
- this.setResting(true);
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) {
+ this.setResting(true);
+ }
+ // CraftBukkit End
- if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1)) {
+ if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(true);
}
}
@@ -198,7 +212,11 @@
@@ -197,7 +201,7 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {
if (!this.level().isClientSide && this.isResting()) {
- this.setResting(false);
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
+ this.setResting(false);
+ }
+ // CraftBukkit End - Call BatToggleSleepEvent
- if (!this.level().isClientSide && this.isResting()) {
+ if (!this.level().isClientSide && this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
}
return super.hurt(damagesource, f);

View File

@ -5,8 +5,8 @@
import net.minecraft.world.level.pathfinder.PathType;
+// CraftBukkit start
+import net.minecraft.world.entity.EntityTameableAnimal;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityBreedEvent;
+import org.bukkit.event.entity.EntityEnterLoveModeEvent;
+// CraftBukkit end
+
@ -20,25 +20,22 @@
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
super(entitytypes, world);
@@ -72,6 +79,9 @@
}
+ /* CraftBukkit start
+ // Function disabled as it has no special function anymore after
+ // setSitting is disabled.
@Override
public boolean hurt(DamageSource damagesource, float f) {
@@ -77,8 +84,13 @@
if (this.isInvulnerableTo(damagesource)) {
@@ -81,6 +91,7 @@
return super.hurt(damagesource, f);
return false;
} else {
+ // CraftBukkit start
+ boolean result = super.hurt(damagesource, f);
+ if (result) {
this.inLove = 0;
- return super.hurt(damagesource, f);
+ }
+ return result;
+ // CraftBukkit end
}
}
+ // CraftBukkit end */
@Override
public float getWalkTargetValue(BlockPosition blockposition, IWorldReader iworldreader) {
@@ -175,10 +186,17 @@
@@ -175,10 +187,17 @@
}
public void setInLove(@Nullable EntityHuman entityhuman) {
@ -57,7 +54,7 @@
this.level().broadcastEntityEvent(this, (byte) 18);
}
@@ -220,12 +238,29 @@
@@ -220,12 +239,29 @@
if (entityageable != null) {
entityageable.setBaby(true);
entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
@ -68,7 +65,7 @@
+ return Optional.ofNullable(entityanimal.getLoveCause());
+ }).orElse(null);
+ int experience = this.getRandom().nextInt(7) + 1;
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, breeder, this.breedItem, experience);
+ EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, breeder, this.breedItem, experience);
+ if (entityBreedEvent.isCancelled()) {
+ return;
+ }
@ -89,7 +86,7 @@
Optional.ofNullable(this.getLoveCause()).or(() -> {
return Optional.ofNullable(entityanimal.getLoveCause());
}).ifPresent((entityplayer) -> {
@@ -238,7 +273,11 @@
@@ -238,7 +274,11 @@
entityanimal.resetLove();
worldserver.broadcastEntityEvent(this, (byte) 18);
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {

View File

@ -1,51 +1,63 @@
--- a/net/minecraft/world/entity/animal/EntityBee.java
+++ b/net/minecraft/world/entity/animal/EntityBee.java
@@ -242,7 +242,7 @@
@@ -90,6 +90,12 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityPotionEffectEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityBird {
public static final float FLAP_DEGREES_PER_TICK = 120.32113F;
@@ -242,7 +248,7 @@
}
if (b0 > 0) {
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this);
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}
@@ -640,11 +640,15 @@
@@ -640,11 +646,14 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {
- if (!this.level().isClientSide) {
+ // CraftBukkit start
+ // CraftBukkit start - Only stop pollinating if entity was damaged
+ boolean result = super.hurt(damagesource, f);
+
+ if (result && !this.level().isClientSide) {
+ // CraftBukkit end
this.beePollinateGoal.stopPollinating();
}
- return super.hurt(damagesource, f);
+ return result;
+ // CraftBukkit end
+ return result; // CraftBukkit
}
}
@@ -1216,7 +1220,7 @@
@@ -1216,7 +1225,7 @@
}
}
- if (iblockdata1 != null) {
+ if (iblockdata1 != null&& !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata1).isCancelled()) { // CraftBukkit
+ if (iblockdata1 != null && CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata1)) { // CraftBukkit
EntityBee.this.level().levelEvent(2005, blockposition, 0);
EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1);
EntityBee.this.incrementNumCropsGrownSincePollination();
@@ -1289,7 +1293,7 @@
@@ -1289,7 +1298,7 @@
@Override
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) {
- entityinsentient.setTarget(entityliving);
+ entityinsentient.setTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
+ entityinsentient.setTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
}
}
@@ -1298,7 +1302,7 @@
@@ -1298,7 +1307,7 @@
private static class c extends PathfinderGoalNearestAttackableTarget<EntityHuman> {
c(EntityBee entitybee) {

View File

@ -1,23 +1,24 @@
--- a/net/minecraft/world/entity/animal/EntityCow.java
+++ b/net/minecraft/world/entity/animal/EntityCow.java
@@ -31,6 +31,11 @@
@@ -31,6 +31,12 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.player.PlayerBucketFillEvent;
+// CraftBukkit end
+
public class EntityCow extends EntityAnimal {
public EntityCow(EntityTypes<? extends EntityCow> entitytypes, World world) {
@@ -83,8 +88,16 @@
@@ -83,8 +89,16 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
+ // CraftBukkit start - Got milk?
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
+
+ if (event.isCancelled()) {
+ return EnumInteractionResult.PASS;

View File

@ -1,7 +1,14 @@
--- a/net/minecraft/world/entity/animal/EntityDolphin.java
+++ b/net/minecraft/world/entity/animal/EntityDolphin.java
@@ -63,6 +63,12 @@
@@ -61,8 +61,19 @@
import net.minecraft.world.level.pathfinder.PathMode;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityPotionEffectEvent;
+// CraftBukkit end
+
public class EntityDolphin extends EntityWaterAnimal {
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
@ -13,7 +20,7 @@
private static final DataWatcherObject<BlockPosition> TREASURE_POS = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BLOCK_POS);
private static final DataWatcherObject<Boolean> GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN);
private static final DataWatcherObject<Integer> MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT);
@@ -190,7 +196,7 @@
@@ -190,7 +201,7 @@
@Override
public int getMaxAirSupply() {
@ -22,20 +29,20 @@
}
@Override
@@ -231,6 +237,12 @@
@@ -231,6 +242,12 @@
ItemStack itemstack = entityitem.getItem();
if (this.canHoldItem(itemstack)) {
+ // CraftBukkit start - call EntityPickupItemEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, false).isCancelled()) {
+ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, false).isCancelled()) {
+ return;
+ }
+ itemstack = entityitem.getItem(); // update ItemStack from event
+ // CraftBukkit end
+ itemstack = entityitem.getItem(); // CraftBukkit- update ItemStack from event
+ // CraftBukkit start
this.onItemPickup(entityitem);
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack);
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
@@ -389,7 +401,7 @@
@@ -389,7 +406,7 @@
@Override
public boolean canUse() {
@ -44,21 +51,21 @@
}
@Override
@@ -489,7 +501,7 @@
@@ -489,7 +506,7 @@
@Override
public void start() {
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
}
@Override
@@ -508,7 +520,7 @@
@@ -508,7 +525,7 @@
}
if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) {
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
}
}

View File

@ -51,7 +51,7 @@
iblockdata.setValue(BlockSweetBerryBush.AGE, 1);
+ // CraftBukkit start - call EntityChangeBlockEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.setValue(BlockSweetBerryBush.AGE, 1)).isCancelled()) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.setValue(BlockSweetBerryBush.AGE, 1))) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -1,16 +1,15 @@
--- a/net/minecraft/world/entity/animal/EntityOcelot.java
+++ b/net/minecraft/world/entity/animal/EntityOcelot.java
@@ -177,7 +177,8 @@
@@ -177,7 +177,7 @@
if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) {
this.usePlayerItem(entityhuman, enumhand, itemstack);
if (!this.level().isClientSide) {
- if (this.random.nextInt(3) == 0) {
+ // CraftBukkit - added event call and isCancelled check
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit - added event call and isCancelled check
this.setTrusting(true);
this.spawnTrustingParticles(true);
this.level().broadcastEntityEvent(this, (byte) 41);
@@ -308,10 +309,10 @@
@@ -308,10 +308,10 @@
private final EntityOcelot ocelot;
public a(EntityOcelot entityocelot, Class<T> oclass, float f, double d0, double d1) {

View File

@ -1,24 +1,27 @@
--- a/net/minecraft/world/entity/animal/EntityPanda.java
+++ b/net/minecraft/world/entity/animal/EntityPanda.java
@@ -65,6 +65,8 @@
@@ -65,6 +65,11 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
+// CraftBukkit start;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public class EntityPanda extends EntityAnimal {
private static final DataWatcherObject<Integer> UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT);
@@ -532,7 +534,7 @@
@@ -532,7 +537,7 @@
@Override
protected void pickUpItem(EntityItem entityitem) {
- if (this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem)) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem))).isCancelled()) { // CraftBukkit
+ if (!CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem))).isCancelled()) { // CraftBukkit
this.onItemPickup(entityitem);
ItemStack itemstack = entityitem.getItem();
@@ -863,10 +865,10 @@
@@ -863,10 +868,10 @@
private final EntityPanda panda;
public c(EntityPanda entitypanda, Class<T> oclass, float f, double d0, double d1) {
@ -32,7 +35,7 @@
this.panda = entitypanda;
}
@@ -1105,7 +1107,7 @@
@@ -1105,7 +1110,7 @@
@Override
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityPanda && entityinsentient.isAggressive()) {

View File

@ -27,12 +27,20 @@
}
@Override
@@ -398,7 +398,7 @@
@@ -397,11 +397,14 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {
if (!this.level().isClientSide) {
- this.setOrderedToSit(false);
+ // this.setOrderedToSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float)
- if (!this.level().isClientSide) {
+ // CraftBukkit start
+ boolean result = super.hurt(damagesource, f);
+ if (!this.level().isClientSide && result) {
+ // CraftBukkit end
this.setOrderedToSit(false);
}
return super.hurt(damagesource, f);
- return super.hurt(damagesource, f);
+ return result; // CraftBukkit
}
}

View File

@ -1,26 +1,30 @@
--- a/net/minecraft/world/entity/animal/EntityRabbit.java
+++ b/net/minecraft/world/entity/animal/EntityRabbit.java
@@ -88,8 +88,14 @@
@@ -66,6 +66,10 @@
import net.minecraft.world.level.pathfinder.PathEntity;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class EntityRabbit extends EntityAnimal implements VariantHolder<EntityRabbit.Variant> {
public static final double STROLL_SPEED_MOD = 0.6D;
@@ -88,7 +92,6 @@
super(entitytypes, world);
this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this);
this.moveControl = new EntityRabbit.ControllerMoveRabbit(this);
+ this.initializePathFinderGoals(); // CraftBukkit - moved code
+ }
+
+ // CraftBukkit start - code from constructor
+ public void initializePathFinderGoals(){
this.setSpeedModifier(0.0D);
- this.setSpeedModifier(0.0D);
}
+ // CraftBukkit end
@Override
public void registerGoals() {
@@ -576,9 +582,23 @@
@@ -576,9 +579,19 @@
int i = (Integer) iblockdata.getValue(BlockCarrots.AGE);
if (i == 0) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, Blocks.AIR.defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end
@ -28,11 +32,7 @@
world.destroyBlock(blockposition, true, this.rabbit);
} else {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(
+ this.rabbit,
+ blockposition,
+ iblockdata.setValue(BlockCarrots.AGE, i - 1)
+ ).isCancelled()) {
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, iblockdata.setValue(BlockCarrots.AGE, i - 1))) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -26,7 +26,7 @@
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
- this.level().setBlockAndUpdate(blockposition, iblockdata);
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockposition, iblockdata, this)) {
+ if (!CraftEventFactory.handleBlockFormEvent(this.level(), blockposition, iblockdata, this)) {
+ continue;
+ }
+ // CraftBukkit end

View File

@ -1,7 +0,0 @@
--- a/net/minecraft/world/entity/animal/EntitySquid.java
+++ b/net/minecraft/world/entity/animal/EntitySquid.java
@@ -1,3 +1,4 @@
+// mc-dev import
package net.minecraft.world.entity.animal;
import net.minecraft.core.BlockPosition;

View File

@ -20,20 +20,18 @@
}
private static class e extends ControllerMove {
@@ -487,12 +491,16 @@
@@ -487,12 +491,14 @@
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
World world = this.turtle.level();
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1)).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1))) { // CraftBukkit
world.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
BlockPosition blockposition1 = this.blockPos.above();
IBlockData iblockdata = (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1);
world.setBlock(blockposition1, iblockdata, 3);
world.gameEvent(GameEvent.BLOCK_PLACE, blockposition1, GameEvent.a.of(this.turtle, iblockdata));
+ }
+ // CraftBukkit end
+ } // CraftBukkit
this.turtle.setHasEgg(false);
this.turtle.setLayingEgg(false);
this.turtle.setInLoveTime(600);

View File

@ -1,52 +1,43 @@
--- a/net/minecraft/world/entity/animal/EntityWolf.java
+++ b/net/minecraft/world/entity/animal/EntityWolf.java
@@ -69,6 +69,11 @@
@@ -69,6 +69,12 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRegainHealthEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
+// CraftBukkit end
+
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable {
private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN);
@@ -126,6 +131,24 @@
return EntityInsentient.createMobAttributes().add(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).add(GenericAttributes.MAX_HEALTH, 8.0D).add(GenericAttributes.ATTACK_DAMAGE, 2.0D);
}
+ // CraftBukkit - add overriden version
+ @Override
+ public boolean setTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fire) {
+ if (!super.setTarget(entityliving, reason, fire)) {
+ return false;
+ }
+ entityliving = getTarget();
+ /* // PAIL
+ if (entityliving == null) {
+ this.setAngry(false);
+ } else if (!this.isTamed()) {
+ this.setAngry(true);
+ }
+ */
+ return true;
+ }
+ // CraftBukkit end
+
@Override
protected void defineSynchedData() {
super.defineSynchedData();
@@ -298,7 +321,7 @@
@@ -297,15 +303,19 @@
} else {
Entity entity = damagesource.getEntity();
if (!this.level().isClientSide) {
- if (!this.level().isClientSide) {
- this.setOrderedToSit(false);
+ // this.setOrderedToSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float)
}
- }
+ // CraftBukkit - move diff down
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
@@ -325,7 +348,7 @@
f = (f + 1.0F) / 2.0F;
}
- return super.hurt(damagesource, f);
+ // CraftBukkit start
+ boolean result = super.hurt(damagesource, f);
+ if (!this.level().isClientSide && result) {
+ this.setOrderedToSit(false);
+ }
+ return result;
+ // CraftBukkit end
}
}
@@ -325,7 +335,7 @@
super.setTame(flag);
if (flag) {
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(20.0D);
@ -55,25 +46,25 @@
} else {
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D);
}
@@ -348,7 +371,7 @@
@@ -348,7 +358,7 @@
itemstack.shrink(1);
}
- this.heal((float) item.getFoodProperties().getNutrition());
+ this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
+ this.heal((float) item.getFoodProperties().getNutrition(), EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
return EnumInteractionResult.SUCCESS;
} else {
if (item instanceof ItemDye) {
@@ -376,7 +399,7 @@
@@ -376,7 +386,7 @@
this.setOrderedToSit(!this.isOrderedToSit());
this.jumping = false;
this.navigation.stop();
- this.setTarget((EntityLiving) null);
+ this.setTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
+ this.setTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
return EnumInteractionResult.SUCCESS;
} else {
return enuminteractionresult;
@@ -387,7 +410,8 @@
@@ -387,7 +397,8 @@
itemstack.shrink(1);
}

View File

@ -1,18 +1,19 @@
--- a/net/minecraft/world/entity/animal/goat/Goat.java
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
@@ -54,6 +54,11 @@
@@ -54,6 +54,12 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.player.PlayerBucketFillEvent;
+// CraftBukkit end
+
public class Goat extends EntityAnimal {
public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.scalable(0.9F, 1.3F).scale(0.7F);
@@ -181,7 +186,7 @@
@@ -181,7 +187,7 @@
@Override
public BehaviorController<Goat> getBrain() {
@ -21,12 +22,12 @@
}
@Override
@@ -219,8 +224,15 @@
@@ -219,8 +225,15 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
+ // CraftBukkit start - Got milk?
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
+
+ if (event.isCancelled()) {
+ return EnumInteractionResult.PASS;

View File

@ -1,15 +1,19 @@
--- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
+++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
@@ -78,6 +78,8 @@
@@ -78,6 +78,12 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.AbstractHorse;
+import org.bukkit.event.entity.EntityRegainHealthEvent;
+// CraftBukkit end
+
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, OwnableEntity, IJumpable, ISaddleable {
public static final int EQUIPMENT_SLOT_OFFSET = 400;
@@ -139,6 +141,7 @@
@@ -139,6 +145,7 @@
protected int gallopSoundCounter;
@Nullable
private UUID owner;
@ -17,16 +21,16 @@
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -334,7 +337,7 @@
@@ -334,7 +341,7 @@
public void createInventory() {
InventorySubcontainer inventorysubcontainer = this.inventory;
- this.inventory = new InventorySubcontainer(this.getInventorySize());
+ this.inventory = new InventorySubcontainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit
+ this.inventory = new InventorySubcontainer(this.getInventorySize(), (AbstractHorse) this.getBukkitEntity()); // CraftBukkit
if (inventorysubcontainer != null) {
inventorysubcontainer.removeListener(this);
int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize());
@@ -442,7 +445,7 @@
@@ -442,7 +449,7 @@
}
public int getMaxTemper() {
@ -35,25 +39,25 @@
}
@Override
@@ -513,7 +516,7 @@
@@ -513,7 +520,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f);
+ this.heal(f, RegainReason.EATING); // CraftBukkit
+ this.heal(f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
flag = true;
}
@@ -590,7 +593,7 @@
@@ -590,7 +597,7 @@
super.aiStep();
if (!this.level().isClientSide && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
}
if (this.canEatGrass()) {
@@ -857,6 +860,7 @@
@@ -857,6 +864,7 @@
if (this.getOwnerUUID() != null) {
nbttagcompound.putUUID("Owner", this.getOwnerUUID());
}
@ -61,7 +65,7 @@
if (!this.inventory.getItem(0).isEmpty()) {
nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(new NBTTagCompound()));
@@ -884,6 +888,11 @@
@@ -884,6 +892,11 @@
if (uuid != null) {
this.setOwnerUUID(uuid);
}
@ -73,7 +77,7 @@
if (nbttagcompound.contains("SaddleItem", 10)) {
ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("SaddleItem"));
@@ -986,6 +995,18 @@
@@ -986,6 +999,17 @@
@Override
public void handleStartJump(int i) {
@ -84,8 +88,7 @@
+ } else {
+ power = 0.4F + 0.4F * (float) i / 90.0F;
+ }
+ org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power);
+ if (event.isCancelled()) {
+ if (!CraftEventFactory.callHorseJumpEvent(this, power)) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/EntityLlama.java
+++ b/net/minecraft/world/entity/animal/horse/EntityLlama.java
@@ -82,6 +82,12 @@
@@ -82,6 +82,11 @@
return false;
}
@ -9,7 +9,6 @@
+ this.setStrength(i);
+ }
+ // CraftBukkit end
+
private void setStrength(int i) {
this.entityData.set(EntityLlama.DATA_STRENGTH_ID, Math.max(1, Math.min(5, i)));
}

View File

@ -25,7 +25,7 @@
}
}
@@ -95,11 +104,24 @@
@@ -95,11 +104,23 @@
return false;
} else {
if (!this.isRemoved() && !this.level().isClientSide) {
@ -40,8 +40,7 @@
- this.level().explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), 6.0F, false, World.a.BLOCK);
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent(this, 6.0F, false);
+ if (event.isCancelled()) {
+ this.unsetRemoved();
+ return false;

View File

@ -75,7 +75,7 @@
if (canDestroy(iblockdata)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState())) {
+ continue;
+ }
+ // CraftBukkit end

View File

@ -1,15 +1,17 @@
--- a/net/minecraft/world/entity/item/EntityFallingBlock.java
+++ b/net/minecraft/world/entity/item/EntityFallingBlock.java
@@ -49,6 +49,8 @@
@@ -49,6 +49,10 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+// CraftBukkit start;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class EntityFallingBlock extends Entity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -83,10 +85,17 @@
@@ -83,10 +87,17 @@
}
public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) {
@ -20,7 +22,7 @@
+ public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end
EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, iblockdata.hasProperty(BlockProperties.WATERLOGGED) ? (IBlockData) iblockdata.setValue(BlockProperties.WATERLOGGED, false) : iblockdata);
+ if (CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock()).isCancelled()) return entityfallingblock; // CraftBukkit
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock())) return entityfallingblock; // CraftBukkit
world.setBlock(blockposition, iblockdata.getFluidState().createLegacyBlock(), 3);
- world.addFreshEntity(entityfallingblock);
@ -28,12 +30,12 @@
return entityfallingblock;
}
@@ -169,6 +178,12 @@
@@ -169,6 +180,12 @@
this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true);
}
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState).isCancelled()) {
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState)) {
+ this.discard(); // SPIGOT-6586 called before the event in previous versions
+ return;
+ }
@ -41,7 +43,7 @@
if (this.level().setBlock(blockposition, this.blockState, 3)) {
((WorldServer) this.level()).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level().getBlockState(blockposition)));
this.discard();
@@ -255,7 +270,9 @@
@@ -255,7 +272,9 @@
float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax);
this.level().getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {

View File

@ -1,11 +1,13 @@
--- a/net/minecraft/world/entity/item/EntityItem.java
+++ b/net/minecraft/world/entity/item/EntityItem.java
@@ -31,6 +31,12 @@
@@ -31,6 +31,14 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Player;
+import org.bukkit.event.entity.EntityPickupItemEvent;
+import org.bukkit.event.player.PlayerPickupItemEvent;
+// CraftBukkit end
@ -13,7 +15,7 @@
public class EntityItem extends Entity implements TraceableEntity {
private static final DataWatcherObject<ItemStack> DATA_ITEM = DataWatcher.defineId(EntityItem.class, DataWatcherRegistry.ITEM_STACK);
@@ -45,6 +51,7 @@
@@ -45,6 +53,7 @@
@Nullable
public UUID target;
public final float bobOffs;
@ -21,7 +23,7 @@
public EntityItem(EntityTypes<? extends EntityItem> entitytypes, World world) {
super(entitytypes, world);
@@ -110,9 +117,12 @@
@@ -110,9 +119,12 @@
this.discard();
} else {
super.tick();
@ -37,7 +39,7 @@
this.xo = this.getX();
this.yo = this.getY();
@@ -162,9 +172,11 @@
@@ -162,9 +174,11 @@
this.mergeWithNeighbours();
}
@ -49,12 +51,12 @@
this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing();
if (!this.level().isClientSide) {
@@ -176,6 +188,12 @@
@@ -176,6 +190,12 @@
}
if (!this.level().isClientSide && this.age >= 6000) {
+ // CraftBukkit start - fire ItemDespawnEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
+ if (CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
+ this.age = 0;
+ return;
+ }
@ -62,7 +64,7 @@
this.discard();
}
@@ -255,10 +273,11 @@
@@ -255,10 +275,15 @@
private static void merge(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) {
ItemStack itemstack2 = merge(itemstack, itemstack1, 64);
@ -71,23 +73,27 @@
}
private static void merge(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(entityitem1, entityitem).isCancelled()) return; // CraftBukkit
+ // CraftBukkit start
+ if (!CraftEventFactory.callItemMergeEvent(entityitem1, entityitem)) {
+ return;
+ }
+ // CraftBukkit end
merge(entityitem, itemstack, itemstack1);
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay);
entityitem.age = Math.min(entityitem.age, entityitem1.age);
@@ -284,6 +303,11 @@
@@ -284,6 +309,11 @@
} else if (this.level().isClientSide) {
return true;
} else {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ return false;
+ }
+ // CraftBukkit end
this.markHurt();
this.health = (int) ((float) this.health - f);
this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity());
@@ -347,6 +371,46 @@
@@ -347,6 +377,46 @@
Item item = itemstack.getItem();
int i = itemstack.getCount();
@ -98,7 +104,7 @@
+ if (this.pickupDelay <= 0 && canHold > 0) {
+ itemstack.setCount(canHold);
+ // Call legacy event
+ PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems());
+ this.level().getCraftServer().getPluginManager().callEvent(playerEvent);
+ if (playerEvent.isCancelled()) {
@ -107,7 +113,7 @@
+ }
+
+ // Call newer event afterwards
+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ entityEvent.setCancelled(!entityEvent.getEntity().getCanPickupItems());
+ this.level().getCraftServer().getPluginManager().callEvent(entityEvent);
+ if (entityEvent.isCancelled()) {
@ -134,13 +140,11 @@
if (this.pickupDelay == 0 && (this.target == null || this.target.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) {
entityhuman.take(this, i);
if (itemstack.isEmpty()) {
@@ -390,7 +454,9 @@
@@ -390,6 +460,7 @@
}
public void setItem(ItemStack itemstack) {
+ com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit
this.getEntityData().set(EntityItem.DATA_ITEM, itemstack);
+ this.getEntityData().markDirty(EntityItem.DATA_ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty
}
@Override

View File

@ -1,10 +1,13 @@
--- a/net/minecraft/world/entity/item/EntityTNTPrimed.java
+++ b/net/minecraft/world/entity/item/EntityTNTPrimed.java
@@ -15,12 +15,16 @@
@@ -15,12 +15,19 @@
import net.minecraft.world.entity.TraceableEntity;
import net.minecraft.world.level.World;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+// CraftBukkit start;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityTNTPrimed extends Entity implements TraceableEntity {
@ -17,7 +20,7 @@
public EntityTNTPrimed(EntityTypes<? extends EntityTNTPrimed> entitytypes, World world) {
super(entitytypes, world);
@@ -71,10 +75,13 @@
@@ -71,10 +78,13 @@
this.setFuse(i);
if (i <= 0) {
@ -32,18 +35,16 @@
} else {
this.updateInWaterStateAndDoFluidPushing();
if (this.level().isClientSide) {
@@ -85,9 +92,16 @@
@@ -85,9 +95,14 @@
}
private void explode() {
- float f = 4.0F;
+ // CraftBukkit start
+ // float f = 4.0F;
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive)this.getBukkitEntity());
- this.level().explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, World.a.TNT);
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.level().explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT);
+ }

View File

@ -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));
}

View File

@ -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
}
}

View File

@ -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

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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

View File

@ -16,28 +16,28 @@
public class EntityEgg extends EntityProjectileThrowable {
public EntityEgg(EntityTypes<? extends EntityEgg> entitytypes, World world) {
@@ -47,22 +56,42 @@
@@ -47,20 +56,47 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {
- if (this.random.nextInt(8) == 0) {
+ boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit
+ // CraftBukkit start
+ boolean hatching = this.random.nextInt(8) == 0;
+ if (true) {
+ // CraftBukkit end
byte b0 = 1;
if (this.random.nextInt(32) == 0) {
b0 = 4;
}
- for (int i = 0; i < b0; ++i) {
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level());
+ // CraftBukkit start
+ if (!hatching) {
+ b0 = 0;
+ }
+ EntityType hatchingType = EntityType.CHICKEN;
+
+ Entity shooter = this.getOwner();
+ if (!hatching) {
+ b0 = 0;
+ }
+ if (shooter instanceof EntityPlayer) {
+ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
@ -45,24 +45,27 @@
+ b0 = event.getNumHatches();
+ hatching = event.isHatching();
+ hatchingType = event.getHatchingType();
+ // If hatching is set to false, ensure child count is 0
+ if (!hatching) {
+ b0 = 0;
+ }
+ }
+ // CraftBukkit end
+
for (int i = 0; i < b0; ++i) {
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level());
+ Entity entitychicken = this.level().getWorld().createEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit
- if (entitychicken != null) {
if (entitychicken != null) {
- entitychicken.setAge(-24000);
- entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
- this.level().addFreshEntity(entitychicken);
+ if (hatching) {
+ for (int i = 0; i < b0; ++i) {
+ Entity entity = this.level().getWorld().createEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass());
+ if (entity != null) {
+ if (entity.getBukkitEntity() instanceof Ageable) {
+ ((Ageable) entity.getBukkitEntity()).setBaby();
+ }
+ this.level().getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
+ // CraftBukkit start
+ if (entitychicken.getBukkitEntity() instanceof Ageable) {
+ ((Ageable) entitychicken.getBukkitEntity()).setBaby();
+ }
+ this.level().addFreshEntity(entitychicken, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
+ // CraftBukkit end
}
}
+ // CraftBukkit end
}
this.level().broadcastEntityEvent(this, (byte) 3);

View File

@ -124,14 +124,14 @@
if (iblockdata.is(TagsBlock.FIRE)) {
- this.level().removeBlock(blockposition, false);
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState())) {
+ this.level().removeBlock(blockposition, false);
+ }
+ // CraftBukkit end
} else if (AbstractCandleBlock.isLit(iblockdata)) {
- AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level(), blockposition);
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(AbstractCandleBlock.LIT, false)).isCancelled()) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(AbstractCandleBlock.LIT, false))) {
+ AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level(), blockposition);
+ }
+ // CraftBukkit end
@ -140,7 +140,7 @@
- BlockCampfire.dowse(this.getOwner(), this.level(), blockposition, iblockdata);
- this.level().setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false));
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(BlockCampfire.LIT, false)).isCancelled()) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(BlockCampfire.LIT, false))) {
+ this.level().levelEvent((EntityHuman) null, 1009, blockposition, 0);
+ BlockCampfire.dowse(this.getOwner(), this.level(), blockposition, iblockdata);
+ this.level().setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false));

View File

@ -1,32 +1,24 @@
--- a/net/minecraft/world/entity/projectile/EntityTippedArrow.java
+++ b/net/minecraft/world/entity/projectile/EntityTippedArrow.java
@@ -142,6 +142,25 @@
}
@@ -28,7 +28,7 @@
private static final int NO_EFFECT_COLOR = -1;
private static final DataWatcherObject<Integer> ID_EFFECT_COLOR = DataWatcher.defineId(EntityTippedArrow.class, DataWatcherRegistry.INT);
private static final byte EVENT_POTION_PUFF = 0;
- private PotionRegistry potion;
+ public PotionRegistry potion; // CraftBukkit private -> public
public final Set<MobEffect> effects;
private boolean fixedColor;
@@ -86,7 +86,7 @@
return nbttagcompound != null && nbttagcompound.contains("CustomPotionColor", 99) ? nbttagcompound.getInt("CustomPotionColor") : -1;
}
+ // CraftBukkit start accessor methods
+ public void refreshEffects() {
+ this.getEntityData().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, (Collection) this.effects)));
+ }
+
+ public String getPotionType() {
+ return BuiltInRegistries.POTION.getKey(this.potion).toString();
+ }
+
+ public void setPotionType(String string) {
+ this.potion = BuiltInRegistries.POTION.get(new net.minecraft.resources.MinecraftKey(string));
+ this.getEntityData().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, (Collection) this.effects)));
+ }
+
+ public boolean isTipped() {
+ return !(this.effects.isEmpty() && this.potion == Potions.EMPTY);
+ }
+ // CraftBukkit end
+
public int getColor() {
return (Integer) this.entityData.get(EntityTippedArrow.ID_EFFECT_COLOR);
}
@@ -212,7 +231,7 @@
- private void updateColor() {
+ public void updateColor() { // CraftBukkit private -> public
this.fixedColor = false;
if (this.potion == Potions.EMPTY && this.effects.isEmpty()) {
this.entityData.set(EntityTippedArrow.ID_EFFECT_COLOR, -1);
@@ -212,7 +212,7 @@
mobeffect = (MobEffect) iterator.next();
entityliving.addEffect(new MobEffect(mobeffect.getEffect(), Math.max(mobeffect.mapDuration((i) -> {
return i / 8;
@ -35,7 +27,7 @@
}
if (!this.effects.isEmpty()) {
@@ -220,7 +239,7 @@
@@ -220,7 +220,7 @@
while (iterator.hasNext()) {
mobeffect = (MobEffect) iterator.next();

View File

@ -1,15 +1,17 @@
--- a/net/minecraft/world/entity/projectile/EntityWitherSkull.java
+++ b/net/minecraft/world/entity/projectile/EntityWitherSkull.java
@@ -20,6 +20,8 @@
@@ -20,6 +20,10 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+// CraftBukkit start
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityWitherSkull extends EntityFireball {
private static final DataWatcherObject<Boolean> DATA_DANGEROUS = DataWatcher.defineId(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN);
@@ -63,7 +65,7 @@
@@ -63,7 +67,7 @@
if (entity.isAlive()) {
this.doEnchantDamageEffects(entityliving, entity);
} else {
@ -18,7 +20,7 @@
}
}
} else {
@@ -81,7 +83,7 @@
@@ -81,7 +85,7 @@
}
if (b0 > 0) {
@ -27,7 +29,7 @@
}
}
@@ -92,7 +94,15 @@
@@ -92,7 +96,15 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {

View File

@ -83,16 +83,7 @@
public static ItemStack of(NBTTagCompound nbttagcompound) {
try {
return new ItemStack(nbttagcompound);
@@ -229,7 +284,7 @@
return this.getItem().builtInRegistryHolder().tags();
}
- public EnumInteractionResult useOn(ItemActionContext itemactioncontext) {
+ public EnumInteractionResult useOn(ItemActionContext itemactioncontext, EnumHand enumhand) { // CraftBukkit - add hand
EntityHuman entityhuman = itemactioncontext.getPlayer();
BlockPosition blockposition = itemactioncontext.getClickedPos();
ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getLevel(), blockposition, false);
@@ -237,12 +292,186 @@
@@ -237,12 +292,187 @@
if (entityhuman != null && !entityhuman.getAbilities().mayBuild && !this.hasAdventureModePlaceTagForBlock(itemactioncontext.getLevel().registryAccess().registryOrThrow(Registries.BLOCK), shapedetectorblock)) {
return EnumInteractionResult.PASS;
} else {
@ -152,6 +143,7 @@
if (entityhuman != null && enuminteractionresult.shouldAwardStats()) {
- entityhuman.awardStat(StatisticList.ITEM_USED.get(item));
+ EnumHand enumhand = itemactioncontext.getHand();
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
+ List<BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
+ world.capturedBlockStates.clear();
@ -280,7 +272,7 @@
return enuminteractionresult;
}
@@ -323,6 +552,21 @@
@@ -323,6 +553,21 @@
}
i -= k;
@ -302,7 +294,7 @@
if (i <= 0) {
return false;
}
@@ -344,6 +588,11 @@
@@ -344,6 +589,11 @@
if (this.hurt(i, t0.getRandom(), t0 instanceof EntityPlayer ? (EntityPlayer) t0 : null)) {
consumer.accept(t0);
Item item = this.getItem();
@ -314,7 +306,7 @@
this.shrink(1);
if (t0 instanceof EntityHuman) {
@@ -492,6 +741,17 @@
@@ -492,6 +742,17 @@
return this.tag;
}
@ -332,7 +324,7 @@
public NBTTagCompound getOrCreateTag() {
if (this.tag == null) {
this.setTag(new NBTTagCompound());
@@ -862,6 +1122,12 @@
@@ -862,6 +1123,12 @@
}
public void setRepairCost(int i) {
@ -345,7 +337,7 @@
this.getOrCreateTag().putInt("RepairCost", i);
}
@@ -911,6 +1177,13 @@
@@ -911,6 +1178,13 @@
nbttaglist.add(nbttagcompound);
}

View File

@ -84,7 +84,7 @@
+ // CraftBukkit start
+ private static boolean setTilt(IBlockData iblockdata, World world, BlockPosition blockposition, Tilt tilt, @Nullable Entity entity) {
+ if (entity != null) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.setValue(BigDripleafBlock.TILT, tilt)).isCancelled()) {
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.setValue(BigDripleafBlock.TILT, tilt))) {
+ return false;
+ }
+ }

View File

@ -43,7 +43,7 @@
worldserver.setBlock(blockposition, this.plant.getStateForPlacement(worldserver, blockposition), 2);
} else {
- this.placeDeadFlower(worldserver, blockposition);
+ // CraftBukkit - add event
+ // CraftBukkit start - add event
+ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.defaultBlockState().setValue(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) {
+ this.placeDeadFlower(worldserver, blockposition);
+ }
@ -51,7 +51,7 @@
}
} else {
- this.placeDeadFlower(worldserver, blockposition);
+ // CraftBukkit - add event
+ // CraftBukkit start - add event
+ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.defaultBlockState().setValue(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) {
+ this.placeDeadFlower(worldserver, blockposition);
+ }
@ -63,8 +63,8 @@
BlockPosition blockposition = movingobjectpositionblock.getBlockPos();
if (!world.isClientSide && iprojectile.mayInteract(world, blockposition) && iprojectile.getType().is(TagsEntity.IMPACT_PROJECTILES)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ // CraftBukkit
+ if (!CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -1,11 +1,10 @@
--- a/net/minecraft/world/level/block/BlockComposter.java
+++ b/net/minecraft/world/level/block/BlockComposter.java
@@ -40,6 +40,12 @@
@@ -40,6 +40,11 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
+// CraftBukkit start
+import net.minecraft.world.entity.Entity;
+import org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder;
+import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
+// CraftBukkit end
@ -13,7 +12,7 @@
public class BlockComposter extends Block implements IInventoryHolder {
public static final int READY = 8;
@@ -248,7 +254,14 @@
@@ -248,7 +253,14 @@
int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL);
if (i < 7 && BlockComposter.COMPOSTABLES.containsKey(itemstack.getItem())) {
@ -21,7 +20,7 @@
+ // CraftBukkit start
+ double rand = worldserver.getRandom().nextDouble();
+ IBlockData iblockdata1 = addItem(entity, iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
+ if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
+ if (iblockdata == iblockdata1 || !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1)) {
+ return iblockdata;
+ }
+ iblockdata1 = addItem(entity, iblockdata, worldserver, blockposition, itemstack, rand);
@ -29,14 +28,14 @@
itemstack.shrink(1);
return iblockdata1;
@@ -258,6 +271,14 @@
@@ -258,6 +270,14 @@
}
public static IBlockData extractProduce(Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) {
+ // CraftBukkit start
+ if (entity != null && !(entity instanceof EntityHuman)) {
+ IBlockData iblockdata1 = empty(entity, iblockdata, DummyGeneratorAccess.INSTANCE, blockposition);
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1)) {
+ return iblockdata;
+ }
+ }
@ -44,7 +43,7 @@
if (!world.isClientSide) {
Vec3D vec3d = Vec3D.atLowerCornerWithOffset(blockposition, 0.5D, 1.01D, 0.5D).offsetRandom(world.random, 0.7F);
EntityItem entityitem = new EntityItem(world, vec3d.x(), vec3d.y(), vec3d.z(), new ItemStack(Items.BONE_MEAL));
@@ -281,10 +302,16 @@
@@ -281,10 +301,16 @@
}
static IBlockData addItem(@Nullable Entity entity, IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
@ -62,7 +61,7 @@
return iblockdata;
} else {
int j = i + 1;
@@ -333,7 +360,8 @@
@@ -333,7 +359,8 @@
public IWorldInventory getContainer(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
int i = (Integer) iblockdata.getValue(BlockComposter.LEVEL);
@ -72,7 +71,7 @@
}
public static class ContainerOutput extends InventorySubcontainer implements IWorldInventory {
@@ -348,6 +376,7 @@
@@ -348,6 +375,7 @@
this.state = iblockdata;
this.level = generatoraccess;
this.pos = blockposition;
@ -80,16 +79,14 @@
}
@Override
@@ -372,8 +401,15 @@
@@ -372,8 +400,15 @@
@Override
public void setChanged() {
- BlockComposter.empty((Entity) null, this.state, this.level, this.pos);
- this.changed = true;
+ // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent)
+ if (this.isEmpty()) {
+ BlockComposter.empty((Entity) null, this.state, this.level, this.pos);
+ this.changed = true;
BlockComposter.empty((Entity) null, this.state, this.level, this.pos);
this.changed = true;
+ } else {
+ this.level.setBlock(this.pos, this.state, 3);
+ this.changed = false;
@ -98,7 +95,7 @@
}
}
@@ -386,6 +422,7 @@
@@ -386,6 +421,7 @@
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
super(1);
@ -106,7 +103,7 @@
this.state = iblockdata;
this.level = generatoraccess;
this.pos = blockposition;
@@ -428,8 +465,9 @@
@@ -428,8 +464,9 @@
public static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory {

View File

@ -32,7 +32,7 @@
@Override
public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
- if (entity instanceof EntityRavager && world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ if (entity instanceof EntityRavager && !CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) { // CraftBukkit
+ if (entity instanceof EntityRavager && CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
world.destroyBlock(blockposition, true, entity);
}

View File

@ -60,7 +60,7 @@
spawnParticles(world, blockposition);
if (!(Boolean) iblockdata.getValue(BlockRedstoneOre.LIT)) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.setValue(BlockRedstoneOre.LIT, true)).isCancelled()) {
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.setValue(BlockRedstoneOre.LIT, true))) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -45,7 +45,7 @@
+ return;
+ }
+
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.defaultBlockState()).isCancelled()) {
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -56,7 +56,7 @@
if (iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()).isCancelled() || !CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PROJECTILE, iprojectile, null)) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()) || !CraftEventFactory.callTNTPrimeEvent(world, blockposition, PrimeCause.PROJECTILE, iprojectile, null)) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -1,11 +1,25 @@
--- a/net/minecraft/world/level/block/BlockWaterLily.java
+++ b/net/minecraft/world/level/block/BlockWaterLily.java
@@ -24,7 +24,7 @@
@Override
@@ -13,6 +13,10 @@
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class BlockWaterLily extends BlockPlant {
protected static final VoxelShape AABB = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 1.5D, 15.0D);
@@ -25,6 +29,11 @@
public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
super.entityInside(iblockdata, world, blockposition, entity);
- if (world instanceof WorldServer && entity instanceof EntityBoat) {
+ if (world instanceof WorldServer && entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit
if (world instanceof WorldServer && entity instanceof EntityBoat) {
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end
world.destroyBlock(new BlockPosition(blockposition), true, entity);
}

View File

@ -1,12 +1,11 @@
--- a/net/minecraft/world/level/block/CaveVines.java
+++ b/net/minecraft/world/level/block/CaveVines.java
@@ -18,6 +18,14 @@
@@ -18,6 +18,13 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.shapes.VoxelShape;
+// CraftBukkit start
+import java.util.Collections;
+import net.minecraft.world.entity.Entity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.player.PlayerHarvestBlockEvent;
@ -15,13 +14,13 @@
public interface CaveVines {
VoxelShape SHAPE = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D);
@@ -25,7 +33,24 @@
@@ -25,7 +32,24 @@
static EnumInteractionResult use(@Nullable Entity entity, IBlockData iblockdata, World world, BlockPosition blockposition) {
if ((Boolean) iblockdata.getValue(CaveVines.BERRIES)) {
- Block.popResource(world, blockposition, new ItemStack(Items.GLOW_BERRIES, 1));
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, (IBlockData) iblockdata.setValue(CaveVines.BERRIES, false)).isCancelled()) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, (IBlockData) iblockdata.setValue(CaveVines.BERRIES, false))) {
+ return EnumInteractionResult.SUCCESS;
+ }
+

View File

@ -17,7 +17,7 @@
if (!world.isClientSide && iprojectile.mayInteract(world, blockposition) && iprojectile instanceof EntityThrownTrident && iprojectile.getDeltaMovement().length() > 0.6D) {
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ if (!CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState())) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -7,7 +7,7 @@
- if (entity.isOnFire() && (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman) && entity.mayInteract(world, blockposition)) {
+ // CraftBukkit start
+ if (entity.isOnFire() && entity.mayInteract(world, blockposition)) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !(world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman)).isCancelled()) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.defaultBlockState(), !(world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof EntityHuman))) {
+ return;
+ }
+ // CraftBukkit end

View File

@ -67,7 +67,7 @@ public class CraftProfileBanList implements org.bukkit.BanList {
public Set<org.bukkit.BanEntry> getBanEntries() {
ImmutableSet.Builder<org.bukkit.BanEntry> builder = ImmutableSet.builder();
for (JsonListEntry entry : list.getValues()) {
for (JsonListEntry entry : list.getEntries()) {
GameProfile profile = (GameProfile) entry.getUser();
builder.add(new CraftProfileBanEntry(profile, (GameProfileBanEntry) entry, list));
}

View File

@ -76,6 +76,7 @@ import org.bukkit.entity.Allay;
import org.bukkit.entity.Ambient;
import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Axolotl;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Bee;
@ -616,7 +617,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
} else if (AbstractArrow.class.isAssignableFrom(clazz)) {
if (TippedArrow.class.isAssignableFrom(clazz)) {
entity = EntityTypes.ARROW.create(world);
((EntityTippedArrow) entity).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
((Arrow) entity.getBukkitEntity()).setBasePotionData(new PotionData(PotionType.WATER, false, false));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
entity = EntityTypes.SPECTRAL_ARROW.create(world);
} else if (Trident.class.isAssignableFrom(clazz)) {

View File

@ -1722,7 +1722,7 @@ public final class CraftServer implements Server {
public Set<OfflinePlayer> getBannedPlayers() {
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (GameProfileBanEntry entry : playerList.getBans().getValues()) {
for (GameProfileBanEntry entry : playerList.getBans().getEntries()) {
result.add(getOfflinePlayer(entry.getUser()));
}
@ -1762,7 +1762,7 @@ public final class CraftServer implements Server {
public Set<OfflinePlayer> getWhitelistedPlayers() {
Set<OfflinePlayer> result = new LinkedHashSet<OfflinePlayer>();
for (WhiteListEntry entry : playerList.getWhiteList().getValues()) {
for (WhiteListEntry entry : playerList.getWhiteList().getEntries()) {
result.add(getOfflinePlayer(entry.getUser()));
}
@ -1773,7 +1773,7 @@ public final class CraftServer implements Server {
public Set<OfflinePlayer> getOperators() {
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (OpListEntry entry : playerList.getOps().getValues()) {
for (OpListEntry entry : playerList.getOps().getEntries()) {
result.add(getOfflinePlayer(entry.getUser()));
}

View File

@ -529,7 +529,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
EntityArrow arrow;
if (TippedArrow.class.isAssignableFrom(clazz)) {
arrow = EntityTypes.ARROW.create(world);
((EntityTippedArrow) arrow).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
((Arrow) arrow.getBukkitEntity()).setBasePotionData(new PotionData(PotionType.WATER, false, false));
} else if (SpectralArrow.class.isAssignableFrom(clazz)) {
arrow = EntityTypes.SPECTRAL_ARROW.create(world);
} else if (Trident.class.isAssignableFrom(clazz)) {

View File

@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectList;
import net.minecraft.world.entity.EntityAreaEffectCloud;
@ -152,14 +154,14 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
getHandle().effects.remove(existing);
}
getHandle().addEffect(CraftPotionUtil.fromBukkit(effect));
getHandle().refreshEffects();
getHandle().updateColor();
return true;
}
@Override
public void clearCustomEffects() {
getHandle().effects.clear();
getHandle().refreshEffects();
getHandle().updateColor();
}
@Override
@ -199,19 +201,19 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud
return false;
}
getHandle().effects.remove(existing);
getHandle().refreshEffects();
getHandle().updateColor();
return true;
}
@Override
public void setBasePotionData(PotionData data) {
Preconditions.checkArgument(data != null, "PotionData cannot be null");
getHandle().setPotionType(CraftPotionUtil.fromBukkit(data));
getHandle().setPotion(BuiltInRegistries.POTION.get(new MinecraftKey(CraftPotionUtil.fromBukkit(data))));
}
@Override
public PotionData getBasePotionData() {
return CraftPotionUtil.toBukkit(getHandle().getPotionType());
return CraftPotionUtil.toBukkit((BuiltInRegistries.POTION.getKey(getHandle().potion)).toString());
}
@Override

View File

@ -56,6 +56,7 @@ import org.bukkit.craftbukkit.inventory.CraftEntityEquipment;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.DragonFireball;
import org.bukkit.entity.Egg;
import org.bukkit.entity.EnderPearl;
@ -434,7 +435,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
} else if (AbstractArrow.class.isAssignableFrom(projectile)) {
if (TippedArrow.class.isAssignableFrom(projectile)) {
launch = new EntityTippedArrow(world, getHandle());
((EntityTippedArrow) launch).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
((Arrow) launch.getBukkitEntity()).setBasePotionData(new PotionData(PotionType.WATER, false, false));
} else if (SpectralArrow.class.isAssignableFrom(projectile)) {
launch = new EntitySpectralArrow(world, getHandle());
} else if (Trident.class.isAssignableFrom(projectile)) {

View File

@ -37,16 +37,6 @@ public class CraftRabbit extends CraftAnimals implements Rabbit {
@Override
public void setRabbitType(Type type) {
EntityRabbit entity = getHandle();
if (getRabbitType() == Type.THE_KILLER_BUNNY) {
// Reset goals and target finders.
World world = ((CraftWorld) this.getWorld()).getHandle();
entity.goalSelector = new PathfinderGoalSelector(world.getProfilerSupplier());
entity.targetSelector = new PathfinderGoalSelector(world.getProfilerSupplier());
entity.registerGoals();
entity.initializePathFinderGoals();
}
entity.setVariant(EntityRabbit.Variant.values()[type.ordinal()]);
getHandle().setVariant(EntityRabbit.Variant.values()[type.ordinal()]);
}
}

View File

@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import java.util.List;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectList;
import net.minecraft.world.entity.projectile.EntityTippedArrow;
@ -52,14 +54,14 @@ public class CraftTippedArrow extends CraftArrow implements Arrow {
getHandle().effects.remove(existing);
}
getHandle().addEffect(CraftPotionUtil.fromBukkit(effect));
getHandle().refreshEffects();
getHandle().updateColor();
return true;
}
@Override
public void clearCustomEffects() {
getHandle().effects.clear();
getHandle().refreshEffects();
getHandle().updateColor();
}
@Override
@ -99,19 +101,19 @@ public class CraftTippedArrow extends CraftArrow implements Arrow {
return false;
}
getHandle().effects.remove(existing);
getHandle().refreshEffects();
getHandle().updateColor();
return true;
}
@Override
public void setBasePotionData(PotionData data) {
Preconditions.checkArgument(data != null, "PotionData cannot be null");
getHandle().setPotionType(CraftPotionUtil.fromBukkit(data));
this.getHandle().potion = BuiltInRegistries.POTION.get(new MinecraftKey(CraftPotionUtil.fromBukkit(data)));
}
@Override
public PotionData getBasePotionData() {
return CraftPotionUtil.toBukkit(getHandle().getPotionType());
return CraftPotionUtil.toBukkit(BuiltInRegistries.POTION.getKey(this.getHandle().potion).toString());
}
@Override

View File

@ -73,6 +73,7 @@ import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.MovingObjectPositionEntity;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Server;
@ -110,6 +111,7 @@ import org.bukkit.entity.Bat;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ExperienceOrb;
import org.bukkit.entity.Explosive;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Fish;
import org.bukkit.entity.HumanEntity;
@ -171,6 +173,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityEnterLoveModeEvent;
import org.bukkit.event.entity.EntityExhaustionEvent;
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.EntityPlaceEvent;
import org.bukkit.event.entity.EntityPotionEffectEvent;
@ -180,10 +183,12 @@ import org.bukkit.event.entity.EntitySpellCastEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
import org.bukkit.event.entity.EntityTeleportEvent;
import org.bukkit.event.entity.EntityToggleGlideEvent;
import org.bukkit.event.entity.EntityToggleSwimEvent;
import org.bukkit.event.entity.EntityTransformEvent;
import org.bukkit.event.entity.ExpBottleEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FireworkExplodeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.HorseJumpEvent;
@ -742,14 +747,14 @@ public class CraftEventFactory {
/**
* ItemMergeEvent
*/
public static ItemMergeEvent callItemMergeEvent(EntityItem merging, EntityItem mergingWith) {
public static boolean callItemMergeEvent(EntityItem merging, EntityItem mergingWith) {
org.bukkit.entity.Item entityMerging = (org.bukkit.entity.Item) merging.getBukkitEntity();
org.bukkit.entity.Item entityMergingWith = (org.bukkit.entity.Item) mergingWith.getBukkitEntity();
ItemMergeEvent event = new ItemMergeEvent(entityMerging, entityMergingWith);
Bukkit.getPluginManager().callEvent(event);
return event;
return !event.isCancelled();
}
/**
@ -1197,23 +1202,23 @@ public class CraftEventFactory {
return event;
}
public static HorseJumpEvent callHorseJumpEvent(Entity horse, float power) {
public static boolean callHorseJumpEvent(Entity horse, float power) {
HorseJumpEvent event = new HorseJumpEvent((AbstractHorse) horse.getBukkitEntity(), power);
horse.getBukkitEntity().getServer().getPluginManager().callEvent(event);
return event;
return !event.isCancelled();
}
public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPosition position, IBlockData newBlock) {
public static boolean callEntityChangeBlockEvent(Entity entity, BlockPosition position, IBlockData newBlock) {
return callEntityChangeBlockEvent(entity, position, newBlock, false);
}
public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, BlockPosition position, IBlockData newBlock, boolean cancelled) {
public static boolean callEntityChangeBlockEvent(Entity entity, BlockPosition position, IBlockData newBlock, boolean cancelled) {
Block block = entity.level().getWorld().getBlockAt(position.getX(), position.getY(), position.getZ());
EntityChangeBlockEvent event = new EntityChangeBlockEvent(entity.getBukkitEntity(), block, CraftBlockData.fromData(newBlock));
event.setCancelled(cancelled);
event.getEntity().getServer().getPluginManager().callEvent(event);
return event;
return !event.isCancelled();
}
public static CreeperPowerEvent callCreeperPowerEvent(Entity creeper, Entity lightning, CreeperPowerEvent.PowerCause cause) {
@ -1772,4 +1777,33 @@ public class CraftEventFactory {
return !event.isCancelled();
}
public static EntityTeleportEvent callEntityTeleportEvent(Entity nmsEntity, double x, double y, double z) {
CraftEntity entity = nmsEntity.getBukkitEntity();
Location to = new Location(entity.getWorld(), x, y, z, nmsEntity.getYRot(), nmsEntity.getXRot());
EntityTeleportEvent event = new org.bukkit.event.entity.EntityTeleportEvent(entity, entity.getLocation(), to);
Bukkit.getPluginManager().callEvent(event);
return event;
}
public static boolean callEntityInteractEvent(Entity nmsEntity, Block block) {
EntityInteractEvent event = new EntityInteractEvent(nmsEntity.getBukkitEntity(), block);
Bukkit.getPluginManager().callEvent(event);
return !event.isCancelled();
}
public static ExplosionPrimeEvent callExplosionPrimeEvent(Explosive explosive) {
ExplosionPrimeEvent event = new ExplosionPrimeEvent(explosive);
Bukkit.getPluginManager().callEvent(event);
return event;
}
public static ExplosionPrimeEvent callExplosionPrimeEvent(Entity nmsEntity, float size, boolean fire) {
ExplosionPrimeEvent event = new ExplosionPrimeEvent(nmsEntity.getBukkitEntity(), size, fire);
Bukkit.getPluginManager().callEvent(event);
return event;
}
}

View File

@ -26,6 +26,7 @@ import org.bukkit.block.Block;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
import org.bukkit.entity.AbstractArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Egg;
import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Fireball;
@ -92,7 +93,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
} else if (AbstractArrow.class.isAssignableFrom(projectile)) {
if (TippedArrow.class.isAssignableFrom(projectile)) {
launch = new EntityTippedArrow(world, iposition.x(), iposition.y(), iposition.z());
((EntityTippedArrow) launch).setPotionType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
((Arrow) launch.getBukkitEntity()).setBasePotionData(new PotionData(PotionType.WATER, false, false));
} else if (SpectralArrow.class.isAssignableFrom(projectile)) {
launch = new EntitySpectralArrow(world, iposition.x(), iposition.y(), iposition.z());
} else {