Create

Create

86M Downloads

Schematicannon should not require tall grass in item form

hlysine opened this issue ยท 2 comments

commented

Describe the Bug

image

Currently, if the build contains 2-block tall grass, the schematicannon prints that as a requirement directly. However, tall grass is not obtainable in item form in survival, so it should request for 2 pieces of short grass or short grass + bonemeal instead.

Reproduction Steps

  1. Build something with tall grass in it.
  2. Save it as a schematic.
  3. Load it into the schematicannon.
  4. Fail to build it in survival because tall grass cannot be obtained.

Expected Result

The schematicannon should request items that are obtainable in survival mode.

Screenshots and Videos

No response

Crash Report or Log

No response

Operating System

Windows 11

Mod Version

0.5.1f

Minecraft Version

1.20.1

Forge Version

47.2.5

Other Mods

No response

Additional Context

No response

commented

It seems normal for the blueprint to contain blocks that cannot be printed, and the additional work set up for this seems a bit cumbersome. This is not just a matter of grass. So the type should be "suggestion", not "error"!

commented

It is reasonable for creative-only blocks to be listed as-is because you are not supposed to build them in survival anyway. But items like large fern and tall grass are easily buildable in survival but not obtainable as items, so they are a different story.

There is already special handling in place for similar items like dirt path and farmland, so I think the same should be expected for large fern and tall grass.

The fix is not cumbersome at all. It is just a few lines in this section:

private static ItemRequirement defaultOf(BlockState state, BlockEntity be) {
Block block = state.getBlock();
if (block == Blocks.AIR)
return NONE;
Item item = block.asItem();
if (item == Items.AIR)
return INVALID;
// double slab needs two items
if (state.hasProperty(BlockStateProperties.SLAB_TYPE)
&& state.getValue(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE)
return new ItemRequirement(ItemUseType.CONSUME, new ItemStack(item, 2));
if (block instanceof TurtleEggBlock)
return new ItemRequirement(ItemUseType.CONSUME, new ItemStack(item, state.getValue(TurtleEggBlock.EGGS)
.intValue()));
if (block instanceof SeaPickleBlock)
return new ItemRequirement(ItemUseType.CONSUME, new ItemStack(item, state.getValue(SeaPickleBlock.PICKLES)
.intValue()));
if (block instanceof SnowLayerBlock)
return new ItemRequirement(ItemUseType.CONSUME, new ItemStack(item, state.getValue(SnowLayerBlock.LAYERS)
.intValue()));
if (block instanceof FarmBlock || block instanceof DirtPathBlock)
return new ItemRequirement(ItemUseType.CONSUME, Items.DIRT);
if (block instanceof AbstractBannerBlock && be instanceof BannerBlockEntity bannerBE)
return new ItemRequirement(new StrictNbtStackRequirement(bannerBE.getItem(), ItemUseType.CONSUME));
return new ItemRequirement(ItemUseType.CONSUME, item);
}