mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
net.minecraft.world.effect
This commit is contained in:
parent
8ec3dedfbd
commit
004ee8651c
17 changed files with 154 additions and 151 deletions
|
@ -0,0 +1,20 @@
|
||||||
|
--- a/net/minecraft/world/effect/HealOrHarmMobEffect.java
|
||||||
|
+++ b/net/minecraft/world/effect/HealOrHarmMobEffect.java
|
||||||
|
@@ -16,7 +_,7 @@
|
||||||
|
@Override
|
||||||
|
public boolean applyEffectTick(ServerLevel level, LivingEntity entity, int amplifier) {
|
||||||
|
if (this.isHarm == entity.isInvertedHealAndHarm()) {
|
||||||
|
- entity.heal(Math.max(4 << amplifier, 0));
|
||||||
|
+ entity.heal(Math.max(4 << amplifier, 0), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit
|
||||||
|
} else {
|
||||||
|
entity.hurtServer(level, entity.damageSources().magic(), 6 << amplifier);
|
||||||
|
}
|
||||||
|
@@ -30,7 +_,7 @@
|
||||||
|
) {
|
||||||
|
if (this.isHarm == entity.isInvertedHealAndHarm()) {
|
||||||
|
int i = (int)(health * (4 << amplifier) + 0.5);
|
||||||
|
- entity.heal(i);
|
||||||
|
+ entity.heal(i, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit
|
||||||
|
} else {
|
||||||
|
int i = (int)(health * (6 << amplifier) + 0.5);
|
||||||
|
if (source == null) {
|
|
@ -0,0 +1,11 @@
|
||||||
|
--- a/net/minecraft/world/effect/HungerMobEffect.java
|
||||||
|
+++ b/net/minecraft/world/effect/HungerMobEffect.java
|
||||||
|
@@ -12,7 +_,7 @@
|
||||||
|
@Override
|
||||||
|
public boolean applyEffectTick(ServerLevel level, LivingEntity entity, int amplifier) {
|
||||||
|
if (entity instanceof Player player) {
|
||||||
|
- player.causeFoodExhaustion(0.005F * (amplifier + 1));
|
||||||
|
+ player.causeFoodExhaustion(0.005F * (amplifier + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
|
@ -0,0 +1,15 @@
|
||||||
|
--- a/net/minecraft/world/effect/InfestedMobEffect.java
|
||||||
|
+++ b/net/minecraft/world/effect/InfestedMobEffect.java
|
||||||
|
@@ -44,7 +_,11 @@
|
||||||
|
Vector3f vector3f = entity.getLookAngle().toVector3f().mul(0.3F).mul(1.0F, 1.5F, 1.0F).rotateY(f1);
|
||||||
|
silverfish.moveTo(x, y, z, level.getRandom().nextFloat() * 360.0F, 0.0F);
|
||||||
|
silverfish.setDeltaMovement(new Vec3(vector3f));
|
||||||
|
- level.addFreshEntity(silverfish);
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ if (!level.addFreshEntity(silverfish, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT)) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
silverfish.playSound(SoundEvents.SILVERFISH_HURT);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
--- a/net/minecraft/world/effect/MobEffectUtil.java
|
||||||
|
+++ b/net/minecraft/world/effect/MobEffectUtil.java
|
||||||
|
@@ -47,18 +_,31 @@
|
||||||
|
public static List<ServerPlayer> addEffectToPlayersAround(
|
||||||
|
ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration
|
||||||
|
) {
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ return MobEffectUtil.addEffectToPlayersAround(level, source, pos, radius, effect, duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) {
|
||||||
|
+ // Paper start - Add ElderGuardianAppearanceEvent
|
||||||
|
+ return addEffectToPlayersAround(level, source, pos, radius, effect, duration, cause, null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel level, @Nullable Entity source, Vec3 pos, double radius, MobEffectInstance effect, int duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, @Nullable java.util.function.Predicate<ServerPlayer> playerPredicate) {
|
||||||
|
+ // Paper end - Add ElderGuardianAppearanceEvent
|
||||||
|
+ // CraftBukkit end
|
||||||
|
Holder<MobEffect> effect1 = effect.getEffect();
|
||||||
|
- List<ServerPlayer> players = level.getPlayers(
|
||||||
|
- serverPlayer -> serverPlayer.gameMode.isSurvival()
|
||||||
|
- && (source == null || !source.isAlliedTo(serverPlayer))
|
||||||
|
- && pos.closerThan(serverPlayer.position(), radius)
|
||||||
|
- && (
|
||||||
|
- !serverPlayer.hasEffect(effect1)
|
||||||
|
- || serverPlayer.getEffect(effect1).getAmplifier() < effect.getAmplifier()
|
||||||
|
- || serverPlayer.getEffect(effect1).endsWithin(duration - 1)
|
||||||
|
- )
|
||||||
|
- );
|
||||||
|
- players.forEach(serverPlayer -> serverPlayer.addEffect(new MobEffectInstance(effect), source));
|
||||||
|
+ List<ServerPlayer> players = level.getPlayers((entityplayer) -> {
|
||||||
|
+ // Paper start - Add ElderGuardianAppearanceEvent
|
||||||
|
+ boolean condition = entityplayer.gameMode.isSurvival() && (source == null || !source.isAlliedTo((Entity) entityplayer)) && pos.closerThan(entityplayer.position(), radius) && (!entityplayer.hasEffect(effect1) || entityplayer.getEffect(effect1).getAmplifier() < effect.getAmplifier() || entityplayer.getEffect(effect1).endsWithin(duration - 1));
|
||||||
|
+ if (condition) {
|
||||||
|
+ return playerPredicate == null || playerPredicate.test(entityplayer); // Only test the player AFTER it is true
|
||||||
|
+ } else {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ // Paper end - Add ElderGuardianAppearanceEvent
|
||||||
|
+ });
|
||||||
|
+
|
||||||
|
+ players.forEach(serverPlayer -> serverPlayer.addEffect(new MobEffectInstance(effect), source, cause)); // CraftBukkit
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
--- a/net/minecraft/world/effect/OozingMobEffect.java
|
||||||
|
+++ b/net/minecraft/world/effect/OozingMobEffect.java
|
||||||
|
@@ -49,7 +_,7 @@
|
||||||
|
if (slime != null) {
|
||||||
|
slime.setSize(2, true);
|
||||||
|
slime.moveTo(x, y, z, level.getRandom().nextFloat() * 360.0F, 0.0F);
|
||||||
|
- level.addFreshEntity(slime);
|
||||||
|
+ level.addFreshEntity(slime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT); // CraftBukkit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
--- a/net/minecraft/world/effect/PoisonMobEffect.java
|
||||||
|
+++ b/net/minecraft/world/effect/PoisonMobEffect.java
|
||||||
|
@@ -13,7 +_,7 @@
|
||||||
|
@Override
|
||||||
|
public boolean applyEffectTick(ServerLevel level, LivingEntity entity, int amplifier) {
|
||||||
|
if (entity.getHealth() > 1.0F) {
|
||||||
|
- entity.hurtServer(level, entity.damageSources().magic(), 1.0F);
|
||||||
|
+ entity.hurtServer(level, entity.damageSources().poison(), 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
|
@ -1,8 +1,8 @@
|
||||||
--- a/net/minecraft/world/effect/RegenerationMobEffect.java
|
--- a/net/minecraft/world/effect/RegenerationMobEffect.java
|
||||||
+++ b/net/minecraft/world/effect/RegenerationMobEffect.java
|
+++ b/net/minecraft/world/effect/RegenerationMobEffect.java
|
||||||
@@ -12,7 +12,7 @@
|
@@ -11,7 +_,7 @@
|
||||||
@Override
|
@Override
|
||||||
public boolean applyEffectTick(ServerLevel world, LivingEntity entity, int amplifier) {
|
public boolean applyEffectTick(ServerLevel level, LivingEntity entity, int amplifier) {
|
||||||
if (entity.getHealth() < entity.getMaxHealth()) {
|
if (entity.getHealth() < entity.getMaxHealth()) {
|
||||||
- entity.heal(1.0F);
|
- entity.heal(1.0F);
|
||||||
+ entity.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC_REGEN); // CraftBukkit
|
+ entity.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC_REGEN); // CraftBukkit
|
|
@ -0,0 +1,19 @@
|
||||||
|
--- a/net/minecraft/world/effect/SaturationMobEffect.java
|
||||||
|
+++ b/net/minecraft/world/effect/SaturationMobEffect.java
|
||||||
|
@@ -12,7 +_,15 @@
|
||||||
|
@Override
|
||||||
|
public boolean applyEffectTick(ServerLevel level, LivingEntity entity, int amplifier) {
|
||||||
|
if (entity instanceof Player player) {
|
||||||
|
- player.getFoodData().eat(amplifier + 1, 1.0F);
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ int oldFoodLevel = player.getFoodData().foodLevel;
|
||||||
|
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(player, amplifier + 1 + oldFoodLevel);
|
||||||
|
+ if (!event.isCancelled()) {
|
||||||
|
+ player.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ((org.bukkit.craftbukkit.entity.CraftPlayer) player.getBukkitEntity()).sendHealthUpdate();
|
||||||
|
+ // CraftBukkit end
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
|
@ -1,24 +1,24 @@
|
||||||
--- a/net/minecraft/world/effect/WeavingMobEffect.java
|
--- a/net/minecraft/world/effect/WeavingMobEffect.java
|
||||||
+++ b/net/minecraft/world/effect/WeavingMobEffect.java
|
+++ b/net/minecraft/world/effect/WeavingMobEffect.java
|
||||||
@@ -25,11 +25,11 @@
|
@@ -25,11 +_,11 @@
|
||||||
@Override
|
@Override
|
||||||
public void onMobRemoved(ServerLevel world, LivingEntity entity, int amplifier, Entity.RemovalReason reason) {
|
public void onMobRemoved(ServerLevel level, LivingEntity entity, int amplifier, Entity.RemovalReason reason) {
|
||||||
if (reason == Entity.RemovalReason.KILLED && (entity instanceof Player || world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) {
|
if (reason == Entity.RemovalReason.KILLED && (entity instanceof Player || level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) {
|
||||||
- this.spawnCobwebsRandomlyAround(world, entity.getRandom(), entity.blockPosition());
|
- this.spawnCobwebsRandomlyAround(level, entity.getRandom(), entity.blockPosition());
|
||||||
+ this.spawnCobwebsRandomlyAround(world, entity.getRandom(), entity.blockPosition(), entity); // Paper - Fire EntityChangeBlockEvent in more places
|
+ this.spawnCobwebsRandomlyAround(level, entity.getRandom(), entity.blockPosition(), entity); // Paper - Fire EntityChangeBlockEvent in more places
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- private void spawnCobwebsRandomlyAround(ServerLevel world, RandomSource random, BlockPos pos) {
|
- private void spawnCobwebsRandomlyAround(ServerLevel level, RandomSource random, BlockPos pos) {
|
||||||
+ private void spawnCobwebsRandomlyAround(ServerLevel world, RandomSource random, BlockPos pos, LivingEntity entity) { // Paper - Fire EntityChangeBlockEvent in more places
|
+ private void spawnCobwebsRandomlyAround(ServerLevel level, RandomSource random, BlockPos pos, LivingEntity entity) { // Paper - Fire EntityChangeBlockEvent in more places
|
||||||
Set<BlockPos> set = Sets.newHashSet();
|
Set<BlockPos> set = Sets.newHashSet();
|
||||||
int i = this.maxCobwebs.applyAsInt(random);
|
int i = this.maxCobwebs.applyAsInt(random);
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@
|
@@ -46,6 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BlockPos blockPos3 : set) {
|
for (BlockPos blockPosx : set) {
|
||||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPos3, Blocks.COBWEB.defaultBlockState())) continue; // Paper - Fire EntityChangeBlockEvent in more places
|
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockPosx, Blocks.COBWEB.defaultBlockState())) continue; // Paper - Fire EntityChangeBlockEvent in more places
|
||||||
world.setBlock(blockPos3, Blocks.COBWEB.defaultBlockState(), 3);
|
level.setBlock(blockPosx, Blocks.COBWEB.defaultBlockState(), 3);
|
||||||
world.levelEvent(3018, blockPos3, 0);
|
level.levelEvent(3018, blockPosx, 0);
|
||||||
}
|
}
|
|
@ -1,5 +1,13 @@
|
||||||
--- a/net/minecraft/world/level/block/grower/TreeGrower.java
|
--- a/net/minecraft/world/level/block/grower/TreeGrower.java
|
||||||
+++ b/net/minecraft/world/level/block/grower/TreeGrower.java
|
+++ b/net/minecraft/world/level/block/grower/TreeGrower.java
|
||||||
|
@@ -132,6 +_,7 @@
|
||||||
|
.get(configuredMegaFeature)
|
||||||
|
.orElse(null);
|
||||||
|
if (holder != null) {
|
||||||
|
+ this.setTreeType(holder); // CraftBukkit
|
||||||
|
for (int i = 0; i >= -1; i--) {
|
||||||
|
for (int i1 = 0; i1 >= -1; i1--) {
|
||||||
|
if (isTwoByTwoSapling(state, level, pos, i, i1)) {
|
||||||
@@ -164,6 +_,7 @@
|
@@ -164,6 +_,7 @@
|
||||||
if (holder1 == null) {
|
if (holder1 == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
--- a/net/minecraft/world/effect/HealOrHarmMobEffect.java
|
|
||||||
+++ b/net/minecraft/world/effect/HealOrHarmMobEffect.java
|
|
||||||
@@ -17,7 +17,7 @@
|
|
||||||
@Override
|
|
||||||
public boolean applyEffectTick(ServerLevel world, LivingEntity entity, int amplifier) {
|
|
||||||
if (this.isHarm == entity.isInvertedHealAndHarm()) {
|
|
||||||
- entity.heal((float) Math.max(4 << amplifier, 0));
|
|
||||||
+ entity.heal((float) Math.max(4 << amplifier, 0), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit
|
|
||||||
} else {
|
|
||||||
entity.hurtServer(world, entity.damageSources().magic(), (float) (6 << amplifier));
|
|
||||||
}
|
|
||||||
@@ -31,7 +31,7 @@
|
|
||||||
|
|
||||||
if (this.isHarm == target.isInvertedHealAndHarm()) {
|
|
||||||
j = (int) (proximity * (double) (4 << amplifier) + 0.5D);
|
|
||||||
- target.heal((float) j);
|
|
||||||
+ target.heal((float) j, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.MAGIC); // CraftBukkit
|
|
||||||
} else {
|
|
||||||
j = (int) (proximity * (double) (6 << amplifier) + 0.5D);
|
|
||||||
if (effectEntity == null) {
|
|
|
@ -1,11 +0,0 @@
|
||||||
--- a/net/minecraft/world/effect/HungerMobEffect.java
|
|
||||||
+++ b/net/minecraft/world/effect/HungerMobEffect.java
|
|
||||||
@@ -13,7 +13,7 @@
|
|
||||||
@Override
|
|
||||||
public boolean applyEffectTick(ServerLevel world, LivingEntity entity, int amplifier) {
|
|
||||||
if (entity instanceof Player entityhuman) {
|
|
||||||
- entityhuman.causeFoodExhaustion(0.005F * (float) (amplifier + 1));
|
|
||||||
+ entityhuman.causeFoodExhaustion(0.005F * (float) (amplifier + 1), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.HUNGER_EFFECT); // CraftBukkit - EntityExhaustionEvent
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
|
@ -1,15 +0,0 @@
|
||||||
--- a/net/minecraft/world/effect/InfestedMobEffect.java
|
|
||||||
+++ b/net/minecraft/world/effect/InfestedMobEffect.java
|
|
||||||
@@ -48,7 +48,11 @@
|
|
||||||
|
|
||||||
entitysilverfish.moveTo(x, y, z, world.getRandom().nextFloat() * 360.0F, 0.0F);
|
|
||||||
entitysilverfish.setDeltaMovement(new Vec3(vector3f));
|
|
||||||
- world.addFreshEntity(entitysilverfish);
|
|
||||||
+ // CraftBukkit start
|
|
||||||
+ if (!world.addFreshEntity(entitysilverfish, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT)) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
entitysilverfish.playSound(SoundEvents.SILVERFISH_HURT);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
--- a/net/minecraft/world/effect/MobEffectUtil.java
|
|
||||||
+++ b/net/minecraft/world/effect/MobEffectUtil.java
|
|
||||||
@@ -50,13 +50,32 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel world, @Nullable Entity entity, Vec3 origin, double range, MobEffectInstance statusEffectInstance, int duration) {
|
|
||||||
- Holder<MobEffect> holder = statusEffectInstance.getEffect();
|
|
||||||
- List<ServerPlayer> list = world.getPlayers((entityplayer) -> {
|
|
||||||
- return entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && origin.closerThan(entityplayer.position(), range) && (!entityplayer.hasEffect(holder) || entityplayer.getEffect(holder).getAmplifier() < statusEffectInstance.getAmplifier() || entityplayer.getEffect(holder).endsWithin(duration - 1));
|
|
||||||
+ // CraftBukkit start
|
|
||||||
+ return MobEffectUtil.addEffectToPlayersAround(world, entity, origin, range, statusEffectInstance, duration, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel worldserver, @Nullable Entity entity, Vec3 vec3d, double d0, MobEffectInstance mobeffect, int i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause) {
|
|
||||||
+ // Paper start - Add ElderGuardianAppearanceEvent
|
|
||||||
+ return addEffectToPlayersAround(worldserver, entity, vec3d, d0, mobeffect, i, cause, null);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static List<ServerPlayer> addEffectToPlayersAround(ServerLevel worldserver, @Nullable Entity entity, Vec3 vec3d, double d0, MobEffectInstance mobeffect, int i, org.bukkit.event.entity.EntityPotionEffectEvent.Cause cause, @Nullable java.util.function.Predicate<ServerPlayer> playerPredicate) {
|
|
||||||
+ // Paper end - Add ElderGuardianAppearanceEvent
|
|
||||||
+ // CraftBukkit end
|
|
||||||
+ Holder<MobEffect> holder = mobeffect.getEffect();
|
|
||||||
+ List<ServerPlayer> list = worldserver.getPlayers((entityplayer) -> {
|
|
||||||
+ // Paper start - Add ElderGuardianAppearanceEvent
|
|
||||||
+ boolean condition = entityplayer.gameMode.isSurvival() && (entity == null || !entity.isAlliedTo((Entity) entityplayer)) && vec3d.closerThan(entityplayer.position(), d0) && (!entityplayer.hasEffect(holder) || entityplayer.getEffect(holder).getAmplifier() < mobeffect.getAmplifier() || entityplayer.getEffect(holder).endsWithin(i - 1));
|
|
||||||
+ if (condition) {
|
|
||||||
+ return playerPredicate == null || playerPredicate.test(entityplayer); // Only test the player AFTER it is true
|
|
||||||
+ } else {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ // Paper ned - Add ElderGuardianAppearanceEvent
|
|
||||||
});
|
|
||||||
|
|
||||||
list.forEach((entityplayer) -> {
|
|
||||||
- entityplayer.addEffect(new MobEffectInstance(statusEffectInstance), entity);
|
|
||||||
+ entityplayer.addEffect(new MobEffectInstance(mobeffect), entity, cause); // CraftBukkit
|
|
||||||
});
|
|
||||||
return list;
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
--- a/net/minecraft/world/effect/OozingMobEffect.java
|
|
||||||
+++ b/net/minecraft/world/effect/OozingMobEffect.java
|
|
||||||
@@ -52,7 +52,7 @@
|
|
||||||
if (entityslime != null) {
|
|
||||||
entityslime.setSize(2, true);
|
|
||||||
entityslime.moveTo(x, y, z, world.getRandom().nextFloat() * 360.0F, 0.0F);
|
|
||||||
- world.addFreshEntity(entityslime);
|
|
||||||
+ world.addFreshEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT); // CraftBukkit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
--- a/net/minecraft/world/effect/PoisonMobEffect.java
|
|
||||||
+++ b/net/minecraft/world/effect/PoisonMobEffect.java
|
|
||||||
@@ -14,7 +14,7 @@
|
|
||||||
@Override
|
|
||||||
public boolean applyEffectTick(ServerLevel world, LivingEntity entity, int amplifier) {
|
|
||||||
if (entity.getHealth() > 1.0F) {
|
|
||||||
- entity.hurtServer(world, entity.damageSources().magic(), 1.0F);
|
|
||||||
+ entity.hurtServer(world, entity.damageSources().poison(), 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
|
@ -1,30 +0,0 @@
|
||||||
--- a/net/minecraft/world/effect/SaturationMobEffect.java
|
|
||||||
+++ b/net/minecraft/world/effect/SaturationMobEffect.java
|
|
||||||
@@ -3,6 +3,10 @@
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
+// CraftBukkit start
|
|
||||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
||||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
||||||
+// CraftBukkit end
|
|
||||||
|
|
||||||
class SaturationMobEffect extends InstantenousMobEffect {
|
|
||||||
|
|
||||||
@@ -13,7 +17,15 @@
|
|
||||||
@Override
|
|
||||||
public boolean applyEffectTick(ServerLevel world, LivingEntity entity, int amplifier) {
|
|
||||||
if (entity instanceof Player entityhuman) {
|
|
||||||
- entityhuman.getFoodData().eat(amplifier + 1, 1.0F);
|
|
||||||
+ // CraftBukkit start
|
|
||||||
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
|
|
||||||
+ org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, amplifier + 1 + oldFoodLevel);
|
|
||||||
+ if (!event.isCancelled()) {
|
|
||||||
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ ((CraftPlayer) entityhuman.getBukkitEntity()).sendHealthUpdate();
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
Loading…
Reference in a new issue