Update to 1.20.6
This commit is contained in:
26
build.gradle
26
build.gradle
@ -1,11 +1,8 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.0-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.9.2'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
@ -32,8 +29,27 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
def targetJavaVersion = 21
|
||||
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 {
|
||||
|
||||
@ -4,11 +4,11 @@ org.gradle.parallel=true
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.19.3
|
||||
yarn_mappings=1.19.3+build.1
|
||||
loader_version=0.14.11
|
||||
minecraft_version=1.20.6
|
||||
yarn_mappings=1.20.6+build.3
|
||||
loader_version=0.16.10
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 2.0.0
|
||||
mod_version = 2.1.0
|
||||
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-7.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@ -4,7 +4,6 @@ pluginManagement {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
mavenCentral()
|
||||
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;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
import de.steamwar.advancedscripts.KeyAction;
|
||||
import net.minecraft.client.Keyboard;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket;
|
||||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Keyboard.class)
|
||||
public class KeyboardMixin {
|
||||
|
||||
@Unique
|
||||
private static final Identifier channel = new Identifier("sw:hotkeys");
|
||||
|
||||
@Inject(method = "onKey", at = @At("HEAD"))
|
||||
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) {
|
||||
PacketByteBuf byteBuf = new PacketByteBuf(Unpooled.buffer());
|
||||
byteBuf.writeInt(key);
|
||||
byteBuf.writeByte(action);
|
||||
byteBuf.writeInt(modifiers);
|
||||
CustomPayloadC2SPacket customPayloadC2SPacket = new CustomPayloadC2SPacket(channel,byteBuf);
|
||||
client.getNetworkHandler().sendPacket(customPayloadC2SPacket);
|
||||
client.getNetworkHandler().sendPacket(new CustomPayloadC2SPacket(new KeyAction(key, (byte) action, modifiers)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -24,22 +24,20 @@ import de.steamwar.advancedscripts.lexer.TokenTypeColors;
|
||||
import de.steamwar.advancedscripts.lexer.ScriptColorizer;
|
||||
import de.steamwar.advancedscripts.lexer.Token;
|
||||
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.ingame.BookEditScreen;
|
||||
import net.minecraft.client.gui.screen.ingame.BookScreen;
|
||||
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.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.WritableBookContentComponent;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
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.text.RawFilteredPair;
|
||||
import net.minecraft.text.Style;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Hand;
|
||||
@ -47,6 +45,7 @@ import org.apache.commons.lang3.mutable.MutableInt;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ScriptEditScreen extends Screen {
|
||||
|
||||
@ -73,19 +72,17 @@ public class ScriptEditScreen extends Screen {
|
||||
this.itemStack = itemStack;
|
||||
this.hand = hand;
|
||||
|
||||
NbtCompound nbtCompound = itemStack.getNbt();
|
||||
if (nbtCompound != null) {
|
||||
BookScreen.filterPages(nbtCompound, s -> {
|
||||
String[] split = s.split("\n");
|
||||
for (String s1 : split) {
|
||||
if (s1.equals(" ")) {
|
||||
List<RawFilteredPair<String>> pages = itemStack.get(DataComponentTypes.WRITABLE_BOOK_CONTENT).pages();
|
||||
pages.forEach(stringRawFilteredPair -> {
|
||||
for (String s : stringRawFilteredPair.raw().split("\n")) {
|
||||
if (s.isEmpty()) {
|
||||
lines.add("");
|
||||
} else {
|
||||
lines.add(s1);
|
||||
lines.add(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (lines.isEmpty()) {
|
||||
lines.add("");
|
||||
}
|
||||
@ -159,12 +156,12 @@ public class ScriptEditScreen extends Screen {
|
||||
}
|
||||
|
||||
@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);
|
||||
this.renderBackground(matrices);
|
||||
this.renderBackground(context, mouseX, mouseY, delta);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
||||
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() + "");
|
||||
|
||||
@ -185,15 +182,15 @@ public class ScriptEditScreen extends Screen {
|
||||
}
|
||||
|
||||
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
|
||||
int height = this.textRenderer.getWrappedLinesHeight(s, this.width - 50 - lineNumberLength - 5);
|
||||
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++;
|
||||
|
||||
// Line text
|
||||
@ -234,15 +231,15 @@ public class ScriptEditScreen extends Screen {
|
||||
}
|
||||
|
||||
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) {
|
||||
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));
|
||||
if (x.get() > this.width - 50 - lineNumberLength - 5) {
|
||||
x.set(25 + lineNumberLength + 5);
|
||||
@ -253,7 +250,7 @@ public class ScriptEditScreen extends Screen {
|
||||
lineNumber.increment();
|
||||
}
|
||||
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
private boolean lineTooLong(String s) {
|
||||
@ -263,13 +260,13 @@ public class ScriptEditScreen extends Screen {
|
||||
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 (!atEnd) {
|
||||
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 {
|
||||
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
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
|
||||
scroll -= Math.signum(amount);
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
|
||||
scroll -= (int) Math.signum(verticalAmount);
|
||||
if (scroll > lines.size() - 1) {
|
||||
scroll = lines.size() - 1;
|
||||
}
|
||||
@ -638,10 +635,10 @@ public class ScriptEditScreen extends Screen {
|
||||
}
|
||||
|
||||
private void writeNbtData(List<String> pages) {
|
||||
NbtList nbtList = new NbtList();
|
||||
pages.stream().map(NbtString::of).forEach(nbtList::add);
|
||||
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
|
||||
|
||||
accessible field net/minecraft/client/network/ClientPlayNetworkHandler serverInfo Lnet/minecraft/client/network/ServerInfo;
|
||||
accessible field net/minecraft/client/Keyboard client Lnet/minecraft/client/MinecraftClient;
|
||||
@ -22,8 +22,8 @@
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.11",
|
||||
"minecraft": ">=1.19.3",
|
||||
"java": ">=17"
|
||||
"minecraft": ">=1.20.6",
|
||||
"java": ">=21"
|
||||
},
|
||||
"accessWidener" : "advancedscripts.accesswidener"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user