Skip to content

Commit

Permalink
Update to 1.20.2, finish up work
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Sep 20, 2023
1 parent 1d7b159 commit c279e4e
Show file tree
Hide file tree
Showing 130 changed files with 2,588 additions and 1,739 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ curseforge {
releaseType = "release"
changelog = System.getenv("CHANGELOG")
changelogType = "markdown"
addGameVersion ((String) project.minecraft_version)
addGameVersion((project.minecraft_version.contains("-") ? ((String) project.minecraft_version.split("-")[0] + "-Snapshot") : project.minecraft_version))
addGameVersion "Fabric"
addGameVersion "Quilt"
mainArtifact(remapJar)
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.20.2-pre1
yarn_mappings=1.20.2-pre1+build.3
minecraft_version=1.20.2-rc2
yarn_mappings=1.20.2-rc2+build.2
loader_version=0.14.22

#Fabric api
fabric_version=0.88.2+1.20.2
fabric_version=0.88.5+1.20.2

maven_group = eu.pb4

mod_version = 0.6.0-alpha.0
mod_version = 0.6.0-rc.1

minecraft_version_supported = ">=1.20-"
minecraft_version_supported = ">=1.20.2-"

packet_tweaker_version = 0.5.0+1.20.2-pre1
packet_tweaker_version = 0.5.0+1.20.2-rc1
mixin_extras_version = 0.2.0-rc.1

is_stable = true
2 changes: 1 addition & 1 deletion polymer-autohost/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ dependencies {

api (project(path: ':polymer-common', configuration: 'namedElements'))
api (project(path: ':polymer-resource-pack', configuration: 'namedElements'))
api (project(path: ':polymer-networking', configuration: 'namedElements'))


testmodImplementation sourceSets.main.output
testmodImplementation (project(path: ':polymer-core', configuration: 'namedElements'))
testmodImplementation (project(path: ':polymer-blocks', configuration: 'namedElements'))
testmodImplementation (project(path: ':polymer-reg-sync-manipulator', configuration: 'namedElements'))
testmodImplementation (project(path: ':polymer-networking', configuration: 'namedElements'))

compileOnly (project(path: ':polymer-virtual-entity', configuration: 'namedElements'))
localRuntime (project(path: ':polymer-virtual-entity', configuration: 'namedElements'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import eu.pb4.polymer.autohost.impl.AutoHost;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.Identifier;

Expand All @@ -23,4 +24,8 @@ static ResourcePackDataProvider getActive() {
static <T> void register(Identifier identifier, Supplier<ResourcePackDataProvider> providerCreator) {
AutoHost.TYPES.put(identifier, providerCreator);
};

default MinecraftServer.ServerResourcePackProperties getProperties() {
return new MinecraftServer.ServerResourcePackProperties(this.getAddress(), this.getHash(), AutoHost.config.require || PolymerResourcePackUtils.isRequired(), AutoHost.message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import eu.pb4.polymer.autohost.impl.providers.WebServerProvider;
import eu.pb4.polymer.common.impl.CommonImpl;
import eu.pb4.polymer.common.impl.CommonImplUtils;
import eu.pb4.polymer.networking.api.EarlyPlayNetworkHandler;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import net.fabricmc.api.ModInitializer;
import net.minecraft.network.packet.s2c.common.ResourcePackSendS2CPacket;
Expand Down Expand Up @@ -53,7 +52,7 @@ public static void init(MinecraftServer server) {
CommonImpl.saveConfig("auto-host", config);


EarlyPlayNetworkHandler.register(ResourcePackNetworkHandler::create);
//EarlyPlayNetworkHandler.register(ResourcePackNetworkHandler::create);
provider.serverStarted(server);
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package eu.pb4.polymer.autohost.mixin;

import eu.pb4.polymer.autohost.impl.AutoHost;
import eu.pb4.polymer.common.api.PolymerCommonUtils;
import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.*;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Queue;

@Mixin(ServerConfigurationNetworkHandler.class)
public abstract class ServerConfigurationNetworkHandlerMixin extends ServerCommonNetworkHandler {
public ServerConfigurationNetworkHandlerMixin(MinecraftServer server, ClientConnection connection, ConnectedClientData clientData) {
super(server, connection, clientData);
}

@Shadow protected abstract void queueSendResourcePackTask();

@Shadow @Final private Queue<ServerPlayerConfigurationTask> tasks;

@Inject(method = "queueSendResourcePackTask", at = @At("HEAD"), cancellable = true)
private void polymerAutoHost$addTask(CallbackInfo ci) {
if (AutoHost.config.enabled && !PolymerCommonUtils.hasResourcePack(this.connection)) {
this.tasks.add(new SendResourcePackTask(AutoHost.provider.getProperties()));
ci.cancel();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"package": "eu.pb4.polymer.autohost.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"MinecraftServerMixin"
"MinecraftServerMixin",
"ServerConfigurationNetworkHandlerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package eu.pb4.polymer.common.api;

import com.mojang.authlib.GameProfile;
import eu.pb4.polymer.common.api.events.SimpleEvent;
import eu.pb4.polymer.common.impl.*;
import eu.pb4.polymer.common.impl.client.ClientUtils;
import eu.pb4.polymer.common.impl.compat.FloodGateUtils;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -18,8 +20,6 @@
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Set;
import java.util.WeakHashMap;

public final class PolymerCommonUtils {
private PolymerCommonUtils(){}
Expand Down Expand Up @@ -115,15 +115,16 @@ public static Path getClientJar() {
*/
public static void executeWithPlayerContext(ServerPlayerEntity player, Runnable runnable) {
var oldPlayer = CommonImplUtils.getPlayer();
var oldTarget = PacketContext.get().getTargetPlayer();
var oldTarget = PacketContext.get().getPlayer();
var oldPacket = PacketContext.get().getEncodedPacket();

CommonImplUtils.setPlayer(player);
PacketContext.setContext(player.networkHandler);
PacketContext.setContext(((CommonNetworkHandlerExt)player.networkHandler).polymerCommon$getConnection(), null);

runnable.run();

CommonImplUtils.setPlayer(oldPlayer);
PacketContext.setContext(oldTarget != null ? oldTarget.networkHandler : null);
PacketContext.setContext(oldTarget != null ? ((CommonNetworkHandlerExt)player.networkHandler).polymerCommon$getConnection() : null, oldPacket);
}


Expand All @@ -146,7 +147,7 @@ public static ServerPlayerEntity getPlayerContext() {

@Nullable
public static ServerPlayerEntity getPlayerContextNoClient() {
ServerPlayerEntity player = PacketContext.get().getTargetPlayer();
ServerPlayerEntity player = PacketContext.get().getPlayer();

if (player == null) {
player = CommonImplUtils.getPlayer();
Expand All @@ -159,16 +160,34 @@ public static boolean isNetworkingThread() {
return Thread.currentThread().getName().startsWith("Netty");
}

public static boolean isServerNetworkingThread() {
return isNetworkingThread() && Thread.currentThread().getName().contains("Server");
}

public static boolean isBedrockPlayer(ServerPlayerEntity player) {
if (CompatStatus.FLOODGATE) {
return FloodGateUtils.isPlayerBroken(player);
}
return false;
}

public static boolean isBedrockPlayer(GameProfile profile) {
if (CompatStatus.FLOODGATE) {
return FloodGateUtils.isPlayerBroken(profile);
}
return false;
}

public static boolean hasResourcePack(@Nullable ServerPlayerEntity player) {
return CommonImpl.FORCE_RESOURCEPACK_ENABLED_STATE || (player != null && ((CommonResourcePackInfoHolder) player).polymerCommon$hasResourcePack())
|| (player != null && ((CommonResourcePackInfoHolder) player).polymerCommon$hasResourcePack())
return CommonImpl.FORCE_RESOURCEPACK_ENABLED_STATE
|| (player != null && player.networkHandler != null && ((CommonClientConnectionExt) ((CommonNetworkHandlerExt) player.networkHandler)
.polymerCommon$getConnection()).polymerCommon$hasResourcePack())
|| (CommonImpl.IS_CLIENT && ClientUtils.isResourcePackLoaded());
}

public static boolean hasResourcePack(ClientConnection connection) {
return CommonImpl.FORCE_RESOURCEPACK_ENABLED_STATE
|| ((CommonClientConnectionExt) connection).polymerCommon$hasResourcePack()
|| (CommonImpl.IS_CLIENT && ClientUtils.isResourcePackLoaded());
}

Expand All @@ -180,6 +199,10 @@ public static boolean isServerBound() {
return true;
}

public static void setHasResourcePack(ServerPlayerEntity player, boolean status) {
((CommonClientConnectionExt) ((CommonNetworkHandlerExt) player.networkHandler).polymerCommon$getConnection()).polymerCommon$setResourcePack(status);
}

public interface ResourcePackChangeCallback {
void onResourcePackChange(ServerPlayNetworkHandler handler, boolean oldStatus, boolean newStatus);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

@ApiStatus.Internal
@SuppressWarnings({"unused"})
public interface CommonResourcePackInfoHolder {
public interface CommonClientConnectionExt {
boolean polymerCommon$hasResourcePack();

void polymerCommon$setResourcePack(boolean value);
void polymerCommon$setResourcePackNoEvent(boolean value);

void polymerCommon$setIgnoreNextResourcePack();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package eu.pb4.polymer.common.impl;

import net.minecraft.network.ClientConnection;
import org.jetbrains.annotations.ApiStatus;

@ApiStatus.Internal
@SuppressWarnings({"unused"})
public interface CommonNetworkHandlerExt {
void polymerCommon$setIgnoreNextResourcePack();
ClientConnection polymerCommon$getConnection();
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package eu.pb4.polymer.common.impl.compat;

import com.mojang.authlib.GameProfile;
import net.minecraft.server.network.ServerPlayerEntity;
import org.geysermc.floodgate.api.FloodgateApi;

import java.util.UUID;

public class FloodGateUtils {
public static boolean isPlayerBroken(ServerPlayerEntity player) {
return FloodgateApi.getInstance().isFloodgatePlayer(player.getUuid());
}

public static boolean isPlayerBroken(GameProfile profile) {
return FloodgateApi.getInstance().isFloodgatePlayer(profile.getId());
}
}
Loading

0 comments on commit c279e4e

Please sign in to comment.