Fix a bunch of vanilla bugs

https://bugs.mojang.com/browse/MC-253721
  wrong msg for opping multiple players

https://bugs.mojang.com/browse/MC-248588
  respect mob griefing gamerule for draining water cauldrons

https://bugs.mojang.com/browse/MC-244739
  play goat eating sound for last item in stack

https://bugs.mojang.com/browse/MC-243057
  ignore furnace fuel slot in recipe book click

https://bugs.mojang.com/browse/MC-147659
  Some witch huts spawn the incorrect cat
  Note: Marked as Won't Fix, makes 0 sense

https://bugs.mojang.com/browse/MC-179072
  Creepers do not defuse when switching from Survival to Creative/Spectator

https://bugs.mojang.com/browse/MC-259571
  Fix changeGameModeForPlayer to use gameModeForPlayer

https://bugs.mojang.com/browse/MC-262422
  Fix lightning being able to hit spectators

https://bugs.mojang.com/browse/MC-263999
  Fix mobs breaking doors not spawning block break particles

https://bugs.mojang.com/browse/MC-210802
  Fixes sheep eating blocks outside of ticking range

https://bugs.mojang.com/browse/MC-123848
  Fixes item frames dropping items above when pointing down

https://bugs.mojang.com/browse/MC-174630
  Fix secondary beacon effect remaining after switching effect

https://bugs.mojang.com/browse/MC-153086
  Fix the beacon deactivation sound always playing when broken

https://bugs.mojang.com/browse/MC-200092
  Fix yaw being ignored for a player's first spawn pos

https://bugs.mojang.com/browse/MC-158900
  Fix error when joining after tempban expired

https://bugs.mojang.com/browse/MC-99075
  Fix inventory desync within spawn protected area

https://bugs.mojang.com/browse/MC-273635
  Fix TrialSpawner forgets assigned mob when placed by player

== AT ==
public net/minecraft/world/entity/Mob leashInfoTag
public net/minecraft/server/level/ChunkMap anyPlayerCloseEnoughForSpawning(Lnet/minecraft/world/level/ChunkPos;)Z

Co-authored-by: William Blake Galbreath <blake.galbreath@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
Jake Potrebic
2022-07-11 11:56:41 -07:00
parent 492ebf1459
commit 0b9ef3701e
20 changed files with 256 additions and 83 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java
+++ b/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java
@@ -72,6 +72,12 @@
@@ -72,9 +72,16 @@
}
if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level().getDifficulty())) {
@@ -10,6 +10,11 @@
+ return;
+ }
+ // CraftBukkit end
+ final net.minecraft.world.level.block.state.BlockState oldState = this.mob.level().getBlockState(this.doorPos); // Paper - fix MC-263999
this.mob.level().removeBlock(this.doorPos, false);
this.mob.level().levelEvent(1021, this.doorPos, 0);
this.mob.level().levelEvent(2001, this.doorPos, Block.getId(this.mob.level().getBlockState(this.doorPos)));
- this.mob.level().levelEvent(2001, this.doorPos, Block.getId(this.mob.level().getBlockState(this.doorPos)));
+ this.mob.level().levelEvent(2001, this.doorPos, Block.getId(oldState)); // Paper - fix MC-263999
}
}

View File

