mojira.dev
MC-313518

The game crashes when a minecraft:trapezoid int provider has a negative plateau value

The minecraft:trapezoid integer provider only checks that plateau is less than or equal to max minus min, without validating that plateau is non negative. When a negative plateau value makes the computed upper bound negative, sampling the provider crashes the game.


Steps to reproduce

  • Create a creative world with the attached data pack enabled

  • Run the command: /give @s minecraft:stick[minecraft:block_transformer="test:trapezoid_crash"]

  • Right-click any block while holding the stick.


Observed results:
The game immediately crashes.

Expected results:
Negative plateau values are rejected during validation instead of crashing the game when the provider is sampled.


Note: This relates to MC-313484

Attachments

Comments 2

Thank you for helping us improve Minecraft! We saved your files:

[media]

Bug reproduced as steps instruct,

Stacktrace:
	at net.minecraft.world.level.levelgen.BitRandomSource.nextInt(BitRandomSource.java:20)
	at net.minecraft.util.Mth.randomBetweenInclusive(Mth.java:816)
	at net.minecraft.util.valueproviders.TrapezoidInt.sample(TrapezoidInt.java:47)
	at net.minecraft.world.level.levelgen.feature.stateproviders.RandomizedIntStateProvider.getState(RandomizedIntStateProvider.java:67)
	at net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider.getOptionalState(BlockStateProvider.java:52)
	at net.minecraft.core.component.BlockTransformer.transformBlock(BlockTransformer.java:66)
	at net.minecraft.world.item.Item.useOn(Item.java:548)
	at net.minecraft.world.item.ItemStack.useOn(ItemStack.java:386)
	at net.minecraft.client.multiplayer.MultiPlayerGameMode.performUseItemOn(MultiPlayerGameMode.java:371)
	at net.minecraft.client.multiplayer.MultiPlayerGameMode.lambda$useItemOn$0(MultiPlayerGameMode.java:326)
	at net.minecraft.client.multiplayer.MultiPlayerGameMode.startPrediction(MultiPlayerGameMode.java:287)
	at net.minecraft.client.multiplayer.MultiPlayerGameMode.useItemOn(MultiPlayerGameMode.java:325)
	at net.minecraft.client.Minecraft.startUseItem(Minecraft.java:1859)
	at net.minecraft.client.Minecraft.handleKeybinds(Minecraft.java:2087)

Vanilla 26.4 snapshot 10 with the DataPack attached in the report

BugTracker - BugTX

(Unassigned)

Confirmed

Platform

Important

Data Packs

26.3, 26.4 Snapshot 10

Retrieved