Fix diffs in block package

This commit is contained in:
Nassim Jahnke 2024-12-18 13:00:21 +01:00
parent a5e786a578
commit 71bcc8c845
No known key found for this signature in database
GPG key ID: EF6771C01F6EF02F
6 changed files with 26 additions and 24 deletions

View file

@ -9,7 +9,7 @@
level.removeBlock(pos, false); level.removeBlock(pos, false);
BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite());
if (level.getBlockState(blockPos).is(this)) { if (level.getBlockState(blockPos).is(this)) {
@@ -103,22 +_,63 @@ @@ -103,22 +_,62 @@
level.explode(null, level.damageSources().badRespawnPointExplosion(center), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); level.explode(null, level.damageSources().badRespawnPointExplosion(center), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK);
return InteractionResult.SUCCESS_SERVER; return InteractionResult.SUCCESS_SERVER;
} else if (state.getValue(OCCUPIED)) { } else if (state.getValue(OCCUPIED)) {
@ -38,7 +38,7 @@
+ } else + } else
+ // CraftBukkit end + // CraftBukkit end
if (bedSleepingProblem.getMessage() != null) { if (bedSleepingProblem.getMessage() != null) {
player.displayClientMessage(bedSleepingProblem.getMessage(), true); - player.displayClientMessage(bedSleepingProblem.getMessage(), true);
+ final net.kyori.adventure.text.Component message = event.getMessage(); // Paper - PlayerBedFailEnterEvent + final net.kyori.adventure.text.Component message = event.getMessage(); // Paper - PlayerBedFailEnterEvent
+ if (message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); // Paper - PlayerBedFailEnterEvent + if (message != null) player.displayClientMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(message), true); // Paper - PlayerBedFailEnterEvent
} }

View file

