Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20.5 port tm #217

Merged
merged 10 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
matrix:
# Use these Java versions
java: [
17 # Minimum supported by Minecraft
21 # Minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-20.04]
os: [ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
Expand All @@ -32,7 +32,7 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v2
with:
name: Artifacts
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//file:noinspection GradlePackageVersionRange
plugins {
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand Down Expand Up @@ -31,7 +31,7 @@ allprojects {
}
}

def targetJavaVersion = 17
def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
// 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
Expand Down Expand Up @@ -119,15 +119,15 @@ loom {
}

dependencies {
modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}")
// modLocalRuntime("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}")
modCompileOnly("me.shedaniel:RoughlyEnoughItems-default-plugin:${project.rei_version}")
modCompileOnly("me.shedaniel:RoughlyEnoughItems-api-fabric:${project.rei_version}")

modCompileOnly("dev.emi:emi-fabric:${project.emi_version}")
// modLocalRuntime("dev.emi:emi-fabric:${project.emi_version}")

modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}")
modLocalRuntime("com.terraformersmc:modmenu:${project.modmenu_version}")
// modLocalRuntime("com.terraformersmc:modmenu:${project.modmenu_version}")

api(include("blue.endless:jankson:${project.jankson_version}"))

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_base_version=1.20.3
minecraft_version=1.20.3
yarn_mappings=1.20.3+build.1
loader_version=0.15.0
minecraft_base_version=1.20.5
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.10
# Mod Properties
mod_version=0.12.6
maven_group=io.wispforest
archives_base_name=owo-lib
# Dependencies
fabric_version=0.91.1+1.20.3
fabric_version=0.97.7+1.20.5

# https://maven.shedaniel.me/me/shedaniel/RoughlyEnoughItems-fabric/
rei_version=14.0.688
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 2 additions & 5 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
before_install:
- wget https://github.com/sormuras/bach/raw/master/install-jdk.sh
- source install-jdk.sh --feature 16
- jshell --version

jdk:
- openjdk21
96 changes: 58 additions & 38 deletions src/main/java/io/wispforest/owo/client/screens/ScreenInternals.java
Original file line number Diff line number Diff line change
@@ -1,38 +1,70 @@
package io.wispforest.owo.client.screens;

import io.wispforest.owo.Owo;
import io.wispforest.owo.serialization.Endec;
import io.wispforest.owo.serialization.endec.BuiltInEndecs;
import io.wispforest.owo.serialization.endec.StructEndecBuilder;
import io.wispforest.owo.util.pond.OwoScreenHandlerExtension;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
public class ScreenInternals {
public static final Identifier LOCAL_PACKET = new Identifier("owo", "local_packet");
public static final Identifier SYNC_PROPERTIES = new Identifier("owo", "sync_screen_handler_properties");

public static void init() {
ServerPlayNetworking.registerGlobalReceiver(LOCAL_PACKET, (server, player, handler, buf, responseSender) -> {
buf.retain();
server.execute(() -> {
var screenHandler = player.currentScreenHandler;
PayloadTypeRegistry.playS2C().register(LocalPacket.ID, LocalPacket.ENDEC.packetCodec());
PayloadTypeRegistry.playC2S().register(LocalPacket.ID, LocalPacket.ENDEC.packetCodec());
PayloadTypeRegistry.playS2C().register(SyncPropertiesPacket.ID, SyncPropertiesPacket.ENDEC.packetCodec());

if (screenHandler == null) {
Owo.LOGGER.error("Received local packet for null ScreenHandler");
return;
}
ServerPlayNetworking.registerGlobalReceiver(LocalPacket.ID, (payload, context) -> {
var screenHandler = context.player().currentScreenHandler;

((OwoScreenHandlerExtension) screenHandler).owo$handlePacket(buf, false);
buf.release();
});
if (screenHandler == null) {
Owo.LOGGER.error("Received local packet for null ScreenHandler");
return;
}

((OwoScreenHandlerExtension) screenHandler).owo$handlePacket(payload, false);
});
}

public record LocalPacket(int packetId, PacketByteBuf payload) implements CustomPayload {
public static final Id<LocalPacket> ID = new Id<>(new Identifier("owo", "local_packet"));
public static final Endec<LocalPacket> ENDEC = StructEndecBuilder.of(
Endec.VAR_INT.fieldOf("packetId", LocalPacket::packetId),
BuiltInEndecs.PACKET_BYTE_BUF.fieldOf("payload", LocalPacket::payload),
LocalPacket::new
);

@Override
public Id<? extends CustomPayload> getId() {
return ID;
}
}

public record SyncPropertiesPacket(PacketByteBuf payload) implements CustomPayload {
public static final Id<SyncPropertiesPacket> ID = new Id<>(SYNC_PROPERTIES);
public static final Endec<SyncPropertiesPacket> ENDEC = StructEndecBuilder.of(
BuiltInEndecs.PACKET_BYTE_BUF.fieldOf("payload", SyncPropertiesPacket::payload),
SyncPropertiesPacket::new
);

@Override
public Id<? extends CustomPayload> getId() {
return ID;
}
}

@Environment(EnvType.CLIENT)
public static class Client {
public static void init() {
Expand All @@ -41,38 +73,26 @@ public static void init() {
((OwoScreenHandlerExtension) handled.getScreenHandler()).owo$attachToPlayer(client.player);
});

ClientPlayNetworking.registerGlobalReceiver(LOCAL_PACKET, (client, handler, buf, responseSender) -> {
if (client.player == null) return;

buf.retain();
client.execute(() -> {
var screenHandler = client.player.currentScreenHandler;
ClientPlayNetworking.registerGlobalReceiver(LocalPacket.ID, (payload, context) -> {
var screenHandler = context.player().currentScreenHandler;

if (screenHandler == null) {
Owo.LOGGER.error("Received local packet for null ScreenHandler");
return;
}
if (screenHandler == null) {
Owo.LOGGER.error("Received local packet for null ScreenHandler");
return;
}

((OwoScreenHandlerExtension) screenHandler).owo$handlePacket(buf, true);
buf.release();
});
((OwoScreenHandlerExtension) screenHandler).owo$handlePacket(payload, true);
});

ClientPlayNetworking.registerGlobalReceiver(SYNC_PROPERTIES, (client, handler, buf, responseSender) -> {
buf.retain();

client.execute(() -> {
if (client.player == null) return;

if (client.player.currentScreenHandler == null) {
Owo.LOGGER.error("Received sync properties packet for null ScreenHandler");
return;
}
ClientPlayNetworking.registerGlobalReceiver(SyncPropertiesPacket.ID, (payload, context) -> {
var screenHandler = context.player().currentScreenHandler;

((OwoScreenHandlerExtension) client.player.currentScreenHandler).owo$readPropertySync(buf);
if (screenHandler == null) {
Owo.LOGGER.error("Received sync properties packet for null ScreenHandler");
return;
}

buf.release();
});
((OwoScreenHandlerExtension) screenHandler).owo$readPropertySync(payload);
});
}
}
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/io/wispforest/owo/command/debug/DumpdataCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
import io.wispforest.owo.Owo;
import io.wispforest.owo.ops.TextOps;
import net.minecraft.command.argument.NbtPathArgumentType;
import net.minecraft.component.ComponentChanges;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.entity.projectile.ProjectileUtil;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtHelper;
import net.minecraft.nbt.NbtOps;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.server.command.ServerCommandSource;
Expand Down Expand Up @@ -59,18 +62,18 @@ private static int executeItem(CommandContext<ServerCommandSource> context, NbtP
informationHeader(source, "Item");
sendIdentifier(source, stack.getItem(), Registries.ITEM);

if (stack.getItem().isDamageable()) {
feedback(source, TextOps.withColor("Durability: §" + stack.getItem().getMaxDamage(),
if (stack.get(DataComponentTypes.MAX_DAMAGE) != null) {
feedback(source, TextOps.withColor("Durability: §" + stack.get(DataComponentTypes.MAX_DAMAGE),
TextOps.color(Formatting.GRAY), KEY_BLUE));
} else {
feedback(source, TextOps.withFormatting("Not damageable", Formatting.GRAY));
}

if (context.getSource().getPlayer().getMainHandStack().hasNbt()) {
feedback(source, TextOps.withFormatting("NBT" + formatPath(path) + ": ", Formatting.GRAY)
.append(NbtHelper.toPrettyPrintedText(getPath(stack.getNbt(), path))));
if (!stack.getComponentChanges().isEmpty()) {
feedback(source, TextOps.withFormatting("Component changes" + formatPath(path) + ": ", Formatting.GRAY)
.append(NbtHelper.toPrettyPrintedText(getPath(ComponentChanges.CODEC.encodeStart(NbtOps.INSTANCE, stack.getComponentChanges()).getOrThrow(), path))));
} else {
feedback(source, TextOps.withFormatting("No NBT", Formatting.GRAY));
feedback(source, TextOps.withFormatting("No component changes", Formatting.GRAY));
}

feedback(source, TextOps.withFormatting("-----------------------", Formatting.GRAY));
Expand Down Expand Up @@ -144,7 +147,7 @@ private static int executeBlock(CommandContext<ServerCommandSource> context, Nbt
final var blockEntity = player.getWorld().getBlockEntity(pos);
if (blockEntity != null) {
feedback(source, TextOps.withFormatting("Block Entity NBT" + formatPath(path) + ": ", Formatting.GRAY)
.append(NbtHelper.toPrettyPrintedText(getPath(blockEntity.createNbt(), path))));
.append(NbtHelper.toPrettyPrintedText(getPath(blockEntity.createNbt(player.getRegistryManager()), path))));
} else {
feedback(source, TextOps.withFormatting("No block entity", Formatting.GRAY));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.argument.IdentifierArgumentType;
import net.minecraft.command.argument.ItemStackArgumentType;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.component.type.NbtComponent;
import net.minecraft.server.command.LootCommand;
import net.minecraft.server.command.ServerCommandSource;

Expand All @@ -26,7 +28,12 @@ private static int execute(CommandContext<ServerCommandSource> context) throws C
var targetStack = ItemStackArgumentType.getItemStackArgument(context, "item").createStack(1, false);
var tableId = IdentifierArgumentType.getIdentifier(context, "loot_table");

targetStack.getOrCreateSubNbt("BlockEntityTag").putString("LootTable", tableId.toString());
var blockEntityTag = targetStack.getOrDefault(DataComponentTypes.BLOCK_ENTITY_DATA, NbtComponent.DEFAULT);
blockEntityTag = blockEntityTag.apply(x -> {
x.putString("LootTable", tableId.toString());
});
targetStack.set(DataComponentTypes.BLOCK_ENTITY_DATA, blockEntityTag);

context.getSource().getPlayer().getInventory().offerOrDrop(targetStack);

return 0;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/io/wispforest/owo/compat/rei/OwoReiPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,30 @@ private static void renderOverlay(Screen screen, Runnable renderFunction) {

final var time = System.currentTimeMillis();
float scale = .75f + (float) (Math.sin(time / 500d) * .5f);
modelView.push();
modelView.pushMatrix();
modelView.translate(screen.width / 2f - scale / 2f * screen.width, screen.height / 2f - scale / 2f * screen.height, 0);
modelView.scale(scale, scale, 1f);
modelView.translate((float) (Math.sin(time / 1000d) * .75f) * screen.width, (float) (Math.sin(time / 500d) * .75f) * screen.height, 0);

modelView.translate(screen.width / 2f, screen.height / 2f, 0);
modelView.multiply(RotationAxis.POSITIVE_Z.rotationDegrees((float) (time / 25d % 360d)));
modelView.rotate(RotationAxis.POSITIVE_Z.rotationDegrees((float) (time / 25d % 360d)));
modelView.translate(screen.width / -2f, screen.height / -2f, 0);

for (int i = 0; i < 20; i++) {
modelView.push();
modelView.pushMatrix();
modelView.translate(screen.width / 2f, screen.height / 2f, 0);
modelView.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(i * 18));
modelView.rotate(RotationAxis.POSITIVE_Z.rotationDegrees(i * 18));
modelView.translate(screen.width / -2f, screen.height / -2f, 0);

RenderSystem.applyModelViewMatrix();
ScissorStack.pushDirect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
renderFunction.run();
GlStateManager._enableScissorTest();
ScissorStack.pop();
modelView.pop();
modelView.popMatrix();
}

modelView.pop();
modelView.popMatrix();
RenderSystem.applyModelViewMatrix();
} else {
ScissorStack.pushDirect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
Expand Down
Loading
Loading