more more work (806)

This commit is contained in:
Noah van der Aa 2024-04-24 23:23:56 +02:00
parent 3ea4a03fbc
commit 060e370a08
50 changed files with 103 additions and 169 deletions

View File

@ -78,7 +78,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void sitDown() {
- if (!this.isCamelSitting()) {
+ if (!this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), true).callEvent()) { // Paper - Add EntityToggleSitEvent
this.playSound(SoundEvents.CAMEL_SIT, 1.0F, this.getVoicePitch());
this.makeSound(SoundEvents.CAMEL_SIT);
this.setPose(Pose.SITTING);
this.gameEvent(GameEvent.ENTITY_ACTION);
@@ -0,0 +0,0 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
@ -87,7 +87,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void standUp() {
- if (this.isCamelSitting()) {
+ if (this.isCamelSitting() && new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), false).callEvent()) { // Paper - Add EntityToggleSitEvent
this.playSound(SoundEvents.CAMEL_STAND, 1.0F, this.getVoicePitch());
this.makeSound(SoundEvents.CAMEL_STAND);
this.setPose(Pose.STANDING);
this.gameEvent(GameEvent.ENTITY_ACTION);
@@ -0,0 +0,0 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl

View File

@ -8,8 +8,8 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftMovingPiston.java b
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftMovingPiston.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftMovingPiston.java
@@ -0,0 +0,0 @@ package org.bukkit.craftbukkit.block;
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
@@ -0,0 +0,0 @@ import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
import org.bukkit.Location;
import org.bukkit.World;
-public class CraftMovingPiston extends CraftBlockEntityState<PistonMovingBlockEntity> {
@ -18,8 +18,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public CraftMovingPiston(World world, PistonMovingBlockEntity tileEntity) {
super(world, tileEntity);
@@ -0,0 +0,0 @@ public class CraftMovingPiston extends CraftBlockEntityState<PistonMovingBlockEn
public CraftMovingPiston copy() {
return new CraftMovingPiston(this);
public CraftMovingPiston copy(Location location) {
return new CraftMovingPiston(this, location);
}
+
+ // Paper start - Add Moving Piston API

View File

@ -26,5 +26,5 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ {
+ // Paper end - PlayerAttackEntityEvent
float f = (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE);
float f1;
float f1 = EnchantmentHelper.getDamageBonus(this.getMainHandItem(), target.getType());
float f2 = this.getAttackStrengthScale(0.5F);

View File

@ -11,18 +11,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class FireBlock extends BaseFireBlock {
@Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
protected void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
- world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random));
+ world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world)); // Paper - Add fire-tick-delay option
+ world.scheduleTick(pos, this, FireBlock.getFireTickDelay(world)); // Paper - Add fire-tick-delay option
if (world.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) {
if (!state.canSurvive(world, pos)) {
this.fireExtinguished(world, pos); // CraftBukkit - invalid place location
@@ -0,0 +0,0 @@ public class FireBlock extends BaseFireBlock {
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
protected void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify, net.minecraft.world.item.context.UseOnContext context) {
super.onPlace(state, world, pos, oldState, notify, context);
// Paper end - UseOnContext param
// Paper end - UseOnContext param
- world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world.random));
+ world.scheduleTick(pos, (Block) this, FireBlock.getFireTickDelay(world)); // Paper - Add fire-tick-delay option
+ world.scheduleTick(pos, this, FireBlock.getFireTickDelay(world)); // Paper - Add fire-tick-delay option
}
- private static int getFireTickDelay(RandomSource random) {

View File

@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
BlockPos blockposition = hitResult.getBlockPos();
BlockState iblockdata = world.getBlockState(blockposition);
InteractionResult enuminteractionresult = InteractionResult.PASS;
boolean cancelledBlock = false;
+ boolean cancelledItem = false; // Paper - correctly handle items on cooldown

View File

@ -53,7 +53,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class Raider extends PatrollingMonster {
boolean flag = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null;
if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance())) {
if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) {
+ // Paper start - EntityPickupItemEvent fixes
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, item, 0, false).isCancelled()) {
+ return;

View File

@ -137,7 +137,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class PotionItem extends Item {
BlockState iblockdata = world.getBlockState(blockposition);
if (context.getClickedFace() != Direction.DOWN && iblockdata.is(BlockTags.CONVERTABLE_TO_MUD) && PotionUtils.getPotion(itemstack) == Potions.WATER) {
if (context.getClickedFace() != Direction.DOWN && iblockdata.is(BlockTags.CONVERTABLE_TO_MUD) && potioncontents.is(Potions.WATER)) {
+ // Paper start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityhuman, blockposition, Blocks.MUD.defaultBlockState())) {
+ entityhuman.containerMenu.sendAllDataToRemote();
@ -187,17 +187,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/CakeBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/CakeBlock.java
@@ -0,0 +0,0 @@ public class CakeBlock extends Block {
Block block = Block.byItem(item);
if (block instanceof CandleBlock) {
CandleBlock candleblock = (CandleBlock) block;
-
+ // Paper start - call change block event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, CandleCakeBlock.byCandle(block))) {
+ player.containerMenu.sendAllDataToRemote(); // update inv because candle could decrease
+ return InteractionResult.PASS;
+ return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
+ }
+ // Paper end - call change block event
if (!player.isCreative()) {
itemstack.shrink(1);
stack.shrink(1);
}
@@ -0,0 +0,0 @@ public class CakeBlock extends Block {
if (!player.canEat(false)) {
@ -221,16 +222,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- int i = (Integer) state.getValue(CakeBlock.BITES);
+ // Paper - move up
world.gameEvent((Entity) player, GameEvent.EAT, pos);
world.gameEvent((Entity) player, (Holder) GameEvent.EAT, pos);
if (i < 6) {
diff --git a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/ComposterBlock.java
@@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
if (i < 8 && ComposterBlock.COMPOSTABLES.containsKey(itemstack.getItem())) {
if (i < 8 && ComposterBlock.COMPOSTABLES.containsKey(stack.getItem())) {
if (i < 7 && !world.isClientSide) {
BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, itemstack);
BlockState iblockdata1 = ComposterBlock.addItem(player, state, world, pos, stack);
+ // Paper start - handle cancelled events
+ if (iblockdata1 == null) {
+ return InteractionResult.PASS;
@ -238,7 +239,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
world.levelEvent(1500, pos, state != iblockdata1 ? 1 : 0);
player.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
player.awardStat(Stats.ITEM_USED.get(stack.getItem()));
@@ -0,0 +0,0 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder {
if (i < 7 && ComposterBlock.COMPOSTABLES.containsKey(stack.getItem())) {
// CraftBukkit start
@ -283,26 +284,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
generatoraccess.setBlock(blockposition, iblockdata1, 3);
generatoraccess.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entity, iblockdata1));
generatoraccess.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(entity, iblockdata1));
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
@@ -0,0 +0,0 @@ public class BeehiveBlockEntity extends BlockEntity {
--j;
}
- world.setBlockAndUpdate(blockposition, (BlockState) iblockdata.setValue(BeehiveBlock.HONEY_LEVEL, i + j));
+ // Paper start - Fire EntityChangeBlockEvent in more places
+ BlockState newBlockState = iblockdata.setValue(BeehiveBlock.HONEY_LEVEL, i + j);
+
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entitybee, blockposition, newBlockState)) {
+ world.setBlockAndUpdate(blockposition, newBlockState);
+ }
+ // Paper end - Fire EntityChangeBlockEvent in more places
--j;
}
- world.setBlockAndUpdate(blockposition, (BlockState) iblockdata.setValue(BeehiveBlock.HONEY_LEVEL, i + j));
+ // Paper start - Fire EntityChangeBlockEvent in more places
+ BlockState newBlockState = iblockdata.setValue(BeehiveBlock.HONEY_LEVEL, i + j);
+
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entitybee, blockposition, newBlockState)) {
+ world.setBlockAndUpdate(blockposition, newBlockState);
+ }
+ // Paper end - Fire EntityChangeBlockEvent in more places
}
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java b/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/DummyGeneratorAccess.java
@ -310,7 +311,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class DummyGeneratorAccess implements WorldGenLevel {
@Override
public void gameEvent(GameEvent event, Vec3 emitterPos, GameEvent.Context emitter) {
public void gameEvent(Holder<GameEvent> event, Vec3 emitterPos, GameEvent.Context emitter) {
- // Used by BlockComposter
+ // Used by ComposterBlock
}

View File

@ -9,10 +9,10 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
pluginManager.callEvent(entityCombustEvent);
if (!entityCombustEvent.isCancelled()) {
this.setSecondsOnFire(entityCombustEvent.getDuration(), false);
this.igniteForSeconds(entityCombustEvent.getDuration(), false);
+ // Paper start - fix EntityCombustEvent cancellation
+ } else {
+ this.setRemainingFireTicks(this.remainingFireTicks - 1);
@ -27,7 +27,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class BaseFireBlock extends Block {
if (!event.isCancelled()) {
entity.setSecondsOnFire(event.getDuration(), false);
entity.igniteForSeconds(event.getDuration(), false);
+ // Paper start - fix EntityCombustEvent cancellation
+ } else {
+ entity.setRemainingFireTicks(entity.getRemainingFireTicks() - 1);

View File

@ -3,9 +3,6 @@ From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Mon, 11 Jul 2022 11:56:41 -0700
Subject: [PATCH] Fix a bunch of vanilla bugs
https://bugs.mojang.com/browse/MC-253884
show raid entity event to all tracking players
https://bugs.mojang.com/browse/MC-253721
wrong msg for opping multiple players
@ -49,12 +46,6 @@ https://bugs.mojang.com/browse/MC-123848
https://bugs.mojang.com/browse/MC-84789
Fix wild wolves not considering bones interesting
https://bugs.mojang.com/browse/MC-225381
Fix overfilled bundles duplicating items / being filled with air
https://bugs.mojang.com/browse/MC-173303
Fix leashed pets teleporting to owner when loaded
https://bugs.mojang.com/browse/MC-174630
Fix secondary beacon effect remaining after switching effect
@ -250,19 +241,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.mob.getRandom().nextInt(this.mob.isBaby() ? 50 : 1000) != 0) {
return false;
} else {
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.java
@@ -0,0 +0,0 @@ public class FollowOwnerGoal extends Goal {
}
private boolean unableToMove() {
- return this.tamable.isOrderedToSit() || this.tamable.isPassenger() || this.tamable.isLeashed();
+ return this.tamable.isOrderedToSit() || this.tamable.isPassenger() || this.tamable.isLeashed() || this.tamable.leashInfoTag != null; // Paper - Fix MC-173303
}
@Override
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/SwellGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/SwellGoal.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/SwellGoal.java
@ -315,13 +293,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
}
public void equipArmor(Player player, ItemStack stack) {
public void equipBodyArmor(Player player, ItemStack stack) {
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -0,0 +0,0 @@ public class ItemFrame extends HangingEntity {
}
return (ItemStack) this.getEntityData().get(ItemFrame.DATA_ITEM);
}
+ // Paper start - Fix MC-123848 (spawn item frame drops above block)
@ -332,9 +310,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end
+
private void removeFramedMap(ItemStack itemstack) {
this.getFramedMapId().ifPresent((i) -> {
MapItemSavedData worldmap = MapItem.getSavedData(i, this.level());
@Nullable
public MapId getFramedMapId() {
return (MapId) this.getItem().get(DataComponents.MAP_ID);
diff --git a/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java b/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/npc/CatSpawner.java
@ -344,33 +322,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return 0;
} else {
+ cat.moveTo(pos, 0.0F, 0.0F); // Paper - move up - Fix MC-147659
cat.finalizeSpawn(world, world.getCurrentDifficultyAt(pos), MobSpawnType.NATURAL, null, null);
cat.finalizeSpawn(world, world.getCurrentDifficultyAt(pos), MobSpawnType.NATURAL, null);
- cat.moveTo(pos, 0.0F, 0.0F);
world.addFreshEntityWithPassengers(cat);
return 1;
}
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raids.java b/src/main/java/net/minecraft/world/entity/raid/Raids.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/raid/Raids.java
+++ b/src/main/java/net/minecraft/world/entity/raid/Raids.java
@@ -0,0 +0,0 @@ public class Raids extends SavedData {
// CraftBukkit end
} else {
player.removeEffect(MobEffects.BAD_OMEN);
- player.connection.send(new ClientboundEntityEventPacket(player, (byte) 43));
+ this.level.broadcastEntityEvent(player, net.minecraft.world.entity.EntityEvent.BAD_OMEN_TRIGGERED /* (byte) 43 */); // Paper - Fix MC-253884
}
if (flag) {
@@ -0,0 +0,0 @@ public class Raids extends SavedData {
}
// CraftBukkit end
raid.absorbBadOmen(player);
- player.connection.send(new ClientboundEntityEventPacket(player, (byte) 43));
+ this.level.broadcastEntityEvent(player, net.minecraft.world.entity.EntityEvent.BAD_OMEN_TRIGGERED /* (byte) 43 */); // Paper - Fix MC-253884
if (!raid.hasFirstWaveSpawned()) {
player.awardStat(Stats.RAID_TRIGGER);
CriteriaTriggers.BAD_OMEN.trigger(player);
diff --git a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java b/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/inventory/BeaconMenu.java
@ -378,37 +334,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class BeaconMenu extends AbstractContainerMenu {
// Paper end - Add PlayerChangeBeaconEffectEvent
public void updateEffects(Optional<MobEffect> primary, Optional<MobEffect> secondary) {
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())) {
+ if (secondary.isPresent() && secondary.get().value() != net.minecraft.world.effect.MobEffects.REGENERATION && (primary.isPresent() && secondary.get() != primary.get())) {
+ secondary = Optional.empty();
+ }
+ // Paper end
if (this.paymentSlot.hasItem()) {
// Paper start - Add PlayerChangeBeaconEffectEvent
io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent event = new io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent((org.bukkit.entity.Player) this.player.player.getBukkitEntity(), convert(primary), convert(secondary), this.access.getLocation().getBlock());
diff --git a/src/main/java/net/minecraft/world/item/BundleItem.java b/src/main/java/net/minecraft/world/item/BundleItem.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/BundleItem.java
+++ b/src/main/java/net/minecraft/world/item/BundleItem.java
@@ -0,0 +0,0 @@ public class BundleItem extends Item {
removeOne(stack).ifPresent(removedStack -> add(stack, slot.safeInsert(removedStack)));
} else if (itemStack.getItem().canFitInsideContainerItems()) {
int i = (64 - getContentWeight(stack)) / getWeight(itemStack);
- int j = add(stack, slot.safeTake(itemStack.getCount(), i, player));
+ int j = add(stack, slot.safeTake(itemStack.getCount(), Math.max(0, i), player)); // Paper - prevent item addition on overfilled bundles - safeTake will yield EMPTY for amount == 0.
if (j > 0) {
this.playInsertSound(player);
}
@@ -0,0 +0,0 @@ public class BundleItem extends Item {
int i = getContentWeight(bundle);
int j = getWeight(stack);
int k = Math.min(stack.getCount(), (64 - i) / j);
- if (k == 0) {
+ if (k <= 0) { // Paper - prevent item addition on overfilled bundles
return 0;
} else {
ListTag listTag = compoundTag.getList("Items", 10);
diff --git a/src/main/java/net/minecraft/world/item/SaddleItem.java b/src/main/java/net/minecraft/world/item/SaddleItem.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/SaddleItem.java

View File

@ -68,22 +68,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
super(type, world);
@@ -0,0 +0,0 @@ public class ItemEntity extends Entity implements TraceableEntity {
this.move(MoverType.SELF, this.getDeltaMovement());
float f1 = 0.98F;
float f = 0.98F;
- if (this.onGround()) {
+ // Paper start - Friction API
+ if (frictionState == net.kyori.adventure.util.TriState.FALSE) {
+ f1 = 1F;
+ f = 1F;
+ } else if (this.onGround()) {
+ // Paper end - Friction API
f1 = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F;
f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F;
}
- this.setDeltaMovement(this.getDeltaMovement().multiply((double) f1, 0.98D, (double) f1));
+ this.setDeltaMovement(this.getDeltaMovement().multiply((double) f1, frictionState == net.kyori.adventure.util.TriState.FALSE ? 1D : 0.98D, (double) f1)); // Paper - Friction API
if (this.onGround()) {
Vec3 vec3d1 = this.getDeltaMovement();
@@ -0,0 +0,0 @@ public class ItemEntity extends Entity implements TraceableEntity {
@Override
@ -97,7 +92,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
nbt.putShort("Age", (short) this.age);
nbt.putShort("PickupDelay", (short) this.pickupDelay);
@@ -0,0 +0,0 @@ public class ItemEntity extends Entity implements TraceableEntity {
this.cachedThrower = null;
this.setItem(ItemStack.EMPTY);
}
+ // Paper start - Friction API
@ -111,9 +106,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end - Friction API
+
CompoundTag nbttagcompound1 = nbt.getCompound("Item");
this.setItem(ItemStack.of(nbttagcompound1));
if (this.getItem().isEmpty()) {
this.discard(null); // CraftBukkit - add Bukkit remove cause
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java

View File

@ -61,8 +61,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public static final int AMOUNT_FULL = 8;
+ protected final boolean isEmpty; // Paper - Perf: moved from isEmpty()
public FluidState(Fluid fluid, ImmutableMap<Property<?>, Comparable<?>> propertiesMap, MapCodec<FluidState> codec) {
super(fluid, propertiesMap, codec);
public FluidState(Fluid fluid, Reference2ObjectArrayMap<Property<?>, Comparable<?>> propertyMap, MapCodec<FluidState> codec) {
super(fluid, propertyMap, codec);
+ this.isEmpty = fluid.isEmpty(); // Paper - Perf: moved from isEmpty()
}

View File

@ -8,15 +8,15 @@ diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
@@ -0,0 +0,0 @@ public class Cat extends TamableAnimal implements VariantHolder<CatVariant> {
if (!(item instanceof DyeItem)) {
if (item.isEdible() && this.isFood(itemstack) && this.getHealth() < this.getMaxHealth()) {
this.usePlayerItem(player, hand, itemstack);
- this.heal((float) item.getFoodProperties().getNutrition());
+ this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason
return InteractionResult.CONSUME;
}
@@ -0,0 +0,0 @@ public class Cat extends TamableAnimal implements VariantHolder<Holder<CatVarian
this.usePlayerItem(player, hand, itemstack);
FoodProperties foodinfo = (FoodProperties) itemstack.get(DataComponents.FOOD);
- this.heal(foodinfo != null ? (float) foodinfo.nutrition() : 1.0F);
+ this.heal(foodinfo != null ? (float) foodinfo.nutrition() : 1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason
}
return InteractionResult.sidedSuccess(this.level().isClientSide());
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java

View File

@ -35,11 +35,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java
+++ b/src/main/java/net/minecraft/world/item/SuspiciousStewItem.java
@@ -0,0 +0,0 @@ public class SuspiciousStewItem extends Item {
@Override
public ItemStack finishUsingItem(ItemStack stack, Level world, LivingEntity user) {
ItemStack itemStack = super.finishUsingItem(stack, world, user);
- listPotionEffects(itemStack, effect -> user.addEffect(effect.createEffectInstance()));
+ listPotionEffects(itemStack, effect -> user.addEffect(effect.createEffectInstance(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD)); // Paper - Add missing effect cause
return user instanceof Player && ((Player)user).getAbilities().instabuild ? itemStack : new ItemStack(Items.BOWL);
}
}
SuspiciousStewEffects suspiciousStewEffects = stack.getOrDefault(DataComponents.SUSPICIOUS_STEW_EFFECTS, SuspiciousStewEffects.EMPTY);
for (SuspiciousStewEffects.Entry entry : suspiciousStewEffects.effects()) {
- user.addEffect(entry.createEffectInstance());
+ user.addEffect(entry.createEffectInstance(), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper - Add missing effect cause
}
super.finishUsingItem(stack, world, user);

View File

@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -0,0 +0,0 @@ public class Commodore {
super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, CB_PACKAGE + "/advancement/CraftAdvancement", "getDisplay0", desc, false);
super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, CB_PACKAGE_PREFIX + "advancement/CraftAdvancement", "getDisplay0", desc, false);
return;
}
+ if (owner.equals("org/bukkit/WorldCreator") && name.equals("keepSpawnLoaded") && desc.equals("(Lnet/kyori/adventure/util/TriState;)V")) {

View File

@ -24,7 +24,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -0,0 +0,0 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public void startSeenByPlayer(ServerPlayer player) {}

View File

@ -9,18 +9,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (entity instanceof Mob) {
Mob entityinsentient = (Mob) entity;
}
if (entity instanceof Mob entityinsentient) {
- if (ServerLevel.this.isUpdatingNavigations) {
+ if (false && ServerLevel.this.isUpdatingNavigations) { // Paper - Remove unnecessary onTrackingStart during navigation warning
String s = "onTrackingStart called during navigation iteration";
Util.logAndPauseIfInIde("onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration"));
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (entity instanceof Mob) {
Mob entityinsentient = (Mob) entity;
}
if (entity instanceof Mob entityinsentient) {
- if (ServerLevel.this.isUpdatingNavigations) {
+ if (false && ServerLevel.this.isUpdatingNavigations) { // Paper - Remove unnecessary onTrackingStart during navigation warning
String s = "onTrackingStart called during navigation iteration";

View File

@ -41,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
+++ b/src/main/java/net/minecraft/world/entity/monster/ZombieVillager.java
@@ -0,0 +0,0 @@ public class ZombieVillager extends Zombie implements VillagerDataHolder {
entityvillager.finalizeSpawn(world, world.getCurrentDifficultyAt(entityvillager.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null, (CompoundTag) null);
entityvillager.finalizeSpawn(world, world.getCurrentDifficultyAt(entityvillager.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData) null);
entityvillager.refreshBrain(world);
if (this.conversionStarter != null) {
- Player entityhuman = world.getPlayerByUUID(this.conversionStarter);

View File

@ -10,26 +10,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -0,0 +0,0 @@ public class ItemFrame extends HangingEntity {
// Paper end
}
private void removeFramedMap(ItemStack itemstack) {
- this.getFramedMapId().ifPresent((i) -> {
+ // Paper start - fix MC-252817 (green map markers do not disappear)
+ this.getFramedMapIdFromItem(itemstack).ifPresent((i) -> {
+ // Paper end - fix MC-252817
MapItemSavedData worldmap = MapItem.getSavedData(i, this.level());
private void removeFramedMap(ItemStack stack) {
- MapId mapid = this.getFramedMapId();
-
+ MapId mapid = this.getFramedMapIdForItem(stack); // Paper - fix MC-252817 (green map markers do not disappear)
if (mapid != null) {
MapItemSavedData worldmap = MapItem.getSavedData(mapid, this.level());
if (worldmap != null) {
@@ -0,0 +0,0 @@ public class ItemFrame extends HangingEntity {
public OptionalInt getFramedMapId() {
ItemStack itemstack = this.getItem();
+ // Paper start - fix MC-252817 (green map markers do not disappear)
+ return this.getFramedMapIdFromItem(itemstack);
@Nullable
public MapId getFramedMapId() {
- return (MapId) this.getItem().get(DataComponents.MAP_ID);
+ // Paper start
+ return this.getFramedMapIdForItem(this.getItem());
}
+ @Nullable
+ public MapId getFramedMapIdForItem(ItemStack item) {
+ return (MapId) item.get(DataComponents.MAP_ID);
+ }
+ public OptionalInt getFramedMapIdFromItem(ItemStack itemstack) {
+ // Paper end - fix MC-252817
if (itemstack.is(Items.FILLED_MAP)) {
Integer integer = MapItem.getMapId(itemstack);
+ // Paper end
+
public boolean hasFramedMap() {
return this.getItem().has(DataComponents.MAP_ID);
}

View File

@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - Call BlockFormEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos, iblockdata1)) {
Block.pushEntitiesUp(((PointedDripstoneBlock.FluidInfo) optional.get()).sourceState, iblockdata1, world, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos);
world.gameEvent(GameEvent.BLOCK_CHANGE, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos, GameEvent.Context.of(iblockdata1));
world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, ((PointedDripstoneBlock.FluidInfo) optional.get()).pos, GameEvent.Context.of(iblockdata1));
world.levelEvent(1504, blockposition1, 0);
+ }
+ // Paper end - Call BlockFormEvent