Upstream Paper's upgrade to vineflower 12.0.0 (#1782)

This commit is contained in:
granny
2026-05-31 16:42:41 -07:00
committed by GitHub
parent dc4a255969
commit 3fe5edd4b5
116 changed files with 1321 additions and 1333 deletions

View File

@@ -1,41 +1,42 @@
--- a/net/minecraft/world/item/AxeItem.java
+++ b/net/minecraft/world/item/AxeItem.java
@@ -65,13 +_,15 @@
if (playerHasBlockingItemUseIntent(context)) {
@@ -66,14 +_,16 @@
return InteractionResult.PASS;
} else {
- Optional<BlockState> newBlock = this.evaluateNewBlockState(level, pos, player, level.getBlockState(pos));
+ Optional<org.purpurmc.purpur.tool.Actionable> newBlock = this.evaluateActionable(level, pos, player, level.getBlockState(pos)); // Purpur - Tool actionable options
if (newBlock.isEmpty()) {
return InteractionResult.PASS;
} else {
+ org.purpurmc.purpur.tool.Actionable actionable = newBlock.get(); // Purpur - Tool actionable options
+ BlockState state = actionable.into().withPropertiesOf(level.getBlockState(pos)); // Purpur - Tool actionable options
ItemStack itemInHand = context.getItemInHand();
// Paper start - EntityChangeBlockEvent
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newBlock.get())) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, state)) { // Purpur - Tool actionable options
return InteractionResult.PASS;
}
// Paper end
@@ -79,8 +_,15 @@
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, pos, itemInHand);
}
}
- level.setBlock(pos, newBlock.get(), Block.UPDATE_ALL_IMMEDIATE);
- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, newBlock.get()));
+ // Purpur start - Tool actionable options
+ level.setBlock(pos, state, Block.UPDATE_ALL_IMMEDIATE);
+ actionable.drops().forEach((drop, chance) -> {
+ if (level.getRandom().nextDouble() < chance) {
+ Block.popResourceFromFace(level, pos, context.getClickedFace(), new ItemStack(drop));
+ }
+ });
+ level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, state));
+ // Purpur end - Tool actionable options
if (player != null) {
itemInHand.hurtAndBreak(1, player, context.getHand().asEquipmentSlot());
}
- Optional<BlockState> newBlock = this.evaluateNewBlockState(level, pos, player, level.getBlockState(pos));
+ Optional<org.purpurmc.purpur.tool.Actionable> newBlock = this.evaluateActionable(level, pos, player, level.getBlockState(pos)); // Purpur - Tool actionable options
if (newBlock.isEmpty()) {
return InteractionResult.PASS;
}
+ org.purpurmc.purpur.tool.Actionable actionable = newBlock.get(); // Purpur - Tool actionable options
+ BlockState state = actionable.into().withPropertiesOf(level.getBlockState(pos)); // Purpur - Tool actionable options
ItemStack itemInHand = context.getItemInHand();
// Paper start - EntityChangeBlockEvent
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, newBlock.get())) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(player, pos, state)) { // Purpur - Tool actionable options
return InteractionResult.PASS;
}
// Paper end
@@ -81,8 +_,15 @@
CriteriaTriggers.ITEM_USED_ON_BLOCK.trigger((ServerPlayer)player, pos, itemInHand);
}
- level.setBlock(pos, newBlock.get(), Block.UPDATE_ALL_IMMEDIATE);
- level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, newBlock.get()));
+ // Purpur start - Tool actionable options
+ level.setBlock(pos, state, Block.UPDATE_ALL_IMMEDIATE);
+ actionable.drops().forEach((drop, chance) -> {
+ if (level.getRandom().nextDouble() < chance) {
+ Block.popResourceFromFace(level, pos, context.getClickedFace(), new ItemStack(drop));
+ }
+ });
+ level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(player, state));
+ // Purpur end - Tool actionable options
if (player != null) {
itemInHand.hurtAndBreak(1, player, context.getHand().asEquipmentSlot());
}
@@ -97,21 +_,23 @@
&& !player.isSecondaryUseActive();
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/BlockItem.java
+++ b/net/minecraft/world/item/BlockItem.java
@@ -132,7 +_,16 @@
@@ -134,7 +_,16 @@
protected boolean updateCustomBlockEntityTag(
final BlockPos pos, final Level level, final @Nullable Player player, final ItemStack itemStack, final BlockState placedState
) {
@@ -18,15 +18,15 @@
}
protected @Nullable BlockState getPlacementState(final BlockPlaceContext context) {
@@ -194,6 +_,7 @@
}
@@ -197,6 +_,7 @@
}
if (!type.onlyOpCanSetNbt() || player != null && (player.canUseGameMasterBlocks() || (player.getAbilities().instabuild && player.getBukkitEntity().hasPermission("minecraft.nbt.place")))) { // Spigot - add permission
+ if (!(level.purpurConfig.silkTouchEnabled && blockEntity instanceof net.minecraft.world.level.block.entity.SpawnerBlockEntity && player.getBukkitEntity().hasPermission("purpur.drop.spawners"))) // Purpur - Silk touch spawners
return customData.loadInto(blockEntity, level.registryAccess());
}
if (!type.onlyOpCanSetNbt() || player != null && (player.canUseGameMasterBlocks() || (player.getAbilities().instabuild && player.getBukkitEntity().hasPermission("minecraft.nbt.place")))) { // Spigot - add permission
+ if (!(level.purpurConfig.silkTouchEnabled && blockEntity instanceof net.minecraft.world.level.block.entity.SpawnerBlockEntity && player.getBukkitEntity().hasPermission("purpur.drop.spawners"))) // Purpur - Silk touch spawners
return customData.loadInto(blockEntity, level.registryAccess());
}
@@ -234,6 +_,7 @@
@@ -236,6 +_,7 @@
public void onDestroyed(final ItemEntity entity) {
ItemContainerContents container = entity.getItem().set(DataComponents.CONTAINER, ItemContainerContents.EMPTY);
if (container != null) {

View File

@@ -11,16 +11,16 @@
+ // Purpur end - Infinity bow settings
if (projectile.isEmpty()) {
return false;
} else {
@@ -38,7 +_,7 @@
} else {
List<ItemStack> firedProjectiles = draw(itemStack, projectile, player);
if (level instanceof ServerLevel serverLevel && !firedProjectiles.isEmpty()) {
- this.shoot(serverLevel, player, player.getUsedItemHand(), itemStack, firedProjectiles, pow * 3.0F, 1.0F, pow == 1.0F, null, pow); // Paper - Pass draw strength
+ this.shoot(serverLevel, player, player.getUsedItemHand(), itemStack, firedProjectiles, pow * 3.0F, (float) serverLevel.purpurConfig.bowProjectileOffset, pow == 1.0F, null, pow); // Paper - Pass draw strength // Purpur - Projectile offset config
}
}
@@ -40,7 +_,7 @@
level.playSound(
List<ItemStack> firedProjectiles = draw(itemStack, projectile, player);
if (level instanceof ServerLevel serverLevel && !firedProjectiles.isEmpty()) {
- this.shoot(serverLevel, player, player.getUsedItemHand(), itemStack, firedProjectiles, pow * 3.0F, 1.0F, pow == 1.0F, null, pow); // Paper - Pass draw strength
+ this.shoot(serverLevel, player, player.getUsedItemHand(), itemStack, firedProjectiles, pow * 3.0F, (float) serverLevel.purpurConfig.bowProjectileOffset, pow == 1.0F, null, pow); // Paper - Pass draw strength // Purpur - Projectile offset config
}
level.playSound(
@@ -95,7 +_,7 @@
public InteractionResult use(final Level level, final Player player, final InteractionHand hand) {
ItemStack itemStack = player.getItemInHand(hand);
@@ -28,5 +28,5 @@
- if (!player.hasInfiniteMaterials() && !foundProjectile) {
+ if (!player.hasInfiniteMaterials() && !foundProjectile && !(level.purpurConfig.infinityWorksWithoutArrows && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, itemStack) > 0)) { // Purpur - Infinity bow settings
return InteractionResult.FAIL;
} else {
player.startUsingItem(hand);
}

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/item/BucketItem.java
+++ b/net/minecraft/world/item/BucketItem.java
@@ -146,7 +_,7 @@
// CraftBukkit end
if (!canPlaceFluidInsideBlock) {
@@ -152,7 +_,7 @@
return hitResult != null && this.emptyContents(user, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null, direction, clicked, itemStack, hand); // CraftBukkit
- } else if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos) && this.content.is(FluidTags.WATER)) {
+ } else if ((level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos) || (level.isTheEnd() && !org.purpurmc.purpur.PurpurConfig.allowWaterPlacementInTheEnd)) && this.content.is(FluidTags.WATER)) { // Purpur - Add allow water in end world option
}
- if (level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos) && this.content.is(FluidTags.WATER)) {
+ if ((level.environmentAttributes().getValue(EnvironmentAttributes.WATER_EVAPORATES, pos) || (level.isTheEnd() && !org.purpurmc.purpur.PurpurConfig.allowWaterPlacementInTheEnd)) && this.content.is(FluidTags.WATER)) { // Purpur - Add allow water in end world option
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/item/DyeColor.java
+++ b/net/minecraft/world/item/DyeColor.java
@@ -154,4 +_,10 @@
}
}
return null;
}
+
+ // Purpur start - Shulker spawn from bullet options

