diff --git a/src/main/java/pers/solid/mishang/uc/item/CarryingToolItem.java b/src/main/java/pers/solid/mishang/uc/item/CarryingToolItem.java index 631ec482a..5783d824f 100644 --- a/src/main/java/pers/solid/mishang/uc/item/CarryingToolItem.java +++ b/src/main/java/pers/solid/mishang/uc/item/CarryingToolItem.java @@ -84,7 +84,8 @@ public static boolean hasHoldingEntity(@NotNull ItemStack stack) { @Contract(pure = true) public static @Nullable Block getHoldingBlock(@NotNull ItemStack stack) { final NbtCompound holdingBlockStateNbt = stack.getSubNbt("holdingBlockState"); - if (holdingBlockStateNbt == null) return null; + if (holdingBlockStateNbt == null) + return null; final Identifier identifier = Identifier.tryParse(holdingBlockStateNbt.getString("Name")); return Registries.BLOCK.get(identifier); } @@ -95,7 +96,8 @@ public static boolean hasHoldingEntity(@NotNull ItemStack stack) { if (holdingBlockStateNbt != null) { try { return NbtHelper.toBlockState(world.createCommandRegistryWrapper(RegistryKeys.BLOCK), holdingBlockStateNbt); - } catch (Exception e) { + } catch ( + Exception e) { return null; } } else { @@ -162,14 +164,15 @@ public static void setHoldingBlockState(@NotNull ItemStack stack, @Nullable Bloc private static MutableText getEntityName(@NotNull ItemStack stack) { final NbtCompound nbt = stack.getNbt(); - if (nbt == null) return TextBridge.empty(); + if (nbt == null) + return TextBridge.empty(); if (nbt.contains("holdingEntityName", NbtElement.STRING_TYPE)) { return Text.Serializer.fromJson(nbt.getString("holdingEntityName")); } else if (nbt.contains("holdingEntityType", NbtElement.STRING_TYPE)) { final Identifier holdingEntityType = Identifier.tryParse(nbt.getString("holdingEntityType")); return Registries.ENTITY_TYPE.containsId(holdingEntityType) ? Registries.ENTITY_TYPE.get(holdingEntityType).getName().copy() : TextBridge.literal(String.valueOf(holdingEntityType)); } else { - return Text.empty(); + return TextBridge.empty(); } } @@ -226,7 +229,8 @@ public ActionResult useOnBlock(ItemStack stack, PlayerEntity player, World world } else if (hasHoldingEntity(stack)) { if (world instanceof ServerWorld serverWorld) { final Entity entity = createHoldingEntity(stack, serverWorld, player); - if (entity == null) return ActionResult.PASS; + if (entity == null) + return ActionResult.PASS; final Vec3d pos = blockHitResult.getPos(); entity.updatePosition(pos.x, pos.y, pos.z); final boolean spawnEntity = world.spawnEntity(entity); @@ -272,7 +276,8 @@ private boolean hasAccess(PlayerEntity player, World world, boolean warn) { @Override public ActionResult beginAttackBlock(ItemStack stack, PlayerEntity player, World world, Hand hand, BlockPos pos, Direction direction, boolean fluidIncluded) { - if (!hasAccess(player, world, true)) return ActionResult.PASS; + if (!hasAccess(player, world, true)) + return ActionResult.PASS; final Block alreadyHolding = getHoldingBlock(stack); if (alreadyHolding != null && !player.isCreative()) { if (!world.isClient) { @@ -284,7 +289,8 @@ public ActionResult beginAttackBlock(ItemStack stack, PlayerEntity player, World } final boolean alreadyHoldingEntity = hasHoldingEntity(stack); if (alreadyHoldingEntity && !player.isCreative()) { - if (world.isClient) return ActionResult.CONSUME; + if (world.isClient) + return ActionResult.CONSUME; else { player.sendMessage(TextBridge.translatable("item.mishanguc.carrying_tool.message.no_picking", getEntityName(stack)).formatted(Formatting.RED), true); return ActionResult.FAIL; @@ -331,7 +337,8 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han if (holdingBlockState.getBlock() instanceof OperatorBlock && !user.hasPermissionLevel(2)) { return TypedActionResult.fail(stack); } - if (world.isClient) return TypedActionResult.success(use.getValue()); + if (world.isClient) + return TypedActionResult.success(use.getValue()); final FallingBlockEntity fallingBlockEntity = new FallingBlockEntity(EntityType.FALLING_BLOCK, world); NbtCompound nbt = new NbtCompound(); nbt.put("BlockState", stack.getSubNbt("holdingBlockState")); @@ -356,7 +363,8 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han } else if (hasHoldingEntity(stack)) { if (world instanceof ServerWorld serverWorld) { final Entity entity = createHoldingEntity(stack, serverWorld, user); - if (entity == null) return use; + if (entity == null) + return use; final Vec3d pos = user.getPos(); entity.updatePositionAndAngles(pos.x, pos.y, pos.z, user.getYaw(), user.getPitch()); entity.setVelocity(Vec3d.fromPolar(user.getPitch(), user.getYaw()).multiply(2).add(user.getVelocity())); @@ -382,7 +390,8 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han @Override public @NotNull ActionResult attackEntityCallback(PlayerEntity player, World world, Hand hand, Entity entity, @Nullable EntityHitResult hitResult) { - if (!hasAccess(player, world, true) || player.isSpectator()) return ActionResult.PASS; + if (!hasAccess(player, world, true) || player.isSpectator()) + return ActionResult.PASS; final ItemStack stack = player.getStackInHand(hand); if (entity instanceof PlayerEntity) { if (world.isClient) { @@ -392,13 +401,15 @@ public TypedActionResult use(World world, PlayerEntity user, Hand han return ActionResult.FAIL; } } else if (hasHoldingEntity(stack) && !player.isCreative()) { - if (world.isClient) return ActionResult.SUCCESS; + if (world.isClient) + return ActionResult.SUCCESS; else { player.sendMessage(TextBridge.translatable("item.mishanguc.carrying_tool.message.no_picking", getEntityName(stack)).formatted(Formatting.RED), true); return ActionResult.FAIL; } } else if (hasHoldingBlockState(stack) && !player.isCreative()) { - if (world.isClient) return ActionResult.SUCCESS; + if (world.isClient) + return ActionResult.SUCCESS; else { player.sendMessage(TextBridge.translatable("item.mishanguc.carrying_tool.message.no_picking", Optional.ofNullable(getHoldingBlock(stack)).map(Block::getName).orElse(TextBridge.empty())).formatted(Formatting.RED), true); return ActionResult.FAIL; @@ -441,7 +452,8 @@ public void writeItemModel(RuntimeResourcePack pack) { @Environment(EnvType.CLIENT) @Override public boolean renderBlockOutline(PlayerEntity player, ItemStack itemStack, WorldRenderContext worldRenderContext, WorldRenderContext.BlockOutlineContext blockOutlineContext, Hand hand) { - if (!hasAccess(player, worldRenderContext.world(), true)) return true; + if (!hasAccess(player, worldRenderContext.world(), true)) + return true; final MinecraftClient client = MinecraftClient.getInstance(); final VertexConsumerProvider consumers = worldRenderContext.consumers(); if (consumers == null) { @@ -487,12 +499,14 @@ public boolean renderBlockOutline(PlayerEntity player, ItemStack itemStack, Worl @Override public void renderBeforeOutline(WorldRenderContext context, HitResult hitResult, ClientPlayerEntity player, Hand hand) { // 只在使用主手且有权限时持有此物品时进行渲染。 - if (hand != Hand.MAIN_HAND || player.isSpectator() || !hasAccess(player, context.world(), true)) return; + if (hand != Hand.MAIN_HAND || player.isSpectator() || !hasAccess(player, context.world(), true)) + return; final ItemStack stack = player.getMainHandStack(); final NbtCompound nbt = stack.getNbt(); final VertexConsumerProvider consumers = context.consumers(); final MatrixStack matrices = context.matrixStack(); - if (consumers == null) return; + if (consumers == null) + return; final VertexConsumer vertexConsumer = consumers.getBuffer(RenderLayer.getLines()); final Vec3d cameraPos = context.camera().getPos(); if (hitResult.getType() == HitResult.Type.BLOCK && hasHoldingEntity(stack) && nbt != null) { @@ -501,7 +515,8 @@ public void renderBeforeOutline(WorldRenderContext context, HitResult hitResult, final Vec3d pos = hitResult.getPos(); WorldRendererInvoker.drawCuboidShapeOutline(matrices, vertexConsumer, VoxelShapes.cuboid(pos.x - width / 2, pos.y, pos.z - width / 2, pos.x + width / 2, pos.y + height, pos.z + width / 2), -cameraPos.x, -cameraPos.y, -cameraPos.z, 0, 1, 1, 0.8f); } - if (!player.isCreative() && (hasHoldingBlockState(stack) || hasHoldingEntity(stack))) return; + if (!player.isCreative() && (hasHoldingBlockState(stack) || hasHoldingEntity(stack))) + return; if (hitResult instanceof EntityHitResult entityHitResult) { final Entity entity = entityHitResult.getEntity(); WorldRendererInvoker.drawCuboidShapeOutline(matrices, vertexConsumer, VoxelShapes.cuboid(entity.getBoundingBox()), -cameraPos.x, -cameraPos.y, -cameraPos.z, 1.0f, 0f, 0f, 0.8f); diff --git a/src/main/java/pers/solid/mishang/uc/item/GrowthToolItem.java b/src/main/java/pers/solid/mishang/uc/item/GrowthToolItem.java index 093af0264..9733e492c 100644 --- a/src/main/java/pers/solid/mishang/uc/item/GrowthToolItem.java +++ b/src/main/java/pers/solid/mishang/uc/item/GrowthToolItem.java @@ -99,10 +99,10 @@ public static int apply(World world, Vec3d center, boolean isPositive) { final int prevSize = slimeEntity.getSize(); if (isPositive) { slimeEntity.setSize(Math.min(prevSize * 2, Math.max(prevSize, 16)), false); - createParticle(world, entity.getPos(), isPositive); } else { slimeEntity.setSize(prevSize / 2, false); } + createParticle(world, entity.getPos(), isPositive); damage += 1; } else if (entity instanceof MobEntity mobEntity) { if (mobEntity.isBaby() == isPositive) { diff --git a/src/main/java/pers/solid/mishang/uc/screen/AbstractSignBlockEditScreen.java b/src/main/java/pers/solid/mishang/uc/screen/AbstractSignBlockEditScreen.java index 4907bd395..0bb3b9475 100644 --- a/src/main/java/pers/solid/mishang/uc/screen/AbstractSignBlockEditScreen.java +++ b/src/main/java/pers/solid/mishang/uc/screen/AbstractSignBlockEditScreen.java @@ -118,7 +118,8 @@ public abstract class AbstractSignBlockEditScreen * 上方第一行:移除文本按钮 */ public final ButtonWidget removeTextButton = new ButtonWidget.Builder(TextBridge.translatable("message.mishanguc.remove_text"), button -> { - if (selectedTextField == null) return; + if (selectedTextField == null) + return; int index = textFieldListWidget.children().indexOf(textFieldListWidget.children().stream().filter(entry -> entry.textFieldWidget == selectedTextField).findFirst().orElse(null)); if (index != -1) { removeTextField(index); @@ -130,11 +131,13 @@ public abstract class AbstractSignBlockEditScreen * 上方第一行:上移按钮。 */ public final ButtonWidget moveUpButton = new ButtonWidget.Builder(TextBridge.translatable("message.mishanguc.moveUp"), button -> { - if (selectedTextField == null) return; + if (selectedTextField == null) + return; int i = textFieldListWidget.children().indexOf(textFieldListWidget.getSelectedOrNull()); final TextContext textContext = AbstractSignBlockEditScreen.this.textContextsEditing.get(i); removeTextField(i); - if (i > 0) i--; + if (i > 0) + i--; addTextField(i, textContext, false); }).dimensions(this.width - 20, 5, 80, 20).tooltip(Tooltip.of(TextBridge.translatable("message.mishanguc.moveUp.description").append(ScreenTexts.LINE_BREAK).append(MishangUtils.describeShortcut(TextBridge.literal("Ctrl + Shift + ").append(TextBridge.translatable("key.keyboard.up")))))).build(); @@ -142,11 +145,13 @@ public abstract class AbstractSignBlockEditScreen * 上方第一行:下移按钮。 */ public final ButtonWidget moveDownButton = new ButtonWidget.Builder(TextBridge.translatable("message.mishanguc.moveDown"), button -> { - if (selectedTextField == null) return; + if (selectedTextField == null) + return; int i = textFieldListWidget.children().indexOf(textFieldListWidget.getSelectedOrNull()); final TextContext textContext = AbstractSignBlockEditScreen.this.textContextsEditing.get(i); removeTextField(i); - if (i < textFieldListWidget.children().size()) i++; + if (i < textFieldListWidget.children().size()) + i++; addTextField(i, textContext, false); }).dimensions(this.width - 20, 5, 80, 20).tooltip(Tooltip.of(TextBridge.translatable("message.mishanguc.moveDown.description").append(ScreenTexts.LINE_BREAK).append(MishangUtils.describeShortcut(TextBridge.literal("Ctrl + Shift + ").append(TextBridge.translatable("key.keyboard.down")))))).build(); @@ -232,7 +237,8 @@ public abstract class AbstractSignBlockEditScreen */ public final BooleanButtonWidget boldButton = new BooleanButtonWidget(this.width / 2 - 200, this.height - 50, 20, 20, TextBridge.translatable("message.mishanguc.bold"), button -> selectedTextContext == null ? null : selectedTextContext.bold, b -> { changed = true; - if (selectedTextContext != null) selectedTextContext.bold = b; + if (selectedTextContext != null) + selectedTextContext.bold = b; }, EMPTY_PRESS_ACTION) .setRenderedName(TextBridge.literal("B").formatted(Formatting.BOLD)); @@ -241,40 +247,44 @@ public abstract class AbstractSignBlockEditScreen */ public final BooleanButtonWidget italicButton = new BooleanButtonWidget(this.width / 2 - 180, this.height - 50, 20, 20, TextBridge.translatable("message.mishanguc.italic"), button -> selectedTextContext == null ? null : selectedTextContext.italic, b -> { changed = true; - if (selectedTextContext != null) selectedTextContext.italic = b; + if (selectedTextContext != null) + selectedTextContext.italic = b; }, EMPTY_PRESS_ACTION) .setRenderedName(TextBridge.literal("I").formatted(Formatting.ITALIC)) - .setKeyboardShortcut(Text.literal("Ctrl + I")); + .setKeyboardShortcut(TextBridge.literal("Ctrl + I")); /** * 下方第一行:下划线按钮。 */ public final BooleanButtonWidget underlineButton = new BooleanButtonWidget(this.width / 2 - 160, this.height - 50, 20, 20, TextBridge.translatable("message.mishanguc.underline"), button -> selectedTextContext == null ? null : selectedTextContext.underline, b -> { changed = true; - if (selectedTextContext != null) selectedTextContext.underline = b; + if (selectedTextContext != null) + selectedTextContext.underline = b; }, EMPTY_PRESS_ACTION) .setRenderedName(TextBridge.literal("U").formatted(Formatting.UNDERLINE)) - .setKeyboardShortcut(Text.literal("Ctrl + U")); + .setKeyboardShortcut(TextBridge.literal("Ctrl + U")); /** * 下方第一行:删除线按钮。 */ public final BooleanButtonWidget strikethroughButton = new BooleanButtonWidget(this.width / 2 - 140, this.height - 50, 20, 20, TextBridge.translatable("message.mishanguc.strikethrough"), button -> selectedTextContext == null ? null : selectedTextContext.strikethrough, b -> { changed = true; - if (selectedTextContext != null) selectedTextContext.strikethrough = b; + if (selectedTextContext != null) + selectedTextContext.strikethrough = b; }, EMPTY_PRESS_ACTION) .setRenderedName(TextBridge.literal("S").formatted(Formatting.STRIKETHROUGH)) - .setKeyboardShortcut(Text.literal("Ctrl + S")); + .setKeyboardShortcut(TextBridge.literal("Ctrl + S")); /** * 下方第一行:随机文字(obfuscated)按钮。 */ public final BooleanButtonWidget obfuscatedButton = new BooleanButtonWidget(this.width / 2 - 120, this.height - 50, 20, 20, TextBridge.translatable("message.mishanguc.obfuscated"), button -> selectedTextContext == null ? null : selectedTextContext.obfuscated, b -> { changed = true; - if (selectedTextContext != null) selectedTextContext.obfuscated = b; + if (selectedTextContext != null) + selectedTextContext.obfuscated = b; }, EMPTY_PRESS_ACTION) .setRenderedName(TextBridge.literal("O").formatted(Formatting.OBFUSCATED)) - .setKeyboardShortcut(Text.literal("Ctrl + O")); + .setKeyboardShortcut(TextBridge.literal("Ctrl + O")); /** @@ -282,7 +292,8 @@ public abstract class AbstractSignBlockEditScreen */ public final BooleanButtonWidget shadeButton = new BooleanButtonWidget(this.width / 2 - 100, this.height - 50, 35, 20, TextBridge.translatable("message.mishanguc.shade"), button -> selectedTextContext == null ? null : selectedTextContext.shadow, b -> { changed = true; - if (selectedTextContext != null) selectedTextContext.shadow = b; + if (selectedTextContext != null) + selectedTextContext.shadow = b; }, EMPTY_PRESS_ACTION) .setTooltip(TextBridge.translatable("message.mishanguc.shade.description")); @@ -405,7 +416,8 @@ public abstract class AbstractSignBlockEditScreen return TextBridge.translatable("message.mishanguc.outline_color.relate", MishangUtils.describeColor(selectedTextContext.outlineColor, TextBridge.translatable("message.mishanguc.outline_color.relate.$1")), MishangUtils.describeColor(color.getSignColor(), TextBridge.translatable("color.minecraft." + color.asString()))); } else { final DyeColor color = DyeColor.byId((int) colorId); - if (color == null) return TextBridge.translatable("message.mishanguc.outline_color.none"); + if (color == null) + return TextBridge.translatable("message.mishanguc.outline_color.none"); return MishangUtils.describeColor(color.getSignColor(), TextBridge.translatable("color.minecraft." + color.asString())); } }).setRenderedNameSupplier((value, valueText) -> { @@ -433,7 +445,8 @@ public abstract class AbstractSignBlockEditScreen @ApiStatus.AvailableSince("0.1.6") public final FloatButtonWidget rotationXButton = new FloatButtonWidget(this.width / 2 + 40, this.height - 50, 40, 20, TextBridge.translatable("message.mishanguc.rotationX"), button -> selectedTextContext != null ? selectedTextContext.rotationX : null, value -> { changed = true; - if (selectedTextContext != null) selectedTextContext.rotationX = value; + if (selectedTextContext != null) + selectedTextContext.rotationX = value; }, EMPTY_PRESS_ACTION); /** @@ -442,7 +455,8 @@ public abstract class AbstractSignBlockEditScreen @ApiStatus.AvailableSince("0.1.6") public final FloatButtonWidget rotationYButton = new FloatButtonWidget(this.width / 2 + 40, this.height - 50, 40, 20, TextBridge.translatable("message.mishanguc.rotationY"), button -> selectedTextContext != null ? selectedTextContext.rotationY : null, value -> { changed = true; - if (selectedTextContext != null) selectedTextContext.rotationY = value; + if (selectedTextContext != null) + selectedTextContext.rotationY = value; }, EMPTY_PRESS_ACTION); /** @@ -451,7 +465,8 @@ public abstract class AbstractSignBlockEditScreen @ApiStatus.AvailableSince("0.1.6") public final FloatButtonWidget rotationZButton = new FloatButtonWidget(this.width / 2 + 40, this.height - 50, 40, 20, TextBridge.translatable("message.mishanguc.rotationZ"), button -> selectedTextContext != null ? selectedTextContext.rotationZ : null, value -> { changed = true; - if (selectedTextContext != null) selectedTextContext.rotationZ = value; + if (selectedTextContext != null) + selectedTextContext.rotationZ = value; }, EMPTY_PRESS_ACTION); /** @@ -499,7 +514,8 @@ public abstract class AbstractSignBlockEditScreen */ public final BooleanButtonWidget seeThroughButton = new BooleanButtonWidget(0, 0, 60, 20, TextBridge.translatable("message.mishanguc.see_through"), button -> selectedTextContext == null ? null : selectedTextContext.seeThrough, b -> { changed = true; - if (selectedTextContext != null) selectedTextContext.seeThrough = b; + if (selectedTextContext != null) + selectedTextContext.seeThrough = b; }, EMPTY_PRESS_ACTION); /** @@ -507,7 +523,8 @@ public abstract class AbstractSignBlockEditScreen */ public final BooleanButtonWidget absoluteButton = new BooleanButtonWidget(0, 0, 50, 20, TextBridge.translatable("message.mishanguc.absolute"), button -> selectedTextContext != null ? selectedTextContext.absolute : null, b -> { changed = true; - if (selectedTextContext != null) selectedTextContext.absolute = b; + if (selectedTextContext != null) + selectedTextContext.absolute = b; }, EMPTY_PRESS_ACTION) .setTooltip(TextBridge.translatable("message.mishanguc.absolute.description")); @@ -572,9 +589,11 @@ public abstract class AbstractSignBlockEditScreen public final ButtonWidget customValueCancelButton = ButtonWidget.builder(ScreenTexts.CANCEL, button -> { if (customValueFor != null) { if (customValueFor == colorButton) { - if (selectedTextContext != null) selectedTextContext.color = customValueBeforeChange.intValue(); + if (selectedTextContext != null) + selectedTextContext.color = customValueBeforeChange.intValue(); } else if (customValueFor == outlineColorButton) { - if (selectedTextContext != null) selectedTextContext.outlineColor = customValueBeforeChange.intValue(); + if (selectedTextContext != null) + selectedTextContext.outlineColor = customValueBeforeChange.intValue(); } else { customValueFor.setValue(customValueBeforeChange == null ? customValueFor.defaultValue : customValueBeforeChange); } @@ -628,9 +647,9 @@ public abstract class AbstractSignBlockEditScreen /** * 下方第三行:隐藏界面 */ - public final ButtonWidget hideButton = new BooleanButtonWidget(0, height - 25, 40, 20, Text.translatable("message.mishanguc.hide_gui"), booleanButtonWidget -> hidden, value -> hidden = value, EMPTY_PRESS_ACTION) + public final ButtonWidget hideButton = new BooleanButtonWidget(0, height - 25, 40, 20, TextBridge.translatable("message.mishanguc.hide_gui"), booleanButtonWidget -> hidden, value -> hidden = value, EMPTY_PRESS_ACTION) .setRenderedNameSupplier(value -> Boolean.TRUE.equals(value) ? TextBridge.translatable("message.mishanguc.hide_gui.show") : TextBridge.translatable("message.mishanguc.hide_gui.hide")) - .setTooltipSupplier(value -> Boolean.TRUE.equals(value) ? null : Text.translatable("message.mishanguc.hide_gui.tooltip")); + .setTooltipSupplier(value -> Boolean.TRUE.equals(value) ? null : TextBridge.translatable("message.mishanguc.hide_gui.tooltip")); public final ClickableWidget[] toolboxTop = new ClickableWidget[]{addTextButton, removeTextButton, moveUpButton, moveDownButton, rearrangeButton}; public final ClickableWidget[] toolbox1 = new ClickableWidget[]{boldButton, italicButton, underlineButton, strikethroughButton, obfuscatedButton, shadeButton, sizeButton, offsetXButton, offsetYButton, offsetZButton, colorButton, outlineColorButton}; @@ -747,7 +766,7 @@ protected void initTextHolders() { this.addDrawableChild(applyRightArrowTemplateButton); } - public static final Text HIDDEN_TEXT_NOTE = Text.translatable("message.mishanguc.hide_gui.note"); + public static final Text HIDDEN_TEXT_NOTE = TextBridge.translatable("message.mishanguc.hide_gui.note"); @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { @@ -836,7 +855,8 @@ public void addTextField(int index, @NotNull TextContext textContext, boolean is case "json": try { textContext1.text = Text.Serializer.fromLenientJson(value); - } catch (JsonParseException e) { + } catch ( + JsonParseException e) { // 如果文本有问题,则不执行操作。 } break; @@ -933,7 +953,8 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) { continue; } } - if (!element.mouseClicked(mouseX, mouseY, button)) continue; + if (!element.mouseClicked(mouseX, mouseY, button)) + continue; if (element == textFieldListWidget || element instanceof TextFieldWidget) { this.setFocused(element); } else { @@ -980,7 +1001,8 @@ private void customValueStartAccepting(FloatButtonWidget floatButtonWidget) { customValueTextField.setEditableColor(16733525); } else { customValueTextField.setEditableColor(16777215); - if (selectedTextContext != null) selectedTextContext.color = parse.getRgb(); + if (selectedTextContext != null) + selectedTextContext.color = parse.getRgb(); } }); } else if (floatButtonWidget == outlineColorButton) { @@ -1018,7 +1040,8 @@ private void customValueStartAccepting(FloatButtonWidget floatButtonWidget) { customValueTextField.setEditableColor(16733525); } else { customValueTextField.setEditableColor(16777215); - if (selectedTextContext != null) selectedTextContext.outlineColor = parse.getRgb(); + if (selectedTextContext != null) + selectedTextContext.outlineColor = parse.getRgb(); } }); } else { @@ -1033,7 +1056,8 @@ private void customValueStartAccepting(FloatButtonWidget floatButtonWidget) { final float value = Float.parseFloat(s); customValueTextField.setEditableColor(16777215); floatButtonWidget.setValue(value); - } catch (NumberFormatException e) { + } catch ( + NumberFormatException e) { customValueTextField.setEditableColor(16733525); } }); diff --git a/src/main/java/pers/solid/mishang/uc/screen/TextFieldListWidget.java b/src/main/java/pers/solid/mishang/uc/screen/TextFieldListWidget.java index 197312f40..a38038d70 100644 --- a/src/main/java/pers/solid/mishang/uc/screen/TextFieldListWidget.java +++ b/src/main/java/pers/solid/mishang/uc/screen/TextFieldListWidget.java @@ -153,8 +153,10 @@ public Entry(@NotNull TextFieldWidget textFieldWidget) { @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof TextFieldListWidget.Entry entry)) return false; + if (this == o) + return true; + if (!(o instanceof TextFieldListWidget.Entry entry)) + return false; return textFieldWidget.equals(entry.textFieldWidget); } @@ -206,7 +208,8 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) { final int index = children.indexOf(getSelectedOrNull()); if (index + 1 < children.size()) TextFieldListWidget.this.setFocused(children.get(index + 1)); - else if (children.size() > 0) signBlockEditScreen.addTextField(index + 1); + else if (children.size() > 0) + signBlockEditScreen.addTextField(index + 1); } case GLFW.GLFW_KEY_BACKSPACE -> { final TextFieldListWidget.Entry focused = TextFieldListWidget.this.getSelectedOrNull();