Update to 1.20.6
This commit is contained in:
26
build.gradle
26
build.gradle
@ -1,11 +1,8 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.0-SNAPSHOT'
|
id 'fabric-loom' version '1.9.2'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
|
||||||
|
|
||||||
archivesBaseName = project.archives_base_name
|
archivesBaseName = project.archives_base_name
|
||||||
version = project.mod_version
|
version = project.mod_version
|
||||||
group = project.maven_group
|
group = project.maven_group
|
||||||
@ -32,8 +29,27 @@ processResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def targetJavaVersion = 21
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
it.options.release = 17
|
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||||
|
// this fixes some edge cases with special characters not displaying correctly
|
||||||
|
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||||
|
// If Javadoc is generated, this must be specified in that task too.
|
||||||
|
it.options.encoding = "UTF-8"
|
||||||
|
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||||
|
it.options.release.set(targetJavaVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||||
|
if (JavaVersion.current() < javaVersion) {
|
||||||
|
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
|
||||||
|
}
|
||||||
|
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||||
|
// if it is present.
|
||||||
|
// If you remove this line, sources will not be generated.
|
||||||
|
withSourcesJar()
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
|||||||
@ -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.19.3
|
minecraft_version=1.20.6
|
||||||
yarn_mappings=1.19.3+build.1
|
yarn_mappings=1.20.6+build.3
|
||||||
loader_version=0.14.11
|
loader_version=0.16.10
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 2.0.0
|
mod_version = 2.1.0
|
||||||
maven_group = de.steamwar
|
maven_group = de.steamwar
|
||||||
archives_base_name = AdvancedScripts
|
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
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@ -4,7 +4,6 @@ pluginManagement {
|
|||||||
name = 'Fabric'
|
name = 'Fabric'
|
||||||
url = 'https://maven.fabricmc.net/'
|
url = 'https://maven.fabricmc.net/'
|
||||||
}
|
}
|
||||||
mavenCentral()
|
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
src/main/java/de/steamwar/advancedscripts/KeyAction.java
Normal file
19
src/main/java/de/steamwar/advancedscripts/KeyAction.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package de.steamwar.advancedscripts;
|
||||||
|
|
||||||
|
import net.minecraft.network.RegistryByteBuf;
|
||||||
|
import net.minecraft.network.codec.PacketCodec;
|
||||||
|
import net.minecraft.network.codec.PacketCodecs;
|
||||||
|
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");
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Id<? extends CustomPayload> getId() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -19,35 +19,22 @@
|
|||||||
|
|
||||||
package de.steamwar.advancedscripts.mixin;
|
package de.steamwar.advancedscripts.mixin;
|
||||||
|
|
||||||
import io.netty.buffer.Unpooled;
|
import de.steamwar.advancedscripts.KeyAction;
|
||||||
import net.minecraft.client.Keyboard;
|
import net.minecraft.client.Keyboard;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.network.PacketByteBuf;
|
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket;
|
||||||
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(Keyboard.class)
|
@Mixin(Keyboard.class)
|
||||||
public class KeyboardMixin {
|
public class KeyboardMixin {
|
||||||
|
|
||||||
@Unique
|
|
||||||
private static final Identifier channel = new Identifier("sw:hotkeys");
|
|
||||||
|
|
||||||
@Inject(method = "onKey", at = @At("HEAD"))
|
@Inject(method = "onKey", at = @At("HEAD"))
|
||||||
public void sendKeyPress(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
|
public void sendKeyPress(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
|
||||||
MinecraftClient client = ((Keyboard) (Object)this).client;
|
MinecraftClient client = ((Keyboard) (Object)this).client;
|
||||||
if(client.currentScreen == null && action != 2) {
|
if(client.currentScreen == null && action != 2) {
|
||||||
PacketByteBuf byteBuf = new PacketByteBuf(Unpooled.buffer());
|
client.getNetworkHandler().sendPacket(new CustomPayloadC2SPacket(new KeyAction(key, (byte) action, modifiers)));
|
||||||
byteBuf.writeInt(key);
|
|
||||||
byteBuf.writeByte(action);
|
|
||||||
byteBuf.writeInt(modifiers);
|
|
||||||
CustomPayloadC2SPacket customPayloadC2SPacket = new CustomPayloadC2SPacket(channel,byteBuf);
|
|
||||||
client.getNetworkHandler().sendPacket(customPayloadC2SPacket);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,22 +24,20 @@ import de.steamwar.advancedscripts.lexer.TokenTypeColors;
|
|||||||
import de.steamwar.advancedscripts.lexer.ScriptColorizer;
|
import de.steamwar.advancedscripts.lexer.ScriptColorizer;
|
||||||
import de.steamwar.advancedscripts.lexer.Token;
|
import de.steamwar.advancedscripts.lexer.Token;
|
||||||
import net.minecraft.client.font.TextHandler;
|
import net.minecraft.client.font.TextHandler;
|
||||||
import net.minecraft.client.gui.DrawableHelper;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.ingame.BookEditScreen;
|
import net.minecraft.client.gui.screen.ingame.BookEditScreen;
|
||||||
import net.minecraft.client.gui.screen.ingame.BookScreen;
|
|
||||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||||
import net.minecraft.client.gui.widget.PressableWidget;
|
import net.minecraft.client.gui.widget.PressableWidget;
|
||||||
import net.minecraft.client.render.GameRenderer;
|
import net.minecraft.client.render.GameRenderer;
|
||||||
import net.minecraft.client.util.NarratorManager;
|
import net.minecraft.client.util.NarratorManager;
|
||||||
import net.minecraft.client.util.SelectionManager;
|
import net.minecraft.client.util.SelectionManager;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.component.DataComponentTypes;
|
||||||
|
import net.minecraft.component.type.WritableBookContentComponent;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
|
||||||
import net.minecraft.nbt.NbtList;
|
|
||||||
import net.minecraft.nbt.NbtString;
|
|
||||||
import net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket;
|
import net.minecraft.network.packet.c2s.play.BookUpdateC2SPacket;
|
||||||
|
import net.minecraft.text.RawFilteredPair;
|
||||||
import net.minecraft.text.Style;
|
import net.minecraft.text.Style;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
@ -47,6 +45,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ScriptEditScreen extends Screen {
|
public class ScriptEditScreen extends Screen {
|
||||||
|
|
||||||
@ -73,19 +72,17 @@ public class ScriptEditScreen extends Screen {
|
|||||||
this.itemStack = itemStack;
|
this.itemStack = itemStack;
|
||||||
this.hand = hand;
|
this.hand = hand;
|
||||||
|
|
||||||
NbtCompound nbtCompound = itemStack.getNbt();
|
List<RawFilteredPair<String>> pages = itemStack.get(DataComponentTypes.WRITABLE_BOOK_CONTENT).pages();
|
||||||
if (nbtCompound != null) {
|
pages.forEach(stringRawFilteredPair -> {
|
||||||
BookScreen.filterPages(nbtCompound, s -> {
|
for (String s : stringRawFilteredPair.raw().split("\n")) {
|
||||||
String[] split = s.split("\n");
|
if (s.isEmpty()) {
|
||||||
for (String s1 : split) {
|
lines.add("");
|
||||||
if (s1.equals(" ")) {
|
} else {
|
||||||
lines.add("");
|
lines.add(s);
|
||||||
} else {
|
|
||||||
lines.add(s1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
if (lines.isEmpty()) {
|
if (lines.isEmpty()) {
|
||||||
lines.add("");
|
lines.add("");
|
||||||
}
|
}
|
||||||
@ -159,12 +156,12 @@ public class ScriptEditScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||||
setFocused(null);
|
setFocused(null);
|
||||||
this.renderBackground(matrices);
|
this.renderBackground(context, mouseX, mouseY, delta);
|
||||||
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
||||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
fill(matrices, 23, 23, this.width - 23, this.height - 63, TokenTypeColors.BACKGROUND);
|
context.fill(23, 23, this.width - 23, this.height - 63, TokenTypeColors.BACKGROUND);
|
||||||
|
|
||||||
int lineNumberLength = textRenderer.getWidth(lines.size() + "");
|
int lineNumberLength = textRenderer.getWidth(lines.size() + "");
|
||||||
|
|
||||||
@ -185,15 +182,15 @@ public class ScriptEditScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (s.isEmpty() && i == cursorY) {
|
if (s.isEmpty() && i == cursorY) {
|
||||||
drawCursor(matrices, 25 + lineNumberLength + 5, lineNumber.getValue() * 9 + 25, true);
|
drawCursor(context, 25 + lineNumberLength + 5, lineNumber.getValue() * 9 + 25, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line number
|
// Line number
|
||||||
int height = this.textRenderer.getWrappedLinesHeight(s, this.width - 50 - lineNumberLength - 5);
|
int height = this.textRenderer.getWrappedLinesHeight(s, this.width - 50 - lineNumberLength - 5);
|
||||||
if (lineTooLong(s)) {
|
if (lineTooLong(s)) {
|
||||||
fill(matrices, 25 + lineNumberLength + 2, 25 + lineNumber.getValue() * 9, 25 + lineNumberLength + 3, 25 + lineNumber.getValue() * 9 + height, TokenTypeColors.ERROR);
|
context.fill(25 + lineNumberLength + 2, 25 + lineNumber.getValue() * 9, 25 + lineNumberLength + 3, 25 + lineNumber.getValue() * 9 + height, TokenTypeColors.ERROR);
|
||||||
}
|
}
|
||||||
this.textRenderer.draw(matrices, String.valueOf(lineNumberText), 25f + lineNumberLength - textRenderer.getWidth(String.valueOf(lineNumberText)), 25f + lineNumber.getValue() * 9f, 0xFFFFFF);
|
context.drawText(textRenderer, String.valueOf(lineNumberText), (int) (25f + lineNumberLength - textRenderer.getWidth(String.valueOf(lineNumberText))), (int) (25f + lineNumber.getValue() * 9f), 0xFFFFFF, false);
|
||||||
lineNumberText++;
|
lineNumberText++;
|
||||||
|
|
||||||
// Line text
|
// Line text
|
||||||
@ -234,15 +231,15 @@ public class ScriptEditScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (finalI >= minSelectionY && finalI <= maxSelectionY && x2 > x1) {
|
if (finalI >= minSelectionY && finalI <= maxSelectionY && x2 > x1) {
|
||||||
fill(matrices, x1, y + 25, x2, y + 25 + 9, TokenTypeColors.SELECTION);
|
context.fill(x1, y + 25, x2, y + 25 + 9, TokenTypeColors.SELECTION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (finalI == cursorY && currentXIndex.get() >= cursorX && previousXIndex <= cursorX) {
|
if (finalI == cursorY && currentXIndex.get() >= cursorX && previousXIndex <= cursorX) {
|
||||||
drawCursor(matrices, x.get() + textRenderer.getWidth(line.substring(0, cursorX - previousXIndex)) - 1, 25 + y, isAtEndOfLine());
|
drawCursor(context, x.get() + textRenderer.getWidth(line.substring(0, cursorX - previousXIndex)) - 1, 25 + y, isAtEndOfLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.textRenderer.draw(matrices, line, x.get(), 25 + y, token.color);
|
context.drawText(this.textRenderer, line, x.get(), 25 + y, token.color, false);
|
||||||
x.addAndGet(textRenderer.getWidth(line));
|
x.addAndGet(textRenderer.getWidth(line));
|
||||||
if (x.get() > this.width - 50 - lineNumberLength - 5) {
|
if (x.get() > this.width - 50 - lineNumberLength - 5) {
|
||||||
x.set(25 + lineNumberLength + 5);
|
x.set(25 + lineNumberLength + 5);
|
||||||
@ -253,7 +250,7 @@ public class ScriptEditScreen extends Screen {
|
|||||||
lineNumber.increment();
|
lineNumber.increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
super.render(matrices, mouseX, mouseY, delta);
|
super.render(context, mouseX, mouseY, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean lineTooLong(String s) {
|
private boolean lineTooLong(String s) {
|
||||||
@ -263,13 +260,13 @@ public class ScriptEditScreen extends Screen {
|
|||||||
return textRenderer.getWrappedLinesHeight(s, 114) > 128;
|
return textRenderer.getWrappedLinesHeight(s, 114) > 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawCursor(MatrixStack matrices, int x, int y, boolean atEnd) {
|
private void drawCursor(DrawContext context, int x, int y, boolean atEnd) {
|
||||||
if (this.tickCounter / 6 % 2 == 0) {
|
if (this.tickCounter / 6 % 2 == 0) {
|
||||||
if (!atEnd) {
|
if (!atEnd) {
|
||||||
Objects.requireNonNull(this.textRenderer);
|
Objects.requireNonNull(this.textRenderer);
|
||||||
DrawableHelper.fill(matrices, x, y - 1, x + 1, y + 9, 0xFFFFFFFF);
|
context.fill(x, y - 1, x + 1, y + 9, 0xFFFFFFFF);
|
||||||
} else {
|
} else {
|
||||||
this.textRenderer.draw(matrices, "_", (float) x, (float) y, 0xFFFFFFFF);
|
context.drawText(this.textRenderer, "_", x, y, 0xFFFFFFFF, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,8 +583,8 @@ public class ScriptEditScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
|
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
|
||||||
scroll -= Math.signum(amount);
|
scroll -= (int) Math.signum(verticalAmount);
|
||||||
if (scroll > lines.size() - 1) {
|
if (scroll > lines.size() - 1) {
|
||||||
scroll = lines.size() - 1;
|
scroll = lines.size() - 1;
|
||||||
}
|
}
|
||||||
@ -638,10 +635,10 @@ public class ScriptEditScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void writeNbtData(List<String> pages) {
|
private void writeNbtData(List<String> pages) {
|
||||||
NbtList nbtList = new NbtList();
|
|
||||||
pages.stream().map(NbtString::of).forEach(nbtList::add);
|
|
||||||
if (!pages.isEmpty()) {
|
if (!pages.isEmpty()) {
|
||||||
this.itemStack.setSubNbt("pages", nbtList);
|
this.itemStack.set(DataComponentTypes.WRITABLE_BOOK_CONTENT, new WritableBookContentComponent(
|
||||||
|
pages.stream().map(string -> new RawFilteredPair<String>(string, Optional.empty())).toList())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
accessWidener v1 named
|
accessWidener v1 named
|
||||||
|
|
||||||
accessible field net/minecraft/client/network/ClientPlayNetworkHandler serverInfo Lnet/minecraft/client/network/ServerInfo;
|
|
||||||
accessible field net/minecraft/client/Keyboard client Lnet/minecraft/client/MinecraftClient;
|
accessible field net/minecraft/client/Keyboard client Lnet/minecraft/client/MinecraftClient;
|
||||||
@ -22,8 +22,8 @@
|
|||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.11",
|
"fabricloader": ">=0.14.11",
|
||||||
"minecraft": ">=1.19.3",
|
"minecraft": ">=1.20.6",
|
||||||
"java": ">=17"
|
"java": ">=21"
|
||||||
},
|
},
|
||||||
"accessWidener" : "advancedscripts.accesswidener"
|
"accessWidener" : "advancedscripts.accesswidener"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user