@ -46,19 +46,21 @@
} else if (tilt == Tilt.FULL) { } else if (tilt == Tilt.FULL) {
resetTilt(state, level, pos); resetTilt(state, level, pos);
} }
@@ -238,8 +_,9 @@ @@ -238,8 +_,11 @@
return entity.onGround() && entity.position().y > pos.getY() + 0.6875F; return entity.onGround() && entity.position().y > pos.getY() + 0.6875F;
} }
- private void setTiltAndScheduleTick(BlockState state, Level level, BlockPos pos, Tilt tilt, @Nullable SoundEvent sound) { - private void setTiltAndScheduleTick(BlockState state, Level level, BlockPos pos, Tilt tilt, @Nullable SoundEvent sound) {
- setTilt(state, level, pos, tilt); - setTilt(state, level, pos, tilt);
+ private void setTiltAndScheduleTick(BlockState state, Level level, BlockPos pos, Tilt tilt, @Nullable SoundEvent sound, @Nullable Entity entity) { + private void setTiltAndScheduleTick(BlockState state, Level level, BlockPos pos, Tilt tilt, @Nullable SoundEvent sound, @Nullable Entity entity) {
+ if (!BigDripleafBlock.setTilt(state, level, pos, tilt, entity)) return; + if (!setTilt(state, level, pos, tilt, entity)) {
+ return;
+ }
+ // CraftBukkit end + // CraftBukkit end
if (sound != null) { if (sound != null) {
playTiltSound(level, pos, sound); playTiltSound(level, pos, sound);
} }
@@ -251,18 +_,25 @@ @@ -251,18 +_,26 @@
} }
private static void resetTilt(BlockState state, Level level, BlockPos pos) { private static void resetTilt(BlockState state, Level level, BlockPos pos) {
@ -70,7 +72,8 @@
} }
- private static void setTilt(BlockState state, Level level, BlockPos pos, Tilt tilt) { - private static void setTilt(BlockState state, Level level, BlockPos pos, Tilt tilt) {
+ private static boolean setTilt(BlockState state, Level level, BlockPos pos, Tilt tilt, @Nullable Entity entity) { // CraftBukkit + // CraftBukkit start
+ private static boolean setTilt(BlockState state, Level level, BlockPos pos, Tilt tilt, @Nullable Entity entity) {
+ if (entity != null) { + if (entity != null) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, state.setValue(BigDripleafBlock.TILT, tilt))) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, state.setValue(BigDripleafBlock.TILT, tilt))) {
+ return false; + return false;

View file

@ -1,23 +1,20 @@
--- a/net/minecraft/world/level/block/CaveVinesBlock.java --- a/net/minecraft/world/level/block/CaveVinesBlock.java
+++ b/net/minecraft/world/level/block/CaveVinesBlock.java +++ b/net/minecraft/world/level/block/CaveVinesBlock.java
@@ -52,7 +_,7 @@ @@ -52,8 +_,15 @@
@Override @Override
protected BlockState getGrowIntoState(BlockState state, RandomSource random) { protected BlockState getGrowIntoState(BlockState state, RandomSource random) {
- return super.getGrowIntoState(state, random).setValue(BERRIES, Boolean.valueOf(random.nextFloat() < 0.11F)); - return super.getGrowIntoState(state, random).setValue(BERRIES, Boolean.valueOf(random.nextFloat() < 0.11F));
+ return this.getGrowIntoState(state, random, null); // Paper - Fix Spigot growth modifiers - }
} + // Paper start - Fix Spigot growth modifiers
+ return this.getGrowIntoState(state, random, null);
@Override + }
@@ -85,4 +_,11 @@
public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) {
level.setBlock(pos, state.setValue(BERRIES, Boolean.valueOf(true)), 2);
}
+ // Paper start - Fix Spigot growth modifiers
+ @Override + @Override
+ protected BlockState getGrowIntoState(BlockState state, RandomSource random, @javax.annotation.Nullable Level level) { + protected BlockState getGrowIntoState(BlockState state, RandomSource random, @javax.annotation.Nullable Level level) {
+ final boolean value = random.nextFloat() < (level != null ? (0.11F * (level.spigotConfig.glowBerryModifier / 100.0F)) : 0.11F); + final boolean value = random.nextFloat() < (level != null ? (0.11F * (level.spigotConfig.glowBerryModifier / 100.0F)) : 0.11F);
+ return (BlockState) super.getGrowIntoState(state, random).setValue(CaveVinesBlock.BERRIES, value); + return super.getGrowIntoState(state, random).setValue(CaveVinesBlock.BERRIES, value);
+ } + }
+ // Paper end - Fix Spigot growth modifiers + // Paper end - Fix Spigot growth modifiers
}
@Override
protected ItemStack getCloneItemStack(LevelReader level, BlockPos pos, BlockState state, boolean includeData) {

View file

@ -1,9 +1,10 @@
--- a/net/minecraft/world/level/block/CraftingTableBlock.java --- a/net/minecraft/world/level/block/CraftingTableBlock.java
+++ b/net/minecraft/world/level/block/CraftingTableBlock.java +++ b/net/minecraft/world/level/block/CraftingTableBlock.java
@@ -32,7 +_,9 @@ @@ -31,8 +_,9 @@
@Override
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
if (!level.isClientSide) { if (!level.isClientSide) {
player.openMenu(state.getMenuProvider(level, pos)); - player.openMenu(state.getMenuProvider(level, pos));
+ if (player.openMenu(state.getMenuProvider(level, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation + if (player.openMenu(state.getMenuProvider(level, pos)).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.INTERACT_WITH_CRAFTING_TABLE); player.awardStat(Stats.INTERACT_WITH_CRAFTING_TABLE);
+ } // Paper - Fix InventoryOpenEvent cancellation + } // Paper - Fix InventoryOpenEvent cancellation

View file

@ -18,7 +18,7 @@
player.awardStat(dispenserBlockEntity instanceof DropperBlockEntity ? Stats.INSPECT_DROPPER : Stats.INSPECT_DISPENSER); player.awardStat(dispenserBlockEntity instanceof DropperBlockEntity ? Stats.INSPECT_DROPPER : Stats.INSPECT_DISPENSER);
} }
@@ -87,18 +_,26 @@ @@ -87,18 +_,27 @@
BlockSource blockSource = new BlockSource(level, pos, state, dispenserBlockEntity); BlockSource blockSource = new BlockSource(level, pos, state, dispenserBlockEntity);
int randomSlot = dispenserBlockEntity.getRandomSlot(level.random); int randomSlot = dispenserBlockEntity.getRandomSlot(level.random);
if (randomSlot < 0) { if (randomSlot < 0) {
@ -31,6 +31,7 @@
DispenseItemBehavior dispenseMethod = this.getDispenseMethod(level, item); DispenseItemBehavior dispenseMethod = this.getDispenseMethod(level, item);
if (dispenseMethod != DispenseItemBehavior.NOOP) { if (dispenseMethod != DispenseItemBehavior.NOOP) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(level, pos, item, randomSlot)) return; // Paper - Add BlockPreDispenseEvent + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(level, pos, item, randomSlot)) return; // Paper - Add BlockPreDispenseEvent
+ DispenserBlock.eventFired = false; // CraftBukkit - reset event status
dispenserBlockEntity.setItem(randomSlot, dispenseMethod.dispense(blockSource, item)); dispenserBlockEntity.setItem(randomSlot, dispenseMethod.dispense(blockSource, item));
} }
} }

View file

@ -136,7 +136,7 @@
level.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 18); level.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 18);
level.gameEvent(GameEvent.BLOCK_DESTROY, blockPos2, GameEvent.Context.of(blockState1)); level.gameEvent(GameEvent.BLOCK_DESTROY, blockPos2, GameEvent.Context.of(blockState1));
if (!blockState1.is(BlockTags.FIRE)) { if (!blockState1.is(BlockTags.FIRE)) {
@@ -321,13 +_,27 @@ @@ -321,13 +_,26 @@
} }
for (int i1 = toPush.size() - 1; i1 >= 0; i1--) { for (int i1 = toPush.size() - 1; i1 >= 0; i1--) {
@ -152,13 +152,13 @@
map.remove(blockPos2); map.remove(blockPos2);
BlockState blockState2 = Blocks.MOVING_PISTON.defaultBlockState().setValue(FACING, facing); BlockState blockState2 = Blocks.MOVING_PISTON.defaultBlockState().setValue(FACING, facing);
level.setBlock(blockPos2, blockState2, 68); level.setBlock(blockPos2, blockState2, 68);
level.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockPos2, blockState2, list.get(i1), facing, extending, false)); - level.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockPos2, blockState2, list.get(i1), facing, extending, false));
+ // Paper start - fix a variety of piston desync dupes + // Paper start - fix a variety of piston desync dupes
+ if (!allowDesync) { + if (!allowDesync) {
+ blockState1 = level.getBlockState(oldPos); + blockState1 = level.getBlockState(oldPos);
+ map.replace(oldPos, blockState1); + map.replace(oldPos, blockState1);
+ } + }
+ level.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockPos2, blockState2, allowDesync ? (BlockState) list.get(i1) : blockState1, facing, extending, false)); + level.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockPos2, blockState2, allowDesync ? list.get(i1) : blockState1, facing, extending, false));
+ if (!allowDesync) { + if (!allowDesync) {
+ level.setBlock(oldPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_MOVE_BY_PISTON | 1024); // set air to prevent later physics updates from seeing this block + level.setBlock(oldPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_MOVE_BY_PISTON | 1024); // set air to prevent later physics updates from seeing this block
+ } + }