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

update to 1.20.6 #7

Merged
merged 4 commits into from
May 23, 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
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk 17
uses: actions/setup-java@v3
- name: setup jdk 21
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
java-version: 21
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: capture build artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
17 changes: 8 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v2
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 17
java-version: 21

- name: Grant execute permission for gradlew
run: chmod +x gradlew
Expand All @@ -35,25 +35,24 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: fabric
path: download

- uses: Kir-Antipov/mc-publish@v3.3
- uses: Kir-Antipov/mc-publish@995edadc13559a8b28d0b7e6571229f067ec7659
with:
modrinth-id: EjH4M3L1
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}

github-token: ${{ secrets.GITHUB_TOKEN }}
loaders: |
fabric
quilt
game-versions: |
1.20.1
1.20.6
modrinth-dependencies: |
fabric-api | depends
java: 17
java: 21
version: ${{ github.event.release.tag_name }}-fabric
name: ${{ github.event.release.tag_name }}-fabric
files: download/!(*-@(dev|dev-shadow)).jar
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.6.9'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -47,7 +47,7 @@ processResources {

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
it.options.release = 21
}

java {
Expand Down
7 changes: 4 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
loader_version=0.14.21
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
loader_version=0.15.11

# Mod Properties
mod_version = 1.0.0
maven_group = de.mari_023
archives_base_name = pressalttomeow

# Dependencies
fabric_version=0.83.1+1.20.1
fabric_version=0.99.0+1.20.6
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Thu May 23 18:27:20 TRT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 18 additions & 0 deletions src/main/java/de/mari_023/pressalttomeow/MeowPayload.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package de.mari_023.pressalttomeow;

import io.netty.buffer.ByteBuf;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;

public class MeowPayload implements CustomPacketPayload {
public static Type<MeowPayload> TYPE = new Type<>(new ResourceLocation("pressalttomeow", "m"));
public static StreamCodec<ByteBuf, MeowPayload> CODEC = StreamCodec.of((buffer, value) -> {
}, (buffer) -> new MeowPayload());

@Override
public @NotNull Type<? extends CustomPacketPayload> type() {
return MeowPayload.TYPE;
}
}
10 changes: 7 additions & 3 deletions src/main/java/de/mari_023/pressalttomeow/PressAltToMeow.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent;
Expand All @@ -15,19 +17,21 @@
import java.util.WeakHashMap;

public class PressAltToMeow implements ModInitializer {
public static final ResourceLocation NETWORK_CHANNEL = new ResourceLocation("pressalttomeow", "m");
private static final WeakHashMap<ServerPlayer, Long> LAST_MEOW = new WeakHashMap<>();
private static final Random RANDOM = new Random();

@Override
public void onInitialize() {
ServerPlayNetworking.registerGlobalReceiver(NETWORK_CHANNEL, (server, player, handler, buf, packetSender) -> server.execute(() -> {
PayloadTypeRegistry.playC2S().register(MeowPayload.TYPE, MeowPayload.CODEC);
PayloadTypeRegistry.playS2C().register(MeowPayload.TYPE, MeowPayload.CODEC);
ServerPlayNetworking.registerGlobalReceiver(MeowPayload.TYPE, (payload, context) -> context.player().getServer().execute(() -> {
var player = context.player();
if (!player.isSpectator() && (!LAST_MEOW.containsKey(player) || System.currentTimeMillis() - LAST_MEOW.get(player) > 1000)) {
playSound(player, defaultSounds());
LAST_MEOW.put(player, System.currentTimeMillis());
}
}));
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> ServerPlayNetworking.send(handler.player, PressAltToMeow.NETWORK_CHANNEL, PacketByteBufs.create()));
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> ServerPlayNetworking.send(handler.player, new MeowPayload()));
}

private static void playSound(ServerPlayer player, SoundEvent soundEvent) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package de.mari_023.pressalttomeow.client;

import com.mojang.blaze3d.platform.InputConstants;
import de.mari_023.pressalttomeow.MeowPayload;
import de.mari_023.pressalttomeow.PressAltToMeow;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.sounds.SoundSource;
import org.lwjgl.glfw.GLFW;

Expand All @@ -23,13 +26,13 @@ public void onInitializeClient() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (keyBinding.consumeClick()) {
if (System.currentTimeMillis() - LAST_MEOW > 1000) {
if (isOnServer) ClientPlayNetworking.send(PressAltToMeow.NETWORK_CHANNEL, PacketByteBufs.create());
if (isOnServer) ClientPlayNetworking.send(new MeowPayload());
else meow();
LAST_MEOW = System.currentTimeMillis();
}
}
});
ClientPlayNetworking.registerGlobalReceiver(PressAltToMeow.NETWORK_CHANNEL, (client, handler, buf, packetSender) -> isOnServer = true);
ClientPlayNetworking.registerGlobalReceiver(MeowPayload.TYPE, (payload, context) -> isOnServer = true);
}

private void meow() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"depends": {
"fabric": "*",
"minecraft": [
"~1.20"
">=1.20.5"
],
"java": ">=17"
"java": ">=21"
}
}
Loading