Skip to content

Commit

Permalink
Update to 1.20.3-pre1
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Nov 20, 2023
1 parent 3034557 commit 3d6ea0d
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 67 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//file:noinspection all

plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'fabric-loom' version '1.4-SNAPSHOT'
id 'maven-publish'
id "org.jetbrains.kotlin.jvm" version "1.9.+"
}
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.2
minecraft_version=1.20.3-pre1
yarn_build=1
loader_version=0.14.22
fabric_version=0.89.2+1.20.2
loader_version=0.14.24
fabric_version=0.90.11+1.20.3
fabric_kotlin_version=1.10.10+kotlin.1.9.10
kache_version=1.0.5

# Mod Properties
mod_version=2.1.3
mod_version=2.2.0
maven_group=dev.andante
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions src/main/java/dev/andante/audience/Audience.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.andante.audience;

import dev.andante.audience.player.PlayerList;
import dev.andante.audience.resource.server.ResourcePackProperties;
import dev.andante.audience.resource.server.ResourcePackRequestCallback;
import dev.andante.audience.sound.ISound;
import dev.andante.audience.sound.SoundStop;
Expand All @@ -12,6 +11,7 @@
import net.minecraft.network.packet.s2c.play.ClearTitleS2CPacket;
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.MinecraftServer.ServerResourcePackProperties;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down Expand Up @@ -212,14 +212,14 @@ default void packet(Function<ServerPlayerEntity, Packet<?>> packet) {
/**
* Sets all audience player resource packs to the given resource pack.
*/
default void setResourcePack(ResourcePackProperties properties, @Nullable ResourcePackRequestCallback callback) {
default void setResourcePack(ServerResourcePackProperties properties, @Nullable ResourcePackRequestCallback callback) {
forEachAudience(player -> player.setResourcePack(properties, callback));
}

/**
* Sets all audience player resource packs to the given resource pack.
*/
default void setResourcePack(ResourcePackProperties properties) {
default void setResourcePack(ServerResourcePackProperties properties) {
setResourcePack(properties, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void performCallback(ResourcePackStatusC2SPacket packet, CallbackInfo ci

ResourcePackRequestCallback callback = ResourcePackRequestCallback.Companion.getCallback(this.uuid);
if (callback != null) {
ResourcePackStatusC2SPacket.Status status = packet.getStatus();
ResourcePackStatusC2SPacket.Status status = packet.status();

// callback
callback.onStatus(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import dev.andante.audience.mixinterface.AudiencePlayerAccessor;
import dev.andante.audience.player.PlayerList;
import dev.andante.audience.player.PlayerReference;
import dev.andante.audience.resource.server.ResourcePackProperties;
import dev.andante.audience.resource.server.ResourcePackRequestCallback;
import net.minecraft.network.packet.c2s.common.ResourcePackStatusC2SPacket;
import net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket;
import net.minecraft.server.MinecraftServer.ServerResourcePackProperties;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import org.jetbrains.annotations.NotNull;
Expand All @@ -33,7 +33,7 @@ public abstract class ServerPlayerEntityMixin implements Audience, PlayerReferen
*/
@Unique
@Nullable
private ResourcePackProperties lastResourcePack = null;
private ServerResourcePackProperties lastResourcePack = null;

@Override
public @NotNull PlayerList getAudiencePlayers() {
Expand All @@ -49,12 +49,12 @@ public abstract class ServerPlayerEntityMixin implements Audience, PlayerReferen

@Nullable
@Override
public ResourcePackProperties getLastResourcePack() {
public ServerResourcePackProperties getLastResourcePack() {
return this.lastResourcePack;
}

@Override
public void setResourcePack(ResourcePackProperties properties, @Nullable ResourcePackRequestCallback callback) {
public void setResourcePack(ServerResourcePackProperties properties, @Nullable ResourcePackRequestCallback callback) {
if (properties == this.lastResourcePack) {
if (callback != null) {
callback.onStatus(ResourcePackStatusC2SPacket.Status.SUCCESSFULLY_LOADED);
Expand All @@ -66,10 +66,11 @@ public void setResourcePack(ResourcePackProperties properties, @Nullable Resourc
if (properties != null) {
this.networkHandler.sendPacket(
new ResourcePackSendS2CPacket(
properties.getUrl(),
properties.getHash(),
properties.getRequired(),
properties.getPrompt()
properties.id(),
properties.url(),
properties.hash(),
properties.isRequired(),
properties.prompt()
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ default String getPlayerName() {
return "Unknown";
} else {
// return online name
return player.getEntityName();
return player.getGameProfile().getName();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package dev.andante.audience.mixinterface

import dev.andante.audience.mixin.ServerPlayerEntityMixin
import dev.andante.audience.resource.server.ResourcePackProperties
import dev.andante.audience.resource.server.ResourcePackRequestCallback
import net.minecraft.server.MinecraftServer.ServerResourcePackProperties

/**
* Used to access variables from the mixin [ServerPlayerEntityMixin].
* @see ServerPlayerEntityMixin
*/
interface AudiencePlayerAccessor {
fun getLastResourcePack(): ResourcePackProperties?
fun getLastResourcePack(): ServerResourcePackProperties?

fun getResourcePackRequestCallback(): ResourcePackRequestCallback?
fun clearResourcePackRequestCallback(): ResourcePackRequestCallback?
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package dev.andante.audience.resource.server

import com.sun.net.httpserver.HttpServer
import dev.andante.audience.resource.ResourcePack
import net.minecraft.server.MinecraftServer.ServerResourcePackProperties
import net.minecraft.text.Text
import java.net.InetSocketAddress
import java.util.UUID

/**
* A wrapper around an http server for serving resource packs.
Expand Down Expand Up @@ -56,7 +58,7 @@ class ResourcePackServer(
/**
* Registers a resource pack to be handled by this server.
*/
fun registerResourcePack(resourcePack: ResourcePack): ResourcePackProperties {
fun registerResourcePack(resourcePack: ResourcePack): ServerResourcePackProperties {
val hash = resourcePack.hash
httpServer.createContext("/$hash", ResourcePackRequestHandler(resourcePack))
return createResourcePackProperties(resourcePack)
Expand All @@ -69,9 +71,9 @@ class ResourcePackServer(
resourcePack: ResourcePack,
required: Boolean = true,
prompt: Text? = null
): ResourcePackProperties {
): ServerResourcePackProperties {
val url = getUrl(resourcePack)
return ResourcePackProperties(url, resourcePack.hash, required, prompt)
return ServerResourcePackProperties(UUID.nameUUIDFromBytes(resourcePack.bytes), url, resourcePack.hash, required, prompt)
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/dev/andante/audience/test/AudienceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package dev.andante.audience.test

import dev.andante.audience.Audience
import dev.andante.audience.resource.ResourcePack
import dev.andante.audience.resource.server.ResourcePackProperties
import dev.andante.audience.resource.server.ResourcePackServer
import net.fabricmc.api.ModInitializer
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents
import net.fabricmc.fabric.api.event.player.UseItemCallback
import net.minecraft.item.Items
import net.minecraft.server.MinecraftServer.ServerResourcePackProperties
import net.minecraft.util.TypedActionResult
import org.slf4j.LoggerFactory
import java.nio.file.Path
Expand All @@ -16,11 +16,11 @@ import kotlin.io.path.readBytes
object AudienceTest : ModInitializer {
private val byteArray = Path.of("resources.zip").readBytes()
private val resourcePack = ResourcePack(byteArray)
private val properties: ResourcePackProperties
private val properties: ServerResourcePackProperties

private val otherByteArray = Path.of("resources2.zip").readBytes()
private val otherResourcePack = ResourcePack(otherByteArray)
private val otherProperties: ResourcePackProperties
private val otherProperties: ServerResourcePackProperties

private val resourcePackServer = ResourcePackServer("localhost", 25566).apply {
properties = registerResourcePack(resourcePack)
Expand Down

0 comments on commit 3d6ea0d

Please sign in to comment.