View File

@@ -7,5 +7,5 @@
- if (!blockState.is(Blocks.OBSIDIAN) && !blockState.is(Blocks.BEDROCK)) {
+ if (!level.purpurConfig.endCrystalPlaceAnywhere && !blockState.is(Blocks.OBSIDIAN) && !blockState.is(Blocks.BEDROCK)) { // Purpur - place end crystal on any block
return InteractionResult.FAIL;
} else {
BlockPos above = pos.above();
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/HoeItem.java
+++ b/net/minecraft/world/item/HoeItem.java
@@ -44,15 +_,25 @@
@@ -44,16 +_,26 @@
public InteractionResult useOn(final UseOnContext context) {
Level level = context.getLevel();
BlockPos pos = context.getClickedPos();
@@ -11,23 +11,24 @@
+ org.purpurmc.purpur.tool.Tillable tillable = level.purpurConfig.hoeTillables.get(clickedBlock);
+ if (tillable == null) {
return InteractionResult.PASS;
} else {
- Predicate<UseOnContext> predicate = logicPair.getFirst();
- Consumer<UseOnContext> action = logicPair.getSecond();
+ Predicate<UseOnContext> predicate = tillable.condition().predicate();
+ Consumer<UseOnContext> action = (ctx) -> {
+ level.setBlock(pos, tillable.into().defaultBlockState(), 11);
+ tillable.drops().forEach((drop, chance) -> {
+ if (level.getRandom().nextDouble() < chance) {
+ Block.popResourceFromFace(level, pos, ctx.getClickedFace(), new ItemStack(drop));
+ }
+ });
+ };
+ // Purpur end - Tool actionable options
if (predicate.test(context)) {
Player player = context.getPlayer();
- level.playSound(player, pos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0F, 1.0F);
+ if (!TILLABLES.containsKey(clickedBlock)) level.playSound(null, pos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0F, 1.0F); // Purpur - Tool actionable options - force sound
if (!level.isClientSide()) {
action.accept(context);
if (player != null) {
}
- Predicate<UseOnContext> predicate = logicPair.getFirst();
- Consumer<UseOnContext> action = logicPair.getSecond();
+ Predicate<UseOnContext> predicate = tillable.condition().predicate();
+ Consumer<UseOnContext> action = (ctx) -> {
+ level.setBlock(pos, tillable.into().defaultBlockState(), 11);
+ tillable.drops().forEach((drop, chance) -> {
+ if (level.getRandom().nextDouble() < chance) {
+ Block.popResourceFromFace(level, pos, ctx.getClickedFace(), new ItemStack(drop));
+ }
+ });
+ };
+ // Purpur end - Tool actionable options
if (predicate.test(context)) {
Player player = context.getPlayer();
- level.playSound(player, pos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0F, 1.0F);
+ if (!TILLABLES.containsKey(clickedBlock)) level.playSound(null, pos, SoundEvents.HOE_TILL, SoundSource.BLOCKS, 1.0F, 1.0F); // Purpur - Tool actionable options - force sound
if (!level.isClientSide()) {
action.accept(context);
if (player != null) {

View File

@@ -1,21 +1,21 @@
--- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java
@@ -452,6 +_,7 @@
// revert back all captured blocks
for (org.bukkit.block.BlockState blockstate : blocks) {
((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).revertPlace();
+ ((org.bukkit.craftbukkit.block.CraftBlock) blockstate.getBlock()).getBlockState().getBlock().forgetPlacer(); // Purpur - Store placer on Block when placed
}
@@ -453,6 +_,7 @@
// revert back all captured blocks
for (org.bukkit.block.BlockState blockstate : blocks) {
((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).revertPlace();
+ ((org.bukkit.craftbukkit.block.CraftBlock) blockstate.getBlock()).getBlockState().getBlock().forgetPlacer(); // Purpur - Store placer on Block when placed
}
SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
@@ -475,6 +_,7 @@
if (!(block.getBlock() instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // Containers get placed automatically
block.onPlace(level, newPos, oldBlock, true, context);
}
+ block.getBlock().forgetPlacer(); // Purpur - Store placer on Block when placed
level.notifyAndUpdatePhysics(newPos, null, oldBlock, block, level.getBlockState(newPos), updateFlags, net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point
SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
@@ -476,6 +_,7 @@
if (!(block.getBlock() instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // Containers get placed automatically
block.onPlace(level, newPos, oldBlock, true, context);
}
+ block.getBlock().forgetPlacer(); // Purpur - Store placer on Block when placed
level.notifyAndUpdatePhysics(newPos, null, oldBlock, block, level.getBlockState(newPos), updateFlags, net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point
}
@@ -591,6 +_,26 @@
return this.isDamageableItem() && this.getDamageValue() > 0;
}
@@ -43,7 +43,7 @@
public int getDamageValue() {
return Mth.clamp(this.getOrDefault(DataComponents.DAMAGE, 0), 0, this.getMaxDamage());
}
@@ -1246,6 +_,12 @@
@@ -1254,6 +_,12 @@
public boolean isEnchanted() {
return !this.getOrDefault(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY).isEmpty();
}

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/item/ProjectileWeaponItem.java
+++ b/net/minecraft/world/item/ProjectileWeaponItem.java
@@ -114,6 +_,8 @@
arrowx.setCritArrow(true);
arrow.setCritArrow(true);
}
+ arrowx.setActualEnchantments(weapon.getEnchantments()); // Purpur - Add an option to fix MC-3304 projectile looting
+ arrow.setActualEnchantments(weapon.getEnchantments()); // Purpur - Add an option to fix MC-3304 projectile looting
+
return arrowx;
return arrow;
}

View File

@@ -1,17 +1,18 @@
--- a/net/minecraft/world/item/ShovelItem.java
+++ b/net/minecraft/world/item/ShovelItem.java
@@ -46,9 +_,12 @@
BlockState newState = FLATTENABLES.get(blockState.getBlock());
BlockState updatedState = null;
Runnable afterAction = null; // Paper
+ org.purpurmc.purpur.tool.Flattenable flattenable = level.purpurConfig.shovelFlattenables.get(blockState.getBlock()); // Purpur - Tool actionable options
if (newState != null && level.getBlockState(pos.above()).isAir()) {
- afterAction = () -> level.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper
- updatedState = newState;
@@ -47,9 +_,12 @@
BlockState newState = FLATTENABLES.get(blockState.getBlock());
BlockState updatedState = null;
Runnable afterAction = null; // Paper
- if (newState != null && level.getBlockState(pos.above()).isAir()) {
- afterAction = () -> level.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F); // Paper
- updatedState = newState;
+ org.purpurmc.purpur.tool.Flattenable flattenable = level.purpurConfig.shovelFlattenables.get(blockState.getBlock()); // Purpur - Tool actionable options
+ if (newState != null && level.getBlockState(pos.above()).isAir()) {
+ // Purpur start - Tool actionable options
+ afterAction = () -> {if (!FLATTENABLES.containsKey(blockState.getBlock())) level.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);}; // Paper
+ updatedState = flattenable.into().defaultBlockState();
+ afterAction = () -> {if (!FLATTENABLES.containsKey(blockState.getBlock())) level.playSound(player, pos, SoundEvents.SHOVEL_FLATTEN, SoundSource.BLOCKS, 1.0F, 1.0F);}; // Paper
+ updatedState = flattenable.into().defaultBlockState();
+ // Purpur end - Tool actionable options
} else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) {
afterAction = () -> { // Paper
if (!level.isClientSide()) {
} else if (blockState.getBlock() instanceof CampfireBlock && blockState.getValue(CampfireBlock.LIT)) {
afterAction = () -> { // Paper
if (!level.isClientSide()) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/SpawnEggItem.java
+++ b/net/minecraft/world/item/SpawnEggItem.java
@@ -62,6 +_,23 @@
@@ -64,6 +_,23 @@
return InteractionResult.FAIL;
} else {
if (level.paperConfig().entities.spawning.disableMobSpawnerSpawnEggTransformation) return InteractionResult.FAIL; // Paper - Allow disabling mob spawner spawn egg transformation

View File

@@ -1,19 +1,19 @@
--- a/net/minecraft/world/item/TridentItem.java
+++ b/net/minecraft/world/item/TridentItem.java
@@ -82,7 +_,7 @@
if (riptideStrength == 0.0F) {
ItemStack thrownItemStack = itemStack.copyWithCount(1); // Paper
Projectile.Delayed<ThrownTrident> tridentDelayed = Projectile.spawnProjectileFromRotationDelayed( // Paper - PlayerLaunchProjectileEvent(
- ThrownTrident::new, serverLevel, thrownItemStack, player, 0.0F, 2.5F, 1.0F
+ ThrownTrident::new, serverLevel, thrownItemStack, player, 0.0F, 2.5F, (float) serverLevel.purpurConfig.tridentProjectileOffset // Purpur - Projectile offset config
);
// Paper start - PlayerLaunchProjectileEvent
com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) tridentDelayed.projectile().getBukkitEntity());
@@ -92,6 +_,7 @@
return false;
}
ThrownTrident trident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent
+ trident.setActualEnchantments(itemStack.getEnchantments()); // Purpur - Add an option to fix MC-3304 projectile looting
if (event.shouldConsume()) {
thrownItemStack.hurtWithoutBreaking(1, player); // Paper - PlayerLaunchProjectileEvent - use thrownItemStack; pickup item damage
}
@@ -84,7 +_,7 @@
if (riptideStrength == 0.0F) {
ItemStack thrownItemStack = itemStack.copyWithCount(1); // Paper
Projectile.Delayed<ThrownTrident> tridentDelayed = Projectile.spawnProjectileFromRotationDelayed( // Paper - PlayerLaunchProjectileEvent(
- ThrownTrident::new, serverLevel, thrownItemStack, player, 0.0F, 2.5F, 1.0F
+ ThrownTrident::new, serverLevel, thrownItemStack, player, 0.0F, 2.5F, (float) serverLevel.purpurConfig.tridentProjectileOffset // Purpur - Projectile offset config
);
// Paper start - PlayerLaunchProjectileEvent
com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Projectile) tridentDelayed.projectile().getBukkitEntity());
@@ -94,6 +_,7 @@
return false;
}
ThrownTrident trident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent
+ trident.setActualEnchantments(itemStack.getEnchantments()); // Purpur - Add an option to fix MC-3304 projectile looting
if (event.shouldConsume()) {
thrownItemStack.hurtWithoutBreaking(1, player); // Paper - PlayerLaunchProjectileEvent - use thrownItemStack; pickup item damage
}

View File

@@ -8,7 +8,7 @@
public boolean isExact() {
return this.itemStacks != null;
@@ -86,6 +_,11 @@
@@ -88,6 +_,11 @@
return this.itemStacks.contains(input); // Paper - Improve exact choice recipe ingredients (hashing FTW!)
}
// CraftBukkit end