@@ -11,7 +11,19 @@
public class EatBlockGoal extends Goal {
private static final int EAT_ANIMATION_TICKS = 40;
@@ -63,8 +67,9 @@
@@ -27,6 +31,11 @@
@Override
public boolean canUse() {
+ // Paper start - Fix MC-210802
+ if (!((net.minecraft.server.level.ServerLevel) this.level).chunkSource.chunkMap.anyPlayerCloseEnoughForSpawning(this.mob.chunkPosition())) {
+ return false;
+ }
+ // Paper end
if (this.mob.getRandom().nextInt(this.mob.isBaby() ? 50 : 1000) != 0) {
return false;
} else {
@@ -63,8 +72,9 @@
if (this.eatAnimationTick == this.adjustedTickDelay(4)) {
BlockPos blockposition = this.mob.blockPosition();
@@ -23,7 +35,7 @@
this.level.destroyBlock(blockposition, false);
}
@@ -73,7 +78,7 @@
@@ -73,7 +83,7 @@
BlockPos blockposition1 = blockposition.below();
if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) {

View File

@@ -0,0 +1,17 @@
--- a/net/minecraft/world/entity/ai/goal/SwellGoal.java
+++ b/net/minecraft/world/entity/ai/goal/SwellGoal.java
@@ -21,7 +21,14 @@
return this.creeper.getSwellDir() > 0 || livingEntity != null && this.creeper.distanceToSqr(livingEntity) < 9.0;
}
+ // Paper start - Fix MC-179072
@Override
+ public boolean canContinueToUse() {
+ return !net.minecraft.world.entity.EntitySelector.NO_CREATIVE_OR_SPECTATOR.test(this.creeper.getTarget()) && canUse();
+ }
+ // Paper end
+
+ @Override
public void start() {
this.creeper.getNavigation().stop();
this.target = this.creeper.getTarget();

View File

@@ -21,7 +21,7 @@
}
@Override
@@ -229,8 +234,15 @@
@@ -229,15 +234,23 @@
ItemStack itemstack = player.getItemInHand(hand);
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
@@ -38,7 +38,16 @@
player.setItemInHand(hand, itemstack1);
return InteractionResult.SUCCESS;
@@ -353,8 +365,7 @@
} else {
+ boolean isFood = this.isFood(itemstack); // Paper - track before stack is possibly decreased to 0 (Fixes MC-244739)
InteractionResult enuminteractionresult = super.mobInteract(player, hand);
- if (enuminteractionresult.consumesAction() && this.isFood(itemstack)) {
+ if (enuminteractionresult.consumesAction() && isFood) { // Paper
this.playEatingSound();
}
@@ -353,8 +366,7 @@
double d2 = (double) Mth.randomBetween(this.random, -0.2F, 0.2F);
ItemEntity entityitem = new ItemEntity(this.level(), vec3d.x(), vec3d.y(), vec3d.z(), itemstack, d0, d1, d2);
@@ -48,7 +57,7 @@
}
}
@@ -383,4 +394,15 @@
@@ -383,4 +395,15 @@
public static boolean checkGoatSpawnRules(EntityType<? extends Animal> entityType, LevelAccessor world, EntitySpawnReason spawnReason, BlockPos pos, RandomSource random) {
return world.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(world, pos);
}

View File

@@ -57,7 +57,23 @@
this.dropItem(world, source.getEntity(), false);
this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity());
this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
@@ -267,17 +286,23 @@
@@ -251,7 +270,15 @@
public ItemStack getItem() {
return (ItemStack) this.getEntityData().get(ItemFrame.DATA_ITEM);
+ }
+
+ // Paper start - Fix MC-123848 (spawn item frame drops above block)
+ @Nullable
+ @Override
+ public net.minecraft.world.entity.item.ItemEntity spawnAtLocation(ServerLevel serverLevel, ItemStack stack) {
+ return this.spawnAtLocation(serverLevel, stack, this.getDirection() == Direction.DOWN ? -0.6F : 0.0F);
}
+ // Paper end
@Nullable
public MapId getFramedMapId(ItemStack stack) {
@@ -267,17 +294,23 @@
}
public void setItem(ItemStack value, boolean update) {
@@ -87,7 +103,7 @@
this.level().updateNeighbourForOutputSignal(this.pos, Blocks.AIR);
}
@@ -386,7 +411,13 @@
@@ -386,7 +419,13 @@
if (worldmap != null && worldmap.isTrackedCountOverLimit(256)) {
return InteractionResult.FAIL;
} else {
@@ -102,7 +118,7 @@
this.gameEvent(GameEvent.BLOCK_CHANGE, player);
itemstack.consume(1, player);
return InteractionResult.SUCCESS;
@@ -395,6 +426,13 @@
@@ -395,6 +434,13 @@
return InteractionResult.PASS;
}
} else {

View File

@@ -0,0 +1,12 @@
--- a/net/minecraft/world/entity/npc/CatSpawner.java
+++ b/net/minecraft/world/entity/npc/CatSpawner.java
@@ -82,8 +82,8 @@
if (cat == null) {
return 0;
} else {
+ cat.moveTo(pos, 0.0F, 0.0F); // Paper - move up - Fix MC-147659
cat.finalizeSpawn(world, world.getCurrentDifficultyAt(pos), EntitySpawnReason.NATURAL, null);
- cat.moveTo(pos, 0.0F, 0.0F);
world.addFreshEntityWithPassengers(cat);
return 1;
}

View File

@@ -43,7 +43,7 @@
return stillValid(this.access, player, Blocks.BEACON);
}
@@ -148,12 +157,25 @@
@@ -148,12 +157,30 @@
return BeaconMenu.decodeEffect(this.beaconData.get(2));
}
@@ -54,6 +54,11 @@
+ // Paper end - Add PlayerChangeBeaconEffectEvent
+
public void updateEffects(Optional<Holder<MobEffect>> primary, Optional<Holder<MobEffect>> secondary) {
+ // Paper start - fix MC-174630 - validate secondary power
+ if (secondary.isPresent() && secondary.get() != net.minecraft.world.effect.MobEffects.REGENERATION && (primary.isPresent() && secondary.get() != primary.get())) {
+ secondary = Optional.empty();
+ }
+ // Paper end
if (this.paymentSlot.hasItem()) {
- this.beaconData.set(1, BeaconMenu.encodeEffect((Holder) primary.orElse((Object) null)));
- this.beaconData.set(2, BeaconMenu.encodeEffect((Holder) secondary.orElse((Object) null)));
@@ -71,7 +76,7 @@
}
}
@@ -178,4 +200,17 @@
@@ -178,4 +205,17 @@
return 1;
}
}

