Merge pull request #1081 from ludovic111/fix/shears-carve-pumpkin

🤖 Agent: merged. Shears carve pumpkins (fixes #1067, reported by Tydragon). Integration proof (main + #1079 #1081 #1082 #1083 #1085 #1086 #1087), 2026-10-21: desktop parity 103/105; the 2 others (world_reopen, save_roundtrip) need a display and pass on the Mac mini. Verify passed.
This commit is contained in:
Ludovic Marie
2026-10-21 18:05:02 +02:00
committed by GitHub
7 changed files with 176 additions and 34 deletions
+40 -11
View File
@@ -1,20 +1,22 @@
#!/usr/bin/env python3
"""Compare a player's right click on a block with vanilla's, for items that are
both food and blocks (sweet and glow berries, carrots, potatoes), for sweet
berry bushes, for spawn eggs used on a monster spawner, for respawn anchors and
for beds in the Nether and the End.
berry bushes, for spawn eggs used on a monster spawner, for shears carving
pumpkins, for respawn anchors and for beds in the Nether and the End.
Every case has a block at the origin, something above it, and a player three
blocks south, survival or creative, hungry or full, sneaking or not, who
right-clicks the top face of the origin holding an item, sometimes with
another (or nothing) in the main hand and the item in the off hand, the
main hand trying first. Vanilla runs the real
`ServerPlayerGameMode.useItemOn` over the headless level of the dispenser
harness (`VanillaDispenserOracle.useItem`): the block's `useItemOn` and
`useWithoutItem` (picking a bush's berries, `SweetBerryBushBlock.useItemOn`
passing bone meal on), then `ItemStack.useOn` (`BlockItem.place` with its
`mayPlaceOn` rules, `BoneMealItem.useOn`, eating a consumable that could
not be placed, and `SpawnEggItem.useOn` setting a spawner's mob). Respawn
right-clicks the top face of the origin (for pumpkins, any face, turned any
way) holding an item, sometimes with another (or nothing) in the main hand
and the item in the off hand, the main hand trying first. Vanilla runs the
real `ServerPlayerGameMode.useItemOn` over the headless level of the
dispenser harness (`VanillaDispenserOracle.useItem`): the block's `useItemOn`
and `useWithoutItem` (picking a bush's berries, `SweetBerryBushBlock.useItemOn`
passing bone meal on, `PumpkinBlock.useItemOn` carving with shears and
dropping the seeds from the carved side), then `ItemStack.useOn`
(`BlockItem.place` with its `mayPlaceOn` rules, `BoneMealItem.useOn`, eating
a consumable that could not be placed, and `SpawnEggItem.useOn` setting a
spawner's mob). Respawn
anchors are charged with glowstone, set the respawn point in the Nether and
explode elsewhere (`RespawnAnchorBlock`, through the stand-in level's real
`ServerExplosion`, with water at the anchor). Respawn cases call
@@ -156,6 +158,27 @@ def anchor_case(rng, states, case):
case['cells'] = cells
def pumpkin_case(rng, states, case):
"""Shears (or something else) used on a pumpkin (`PumpkinBlock.useItemOn`):
any face, the player turned any way, worn shears (the stand-in player
has no entity id for the break event, so they keep one use)."""
cells = [[0, 0, 0, states.get(rng.choice(['pumpkin'] * 6 + ['carved_pumpkin', 'melon']))]]
if rng.random() < 0.3:
cells.append([0, 1, 0, states.get(rng.choice(['stone', 'snow', 'short_grass']))])
damage = rng.choice([0, 0, 0, 100, 236])
shears = d_plain('shears', 1) if damage == 0 else \
'{id:"minecraft:shears",count:1,components:{"minecraft:damage":%d}}' % damage
item = rng.choice([shears] * 6 + [d_plain('stick', 1), d_plain('pumpkin', 3), '-'])
use = {'item': item, 'creative': rng.random() < 0.2, 'sneaking': rng.random() < 0.15, 'food': 20,
'yaw': rng.choice([0, 30, 90, 135, 180, 200, 270, 315, -45, -100]),
'face': rng.choice(['up', 'up', 'down', 'north', 'south', 'west', 'east'])}
if rng.random() < 0.3:
# Shears in the off hand, something else or nothing in the main hand.
use.update(offhand=item, item=rng.choice(['-', '-', d_plain('stick', 1), d_plain('stone', 16)]))
case['use_item'] = use
case['cells'] = cells
def cases(facts, count, seed):
rng = random.Random(seed)
states = d.States(facts)
@@ -181,6 +204,12 @@ def cases(facts, count, seed):
case['mode'] = 'dispense'
yield case
continue
if rng.random() < 0.12:
pumpkin_case(rng, states, case)
case['items'] = []
case['mode'] = 'dispense'
yield case
continue
cells = []
item = rng.choice(ITEMS)
if rng.random() < 0.15: