Update to 1.21.4

This commit is contained in:
2025-01-19 17:13:27 +01:00
parent 3a26248296
commit 67f979a051
3 changed files with 10 additions and 9 deletions

View File

@ -4,11 +4,11 @@ org.gradle.parallel=true
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/develop # check these on https://fabricmc.net/develop
minecraft_version=1.20.6 minecraft_version=1.21.4
yarn_mappings=1.20.6+build.3 yarn_mappings=1.21.4+build.8
loader_version=0.16.10 loader_version=0.16.10
# Mod Properties # Mod Properties
mod_version = 2.1.0 mod_version = 2.2.0
maven_group = de.steamwar maven_group = de.steamwar
archives_base_name = AdvancedScripts archives_base_name = AdvancedScripts

View File

@ -7,7 +7,7 @@ import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public record KeyAction(int key, byte action, int modifiers) implements CustomPayload { public record KeyAction(int key, byte action, int modifiers) implements CustomPayload {
private static final Identifier channel = new Identifier("sw:hotkeys"); private static final Identifier channel = Identifier.of("sw:hotkeys");
public static final CustomPayload.Id<KeyAction> ID = new CustomPayload.Id<>(channel); public static final CustomPayload.Id<KeyAction> ID = new CustomPayload.Id<>(channel);
public static final PacketCodec<RegistryByteBuf, KeyAction> CODEC = PacketCodec.tuple(PacketCodecs.INTEGER, KeyAction::key, PacketCodecs.BYTE, KeyAction::action, PacketCodecs.INTEGER, KeyAction::modifiers, KeyAction::new); public static final PacketCodec<RegistryByteBuf, KeyAction> CODEC = PacketCodec.tuple(PacketCodecs.INTEGER, KeyAction::key, PacketCodecs.BYTE, KeyAction::action, PacketCodecs.INTEGER, KeyAction::modifiers, KeyAction::new);

View File

@ -102,7 +102,7 @@ public class ScriptEditScreen extends Screen {
this.addDrawableChild( this.addDrawableChild(
new Button(BOOK, this.width - 98 - 5, height - 20 - 5, () -> { new Button(BOOK, this.width - 98 - 5, height - 20 - 5, () -> {
finalizeBook(); finalizeBook();
this.client.setScreen(new BookEditScreen(player, itemStack, hand)); this.client.setScreen(new BookEditScreen(player, itemStack, hand, toContent(toPages())));
}) })
); );
} }
@ -159,7 +159,6 @@ public class ScriptEditScreen extends Screen {
public void render(DrawContext context, int mouseX, int mouseY, float delta) { public void render(DrawContext context, int mouseX, int mouseY, float delta) {
setFocused(null); setFocused(null);
this.renderBackground(context, mouseX, mouseY, delta); this.renderBackground(context, mouseX, mouseY, delta);
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
context.fill(23, 23, this.width - 23, this.height - 63, TokenTypeColors.BACKGROUND); context.fill(23, 23, this.width - 23, this.height - 63, TokenTypeColors.BACKGROUND);
@ -634,11 +633,13 @@ public class ScriptEditScreen extends Screen {
this.client.getNetworkHandler().sendPacket(new BookUpdateC2SPacket(i, pages, Optional.empty())); this.client.getNetworkHandler().sendPacket(new BookUpdateC2SPacket(i, pages, Optional.empty()));
} }
private WritableBookContentComponent toContent(List<String> pages) {
return new WritableBookContentComponent(pages.stream().map(string -> new RawFilteredPair<String>(string, Optional.empty())).toList());
}
private void writeNbtData(List<String> pages) { private void writeNbtData(List<String> pages) {
if (!pages.isEmpty()) { if (!pages.isEmpty()) {
this.itemStack.set(DataComponentTypes.WRITABLE_BOOK_CONTENT, new WritableBookContentComponent( this.itemStack.set(DataComponentTypes.WRITABLE_BOOK_CONTENT, toContent(pages));
pages.stream().map(string -> new RawFilteredPair<String>(string, Optional.empty())).toList())
);
} }
} }
} }