View File

@@ -20,10 +20,11 @@
if (world instanceof ServerLevel worldserver) {
if (entity.isOnFire() && this.isEntityInsideContent(state, pos, entity)) {
- entity.clearFire();
- if (entity.mayInteract(worldserver, pos)) {
- this.handleEntityOnFireInside(state, world, pos);
+ // CraftBukkit start - moved down
+ // entity.clearFire();
if (entity.mayInteract(worldserver, pos)) {
- this.handleEntityOnFireInside(state, world, pos);
+ if ((entity instanceof net.minecraft.world.entity.player.Player || worldserver.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_MOBGRIEFING)) && entity.mayInteract(worldserver, pos)) { // Paper - Fixes MC-248588
+ if (this.handleEntityOnFireInsideWithEvent(state, world, pos, entity)) { // Paper - fix powdered snow cauldron extinguishing entities
+ entity.clearFire();
+ }

View File

@@ -276,7 +276,7 @@
}
}
@@ -378,30 +481,47 @@
@@ -378,41 +481,55 @@
}
public List<RecipeHolder<?>> getRecipesToAwardAndPopExperience(ServerLevel world, Vec3 pos) {
@@ -330,3 +330,18 @@
}
@Override
public void fillStackedContents(StackedItemContents finder) {
- Iterator iterator = this.items.iterator();
+ // Paper start - don't account fuel stack (fixes MC-243057)
+ finder.accountStack(this.items.get(SLOT_INPUT));
+ finder.accountStack(this.items.get(SLOT_RESULT));
+ // Paper end
- while (iterator.hasNext()) {
- ItemStack itemstack = (ItemStack) iterator.next();
-
- finder.accountStack(itemstack);
- }
-
}
}

View File

@@ -77,7 +77,7 @@
if (blockEntity.lastCheckY >= l) {
blockEntity.lastCheckY = world.getMinY() - 1;
@@ -247,43 +291,104 @@
@@ -247,43 +291,108 @@
@Override
public void setRemoved() {
@@ -85,7 +85,11 @@
+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, worldPosition);
+ new io.papermc.paper.event.block.BeaconDeactivatedEvent(block).callEvent();
+ // Paper end - beacon activation/deactivation events
+ // Paper start - fix MC-153086
+ if (this.levels > 0 && !this.beamSections.isEmpty()) {
BeaconBlockEntity.playSound(this.level, this.worldPosition, SoundEvents.BEACON_DEACTIVATE);
+ }
+ // Paper end
super.setRemoved();
}
@@ -197,7 +201,7 @@
public static void playSound(Level world, BlockPos pos, SoundEvent sound) {
world.playSound((Player) null, pos, sound, SoundSource.BLOCKS, 1.0F, 1.0F);
}
@@ -316,7 +421,7 @@
@@ -316,7 +425,7 @@
if (nbt.contains(key, 8)) {
ResourceLocation minecraftkey = ResourceLocation.tryParse(nbt.getString(key));
@@ -206,7 +210,7 @@
} else {
return null;
}
@@ -327,11 +432,13 @@
@@ -327,11 +436,13 @@
super.loadAdditional(nbt, registries);
this.primaryPower = BeaconBlockEntity.loadEffect(nbt, "primary_effect");
this.secondaryPower = BeaconBlockEntity.loadEffect(nbt, "secondary_effect");
@@ -220,7 +224,7 @@
}
@Override
@@ -345,6 +452,7 @@
@@ -345,6 +456,7 @@
}
this.lockKey.addToTag(nbt, registries);

