forked from SteamWar/AdvancedScripts
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5953eb0640 | |||
| 4f98cc0267 | |||
| d7c9759d27 | |||
| 67f979a051 |
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.9.2'
|
||||
id 'fabric-loom' version '1.10.1'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
}
|
||||
|
||||
loom {
|
||||
|
||||
@ -4,11 +4,16 @@ org.gradle.parallel=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.20.6
|
||||
yarn_mappings=1.20.6+build.3
|
||||
loader_version=0.16.10
|
||||
|
||||
minecraft_version=1.21
|
||||
yarn_mappings=1.21+build.1
|
||||
loader_version=0.16.14
|
||||
loom_version=1.10-SNAPSHOT
|
||||
|
||||
# Fabric API
|
||||
fabric_version=0.100.3+1.21
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 2.1.0
|
||||
mod_version = 2.2.2
|
||||
maven_group = de.steamwar
|
||||
archives_base_name = AdvancedScripts
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@ -20,10 +20,12 @@
|
||||
package de.steamwar.advancedscripts;
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
|
||||
|
||||
public class AdvancedScripts implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
PayloadTypeRegistry.playC2S().register(KeyAction.ID, KeyAction.CODEC);
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import net.minecraft.network.packet.CustomPayload;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
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 PacketCodec<RegistryByteBuf, KeyAction> CODEC = PacketCodec.tuple(PacketCodecs.INTEGER, KeyAction::key, PacketCodecs.BYTE, KeyAction::action, PacketCodecs.INTEGER, KeyAction::modifiers, KeyAction::new);
|
||||
|
||||
@ -20,9 +20,9 @@
|
||||
package de.steamwar.advancedscripts.mixin;
|
||||
|
||||
import de.steamwar.advancedscripts.KeyAction;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -34,7 +34,7 @@ public class KeyboardMixin {
|
||||
public void sendKeyPress(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
|
||||
MinecraftClient client = ((Keyboard) (Object)this).client;
|
||||
if(client.currentScreen == null && action != 2) {
|
||||
client.getNetworkHandler().sendPacket(new CustomPayloadC2SPacket(new KeyAction(key, (byte) action, modifiers)));
|
||||
ClientPlayNetworking.send(new KeyAction(key, (byte) action, modifiers));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,16 +20,15 @@
|
||||
package de.steamwar.advancedscripts.screen;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import de.steamwar.advancedscripts.lexer.TokenTypeColors;
|
||||
import de.steamwar.advancedscripts.lexer.ScriptColorizer;
|
||||
import de.steamwar.advancedscripts.lexer.Token;
|
||||
import de.steamwar.advancedscripts.lexer.TokenTypeColors;
|
||||
import net.minecraft.client.font.TextHandler;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.ingame.BookEditScreen;
|
||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||
import net.minecraft.client.gui.widget.PressableWidget;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.util.NarratorManager;
|
||||
import net.minecraft.client.util.SelectionManager;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
@ -43,9 +42,11 @@ import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Hand;
|
||||
import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ScriptEditScreen extends Screen {
|
||||
|
||||
@ -72,7 +73,7 @@ public class ScriptEditScreen extends Screen {
|
||||
this.itemStack = itemStack;
|
||||
this.hand = hand;
|
||||
|
||||
List<RawFilteredPair<String>> pages = itemStack.get(DataComponentTypes.WRITABLE_BOOK_CONTENT).pages();
|
||||
List<RawFilteredPair<String>> pages = itemStack.getComponents().get(DataComponentTypes.WRITABLE_BOOK_CONTENT).pages();
|
||||
pages.forEach(stringRawFilteredPair -> {
|
||||
for (String s : stringRawFilteredPair.raw().split("\n")) {
|
||||
if (s.isEmpty()) {
|
||||
@ -155,11 +156,14 @@ public class ScriptEditScreen extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyBlur(float delta) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
setFocused(null);
|
||||
this.renderBackground(context, mouseX, mouseY, delta);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
context.fill(23, 23, this.width - 23, this.height - 63, TokenTypeColors.BACKGROUND);
|
||||
|
||||
@ -634,11 +638,13 @@ public class ScriptEditScreen extends Screen {
|
||||
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) {
|
||||
if (!pages.isEmpty()) {
|
||||
this.itemStack.set(DataComponentTypes.WRITABLE_BOOK_CONTENT, new WritableBookContentComponent(
|
||||
pages.stream().map(string -> new RawFilteredPair<String>(string, Optional.empty())).toList())
|
||||
);
|
||||
this.itemStack.set(DataComponentTypes.WRITABLE_BOOK_CONTENT, toContent(pages));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,8 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.11",
|
||||
"minecraft": ">=1.20.6",
|
||||
"java": ">=21"
|
||||
"java": ">=21",
|
||||
"fabric-api": "*"
|
||||
},
|
||||
"accessWidener" : "advancedscripts.accesswidener"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user