Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ClientConfiguration extends AbstractConfiguration
public final BooleanValue displayShared;
public final IntValue rendererLightLevel;
public final DoubleValue rendererTransparency;
public final BooleanValue scanToolScrolling;

/**
* Builds client configuration.
Expand Down Expand Up @@ -58,7 +59,12 @@ protected ClientConfiguration(final ForgeConfigSpec.Builder builder)
}
});

finishCategory(builder);
finishCategory(builder); // blueprint.renderer
finishCategory(builder); // blueprint

createCategory(builder, "gameplay");
scanToolScrolling = defineBoolean(builder, "scan_tool_scrolling", true);
finishCategory(builder); // gameplay
}

/**
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/com/ldtteam/structurize/items/ItemScanTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public InteractionResult onBlockPick(@NotNull final Player player,
{
// treat pick in air like mouse scrolling (just in case someone doesn't have a wheel)
final double delta = player.isShiftKeyDown() ? -1 : 1;
return onMouseScroll(player, stack, delta, ctrlKey);
return switchSlot(player, stack, delta < 0 ? ScanToolData::prevSlot : ScanToolData::nextSlot);
}

if (player.level().getBlockEntity(pos) instanceof CommandBlockEntity command)
Expand All @@ -300,26 +300,31 @@ public InteractionResult onMouseScroll(@NotNull final Player player,
final double delta,
final boolean ctrlKey)
{
if (player.level().isClientSide())
if (!player.level().isClientSide() || Structurize.getConfig().getClient().scanToolScrolling.get())
{
return InteractionResult.SUCCESS;
return switchSlot(player, stack, delta < 0 ? ScanToolData::prevSlot : ScanToolData::nextSlot);
}

switchSlot((ServerPlayer) player, stack, delta < 0 ? ScanToolData::prevSlot : ScanToolData::nextSlot);

return InteractionResult.SUCCESS;
return InteractionResult.PASS;
}

private void switchSlot(@NotNull final ServerPlayer player,
@NotNull final ItemStack stack,
@NotNull final Consumer<ScanToolData> action)
@NotNull
private InteractionResult switchSlot(@NotNull final Player player,
@NotNull final ItemStack stack,
@NotNull final Consumer<ScanToolData> action)
{
if (player.level().isClientSide())
{
return InteractionResult.SUCCESS;
}

final ScanToolData data = new ScanToolData(stack.getOrCreateTag());
saveSlot(data, stack, player);
action.accept(data);
final ScanToolData.Slot slot = loadSlot(data, stack);

Network.getNetwork().sendToPlayer(new ShowScanMessage(slot.getBox()), player);
Network.getNetwork().sendToPlayer(new ShowScanMessage(slot.getBox()), (ServerPlayer) player);
return InteractionResult.SUCCESS;
}

private void saveSlot(@NotNull final ScanToolData data,
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/structurize/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
"structurize.config.maxoperationspertick.comment": "Max world operations per tick (max blocks to place, remove, or replace).",
"structurize.config.render_placeholders_nice": "Render placeholders as target blocks",
"structurize.config.render_placeholders_nice.comment": "If disabled show placeholders as normal blocks, if enabled render: any (light) -> nothing, fluid (blue) -> dimension default fluid, solid (brown) -> worldgen block, tag (transparent) -> content block. Fluid and solid only work in singleplayer/for LAN owner, else it's just best guess. Currently without auto-updating",
"structurize.config.scan_tool_scrolling": "Scan Tool Scrolling",
"structurize.config.scan_tool_scrolling.comment": "Sneak+scroll on the hotbar switches scan tool slots",
"structurize.config.see_shared_previews": "See previews from others",
"structurize.config.see_shared_previews.comment": "Once enabled you will see previews from other players within sensible distance",
"structurize.config.share_previews": "Share previews to others",
Expand Down