View File

@@ -52,3 +52,12 @@
ObjectListIterator objectlistiterator = objectarraylist.iterator();
while (objectlistiterator.hasNext()) {
@@ -370,7 +391,7 @@
}
public void overrideEntityToSpawn(EntityType<?> entityType, Level world) {
- this.data.reset();
+ this.data.reset(this); // Paper
this.normalConfig = Holder.direct(((TrialSpawnerConfig) this.normalConfig.value()).withSpawning(entityType));
this.ominousConfig = Holder.direct(((TrialSpawnerConfig) this.ominousConfig.value()).withSpawning(entityType));
this.setState(world, TrialSpawnerState.INACTIVE);

View File

@@ -1,5 +1,17 @@
--- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
+++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
@@ -100,9 +100,9 @@
this.ejectingLootTable = rewardLootTable;
}
- public void reset() {
+ public void reset(TrialSpawner logic) { // Paper - Fix TrialSpawner forgets assigned mob; MC-273635
this.currentMobs.clear();
- this.nextSpawnData = Optional.empty();
+ if (!logic.getConfig().spawnPotentialsDefinition().isEmpty()) this.nextSpawnData = Optional.empty(); // Paper - Fix TrialSpawner forgets assigned mob; MC-273635
this.resetStatistics();
}
@@ -210,7 +210,7 @@
}

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java
+++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java
@@ -145,7 +145,7 @@
yield ACTIVE;
} else if (trialSpawnerData.isCooldownFinished(world)) {
logic.removeOminous(world, pos);
- trialSpawnerData.reset();
+ trialSpawnerData.reset(logic); // Paper - Fix TrialSpawner forgets assigned mob; MC-273635
yield WAITING_FOR_PLAYERS;
} else {
yield this;

View File

@@ -53,10 +53,19 @@
}
+ public TeleportTransition(ServerLevel worldserver, Entity entity, TeleportTransition.PostTeleportTransition teleporttransition_a, PlayerTeleportEvent.TeleportCause cause) {
+ this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3.ZERO, 0.0F, 0.0F, false, false, Set.of(), teleporttransition_a, cause);
+ this(worldserver, findAdjustedSharedSpawnPos(worldserver, entity), Vec3.ZERO, worldserver.getSharedSpawnAngle(), 0.0F, false, false, Set.of(), teleporttransition_a, cause); // Paper - MC-200092 - fix first spawn pos yaw being ignored
+ // CraftBukkit end
+ }
+
private static void playPortalSound(Entity entity) {
if (entity instanceof ServerPlayer entityplayer) {
entityplayer.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
@@ -40,7 +69,7 @@
}
public static TeleportTransition missingRespawnBlock(ServerLevel world, Entity entity, TeleportTransition.PostTeleportTransition postDimensionTransition) {
- return new TeleportTransition(world, findAdjustedSharedSpawnPos(world, entity), Vec3.ZERO, 0.0F, 0.0F, true, false, Set.of(), postDimensionTransition);
+ return new TeleportTransition(world, findAdjustedSharedSpawnPos(world, entity), Vec3.ZERO, world.getSharedSpawnAngle(), 0.0F, true, false, Set.of(), postDimensionTransition); // Paper - MC-200092 - fix spawn pos yaw being ignored
}
private static Vec3 findAdjustedSharedSpawnPos(ServerLevel world, Entity entity) {