mirror of
https://github.com/TeamMidnightDust/PictureSign.git
synced 2025-12-13 04:45:10 +01:00
PictureSign 1.4.1 - Update to 1.19
This commit is contained in:
@@ -3,17 +3,17 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version=1.17.1
|
minecraft_version=1.19
|
||||||
yarn_mappings=1.17.1+build.61
|
yarn_mappings=1.19+build.4
|
||||||
loader_version=0.14.6
|
loader_version=0.14.8
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.4.0
|
mod_version = 1.4.1
|
||||||
maven_group = eu.midnightdust
|
maven_group = eu.midnightdust
|
||||||
archives_base_name = picturesign
|
archives_base_name = picturesign
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
fabric_version=0.40.1+1.17
|
fabric_version=0.56.0+1.19
|
||||||
midnightlib_version=0.4.0
|
midnightlib_version=0.5.2
|
||||||
iris_version=1.17.x-v1.2.2
|
iris_version=1.19.x-v1.2.5
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ public class PictureSignClient implements ClientModInitializer {
|
|||||||
if (client.crosshairTarget.getType() == HitResult.Type.BLOCK && client.world.getBlockState(new BlockPos(client.crosshairTarget.getPos())).hasBlockEntity()) {
|
if (client.crosshairTarget.getType() == HitResult.Type.BLOCK && client.world.getBlockState(new BlockPos(client.crosshairTarget.getPos())).hasBlockEntity()) {
|
||||||
if (client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos())) instanceof SignBlockEntity) {
|
if (client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos())) instanceof SignBlockEntity) {
|
||||||
SignBlockEntity sign = (SignBlockEntity) client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos()));
|
SignBlockEntity sign = (SignBlockEntity) client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos()));
|
||||||
clipboard[0] = sign.getTextOnRow(0, false).asString();
|
clipboard[0] = sign.getTextOnRow(0, false).getString();
|
||||||
clipboard[1] = sign.getTextOnRow(1, false).asString();
|
clipboard[1] = sign.getTextOnRow(1, false).getString();
|
||||||
clipboard[2] = sign.getTextOnRow(2, false).asString();
|
clipboard[2] = sign.getTextOnRow(2, false).getString();
|
||||||
clipboard[3] = sign.getTextOnRow(3, false).asString();
|
clipboard[3] = sign.getTextOnRow(3, false).getString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class PictureSignRenderer {
|
|||||||
matrixStack.translate(xOffset + x, 0.00F + y, zOffset + z);
|
matrixStack.translate(xOffset + x, 0.00F + y, zOffset + z);
|
||||||
matrixStack.multiply(yRotation);
|
matrixStack.multiply(yRotation);
|
||||||
|
|
||||||
Matrix4f matrix4f = matrixStack.peek().getModel();
|
Matrix4f matrix4f = matrixStack.peek().getPositionMatrix();
|
||||||
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE_LIGHT);
|
buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE_LIGHT);
|
||||||
|
|
||||||
buffer.vertex(matrix4f, width, 0.0F, 1.0F).color(255, 255, 255, 255).texture(1.0F, 1.0F).light(l).overlay(overlay)
|
buffer.vertex(matrix4f, width, 0.0F, 1.0F).color(255, 255, 255, 255).texture(1.0F, 1.0F).light(l).overlay(overlay)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import net.minecraft.block.BlockState;
|
|||||||
import net.minecraft.block.SignBlock;
|
import net.minecraft.block.SignBlock;
|
||||||
import net.minecraft.block.entity.SignBlockEntity;
|
import net.minecraft.block.entity.SignBlockEntity;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.screen.ScreenTexts;
|
|
||||||
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
@@ -19,8 +18,8 @@ import net.minecraft.client.render.block.entity.SignBlockEntityRenderer;
|
|||||||
import net.minecraft.client.util.SpriteIdentifier;
|
import net.minecraft.client.util.SpriteIdentifier;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket;
|
import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket;
|
||||||
|
import net.minecraft.screen.ScreenTexts;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableText;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.Matrix4f;
|
import net.minecraft.util.math.Matrix4f;
|
||||||
|
|
||||||
@@ -36,7 +35,7 @@ public class PictureSignHelperScreen extends Screen {
|
|||||||
private String[] text;
|
private String[] text;
|
||||||
|
|
||||||
public PictureSignHelperScreen(SignBlockEntity sign, boolean filtered) {
|
public PictureSignHelperScreen(SignBlockEntity sign, boolean filtered) {
|
||||||
super(new TranslatableText("sign.edit"));
|
super(Text.translatable("sign.edit"));
|
||||||
this.text = IntStream.range(0, 4).mapToObj((row) ->
|
this.text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
sign.getTextOnRow(row, filtered)).map(Text::getString).toArray(String[]::new);
|
sign.getTextOnRow(row, filtered)).map(Text::getString).toArray(String[]::new);
|
||||||
this.sign = sign;
|
this.sign = sign;
|
||||||
@@ -44,8 +43,8 @@ public class PictureSignHelperScreen extends Screen {
|
|||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
sign.setEditable(false);
|
sign.setEditable(false);
|
||||||
if (!sign.getTextOnRow(3,false).asString().matches("(.*\\d:.*\\d:.*\\d:.*\\d:.*\\d)")) sign.setTextOnRow(3, Text.of("1:1:0:0:0"));
|
if (!sign.getTextOnRow(3,false).getString().matches("(.*\\d:.*\\d:.*\\d:.*\\d:.*\\d)")) sign.setTextOnRow(3, Text.of("1:1:0:0:0"));
|
||||||
if (!sign.getTextOnRow(0, false).asString().startsWith("!PS:")) sign.setTextOnRow(0, Text.of("!PS:"));
|
if (!sign.getTextOnRow(0, false).getString().startsWith("!PS:")) sign.setTextOnRow(0, Text.of("!PS:"));
|
||||||
text = IntStream.range(0, 4).mapToObj((row) ->
|
text = IntStream.range(0, 4).mapToObj((row) ->
|
||||||
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
||||||
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 4 + 120, 200, 20, ScreenTexts.DONE, (button) -> {
|
this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 4 + 120, 200, 20, ScreenTexts.DONE, (button) -> {
|
||||||
@@ -95,14 +94,14 @@ public class PictureSignHelperScreen extends Screen {
|
|||||||
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
sign.getTextOnRow(row, false)).map(Text::getString).toArray(String[]::new);
|
||||||
});
|
});
|
||||||
this.addDrawableChild(linkWidget);
|
this.addDrawableChild(linkWidget);
|
||||||
String[] initialDimensions = sign.getTextOnRow(3, false).asString().split(":");
|
String[] initialDimensions = sign.getTextOnRow(3, false).getString().split(":");
|
||||||
TextFieldWidget widthWidget = new TextFieldWidget(textRenderer,this.width / 2 - 175,this.height / 5 + 70,30,20, Text.of("width"));
|
TextFieldWidget widthWidget = new TextFieldWidget(textRenderer,this.width / 2 - 175,this.height / 5 + 70,30,20, Text.of("width"));
|
||||||
widthWidget.setText(initialDimensions[0]);
|
widthWidget.setText(initialDimensions[0]);
|
||||||
widthWidget.setChangedListener(s -> {
|
widthWidget.setChangedListener(s -> {
|
||||||
String[] dimensions = new String[5];
|
String[] dimensions = new String[5];
|
||||||
for (int i = 0; i < dimensions.length; ++i){
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
if (sign.getTextOnRow(3, false).getString().split(":").length > i)
|
||||||
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
dimensions[i] = sign.getTextOnRow(3, false).getString().split(":")[i];
|
||||||
}
|
}
|
||||||
dimensions[0] = s;
|
dimensions[0] = s;
|
||||||
StringBuilder mergedDimensions = new StringBuilder();
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
@@ -121,8 +120,8 @@ public class PictureSignHelperScreen extends Screen {
|
|||||||
heightWidget.setChangedListener(s -> {
|
heightWidget.setChangedListener(s -> {
|
||||||
String[] dimensions = new String[5];
|
String[] dimensions = new String[5];
|
||||||
for (int i = 0; i < dimensions.length; ++i){
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
if (sign.getTextOnRow(3, false).getString().split(":").length > i)
|
||||||
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
dimensions[i] = sign.getTextOnRow(3, false).getString().split(":")[i];
|
||||||
}
|
}
|
||||||
dimensions[1] = s;
|
dimensions[1] = s;
|
||||||
StringBuilder mergedDimensions = new StringBuilder();
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
@@ -141,8 +140,8 @@ public class PictureSignHelperScreen extends Screen {
|
|||||||
posXWidget.setChangedListener(s -> {
|
posXWidget.setChangedListener(s -> {
|
||||||
String[] dimensions = new String[5];
|
String[] dimensions = new String[5];
|
||||||
for (int i = 0; i < dimensions.length; ++i){
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
if (sign.getTextOnRow(3, false).getString().split(":").length > i)
|
||||||
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
dimensions[i] = sign.getTextOnRow(3, false).getString().split(":")[i];
|
||||||
}
|
}
|
||||||
dimensions[2] = s;
|
dimensions[2] = s;
|
||||||
StringBuilder mergedDimensions = new StringBuilder();
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
@@ -161,8 +160,8 @@ public class PictureSignHelperScreen extends Screen {
|
|||||||
posYWidget.setChangedListener(s -> {
|
posYWidget.setChangedListener(s -> {
|
||||||
String[] dimensions = new String[5];
|
String[] dimensions = new String[5];
|
||||||
for (int i = 0; i < dimensions.length; ++i){
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
if (sign.getTextOnRow(3, false).getString().split(":").length > i)
|
||||||
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
dimensions[i] = sign.getTextOnRow(3, false).getString().split(":")[i];
|
||||||
}
|
}
|
||||||
dimensions[3] = s;
|
dimensions[3] = s;
|
||||||
StringBuilder mergedDimensions = new StringBuilder();
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
@@ -181,8 +180,8 @@ public class PictureSignHelperScreen extends Screen {
|
|||||||
posZWidget.setChangedListener(s -> {
|
posZWidget.setChangedListener(s -> {
|
||||||
String[] dimensions = new String[5];
|
String[] dimensions = new String[5];
|
||||||
for (int i = 0; i < dimensions.length; ++i){
|
for (int i = 0; i < dimensions.length; ++i){
|
||||||
if (sign.getTextOnRow(3, false).asString().split(":").length > i)
|
if (sign.getTextOnRow(3, false).getString().split(":").length > i)
|
||||||
dimensions[i] = sign.getTextOnRow(3, false).asString().split(":")[i];
|
dimensions[i] = sign.getTextOnRow(3, false).getString().split(":")[i];
|
||||||
}
|
}
|
||||||
dimensions[4] = s;
|
dimensions[4] = s;
|
||||||
StringBuilder mergedDimensions = new StringBuilder();
|
StringBuilder mergedDimensions = new StringBuilder();
|
||||||
@@ -209,30 +208,30 @@ public class PictureSignHelperScreen extends Screen {
|
|||||||
Text linkText = Text.of("!PS:"+link);
|
Text linkText = Text.of("!PS:"+link);
|
||||||
String[] brokenLink = new String[3];
|
String[] brokenLink = new String[3];
|
||||||
Text line0Text = linkText;
|
Text line0Text = linkText;
|
||||||
int line0width = line0Text.asString().length();
|
int line0width = line0Text.getString().length();
|
||||||
assert this.client != null;
|
assert this.client != null;
|
||||||
while (this.client.textRenderer.getWidth(line0Text) >= 90) {
|
while (this.client.textRenderer.getWidth(line0Text) >= 90) {
|
||||||
--line0width;
|
--line0width;
|
||||||
line0Text = Text.of(line0Text.asString().substring(0,line0width));
|
line0Text = Text.of(line0Text.getString().substring(0,line0width));
|
||||||
}
|
}
|
||||||
brokenLink[0] = line0Text.asString();
|
brokenLink[0] = line0Text.getString();
|
||||||
Text line1Text = Text.of(linkText.asString().substring(line0width));
|
Text line1Text = Text.of(linkText.getString().substring(line0width));
|
||||||
int line1width = line1Text.asString().length();
|
int line1width = line1Text.getString().length();
|
||||||
assert this.client != null;
|
assert this.client != null;
|
||||||
while (this.client.textRenderer.getWidth(line1Text) >= 90) {
|
while (this.client.textRenderer.getWidth(line1Text) >= 90) {
|
||||||
--line1width;
|
--line1width;
|
||||||
line1Text = Text.of(line1Text.asString().substring(0,line1width));
|
line1Text = Text.of(line1Text.getString().substring(0,line1width));
|
||||||
}
|
}
|
||||||
brokenLink[1] = line1Text.asString();
|
brokenLink[1] = line1Text.getString();
|
||||||
Text line2Text = Text.of(linkText.asString().substring(line0width + line1width));
|
Text line2Text = Text.of(linkText.getString().substring(line0width + line1width));
|
||||||
int line2width = line2Text.asString().length();
|
int line2width = line2Text.getString().length();
|
||||||
assert this.client != null;
|
assert this.client != null;
|
||||||
if (!PictureSignConfig.exceedVanillaLineLength)
|
if (!PictureSignConfig.exceedVanillaLineLength)
|
||||||
while (this.client.textRenderer.getWidth(line2Text) >= 90) {
|
while (this.client.textRenderer.getWidth(line2Text) >= 90) {
|
||||||
--line2width;
|
--line2width;
|
||||||
line2Text = Text.of(line2Text.asString().substring(0,line2width));
|
line2Text = Text.of(line2Text.getString().substring(0,line2width));
|
||||||
}
|
}
|
||||||
brokenLink[2] = line2Text.asString();
|
brokenLink[2] = line2Text.getString();
|
||||||
|
|
||||||
return brokenLink;
|
return brokenLink;
|
||||||
}
|
}
|
||||||
@@ -280,7 +279,7 @@ public class PictureSignHelperScreen extends Screen {
|
|||||||
matrices.translate(0.0, 0.3333333432674408, 0.046666666865348816);
|
matrices.translate(0.0, 0.3333333432674408, 0.046666666865348816);
|
||||||
matrices.scale(0.010416667F, -0.010416667F, 0.010416667F);
|
matrices.scale(0.010416667F, -0.010416667F, 0.010416667F);
|
||||||
int i = this.sign.getTextColor().getSignColor();
|
int i = this.sign.getTextColor().getSignColor();
|
||||||
Matrix4f matrix4f = matrices.peek().getModel();
|
Matrix4f matrix4f = matrices.peek().getPositionMatrix();
|
||||||
|
|
||||||
int m;
|
int m;
|
||||||
String string;
|
String string;
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
package eu.midnightdust.picturesign.util;
|
|
||||||
|
|
||||||
import eu.midnightdust.picturesign.PictureSignClient;
|
|
||||||
import net.minecraft.block.entity.SignBlockEntity;
|
|
||||||
import net.minecraft.client.MinecraftClient;
|
|
||||||
import net.minecraft.client.gui.screen.ingame.SignEditScreen;
|
|
||||||
import net.minecraft.util.hit.HitResult;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class SignEditEvent {
|
|
||||||
public static void tick(@NotNull MinecraftClient client) {
|
|
||||||
if (!PictureSignClient.BINDING_EDIT_SIGN.isPressed()) return;
|
|
||||||
PictureSignClient.BINDING_EDIT_SIGN.setPressed(false);
|
|
||||||
if (client.player == null || client.crosshairTarget == null || client.crosshairTarget.getType() != HitResult.Type.BLOCK) return;
|
|
||||||
if (client.crosshairTarget.getType() == HitResult.Type.BLOCK && client.world.getBlockState(new BlockPos(client.crosshairTarget.getPos())).hasBlockEntity()) {
|
|
||||||
if (client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos())) instanceof SignBlockEntity) {
|
|
||||||
client.setScreen(new SignEditScreen((SignBlockEntity) client.world.getBlockEntity(new BlockPos(client.crosshairTarget.getPos())), false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user