Skip to content

Commit

Permalink
Update used asset jar, update immersive portals compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Oct 9, 2023
1 parent ff3e580 commit ab40ae0
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 118 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fabric_version=0.89.1+1.20.2

maven_group = eu.pb4

mod_version = 0.6.0
mod_version = 0.6.1

minecraft_version_supported = ">=1.20.2-"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private PolymerCommonUtils(){}

public static final SimpleEvent<ResourcePackChangeCallback> ON_RESOURCE_PACK_STATUS_CHANGE = new SimpleEvent<>();
private static Path cachedClientPath;
private final static String SAFE_CLIENT_SHA1 = "e575a48efda46cf88111ba05b624ef90c520eef1";
private final static String SAFE_CLIENT_SHA1 = "82d1974e75fc984c5ed4b038e764e50958ac61a0";
private final static String SAFE_CLIENT_URL = "https://piston-data.mojang.com/v1/objects/" + SAFE_CLIENT_SHA1 + "/client.jar";
private static Path cachedClientJarRoot;

Expand Down
4 changes: 2 additions & 2 deletions polymer-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ dependencies {
modCompileOnly("xyz.nucleoid:server-translations-api:2.0.0-beta.2+1.19.4-pre2")
//modLocalRuntime("xyz.nucleoid:server-translations-api:2.0.0-beta.2+1.19.4-pre2")

modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v3.0.2-mc1.20'
modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:4.0.1-mc1.20.2'
//modLocalRuntime 'com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v3.0.2-mc1.20'
modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:v3.0.2-mc1.20'
modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:v4.0.1-mc1.20.2'
//modLocalRuntime 'com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:v3.0.2-mc1.20'

//modLocalRuntime 'maven.modrinth:immersiveportals:v3.0.2-mc1.20'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

import eu.pb4.polymer.core.impl.networking.BlockPacketUtil;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import qouteall.imm_ptl.core.ducks.IECustomPayloadPacket;
import qouteall.imm_ptl.core.network.PacketRedirection;
import qouteall.q_misc_util.dimension.DimensionIdRecord;

import java.util.Objects;

public class ImmersivePortalsUtils {
public static void sendBlockPackets(ServerPlayNetworkHandler handler, Packet<?> packet) {
if (packet instanceof IECustomPayloadPacket attachedPacket && attachedPacket.ip_getRedirectedPacket() != null && attachedPacket.ip_getRedirectedDimension() != null) {
PacketRedirection.withForceRedirect(handler.player.getServer().getWorld(attachedPacket.ip_getRedirectedDimension()), () -> {
BlockPacketUtil.sendFromPacket(attachedPacket.ip_getRedirectedPacket(), handler);
if (packet instanceof CustomPayloadS2CPacket payloadS2CPacket && payloadS2CPacket.payload() instanceof PacketRedirection.Payload payload) {
PacketRedirection.withForceRedirect(Objects.requireNonNull(handler.player.getServer().getWorld(DimensionIdRecord.serverRecord.getDim(payload.dimensionIntId()))), () -> {
BlockPacketUtil.sendFromPacket(payload.packet(), handler);
});
} else {
BlockPacketUtil.sendFromPacket(packet, handler);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package eu.pb4.polymer.core.mixin.compat.immersive_portals;

import eu.pb4.polymer.common.impl.CommonImplUtils;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.chunk.WorldChunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import qouteall.imm_ptl.core.chunk_loading.PlayerChunkLoading;


@Pseudo
@Mixin(value = PlayerChunkLoading.class)
public class ip_PlayerChunkLoadingMixin {
@Inject(method = "sendChunkPacket", at = @At("HEAD"), require = 0)
private static void polymer_setPlayerNow(ServerPlayNetworkHandler serverGamePacketListenerImpl, ServerWorld serverLevel, WorldChunk levelChunk, CallbackInfo ci) {
CommonImplUtils.setPlayer(serverGamePacketListenerImpl.getPlayer());
}

@Inject(method = "sendChunkPacket", at = @At("TAIL"), require = 0)
private static void polymer_resetPlayer(ServerPlayNetworkHandler serverGamePacketListenerImpl, ServerWorld serverLevel, WorldChunk levelChunk, CallbackInfo ci) {
CommonImplUtils.setPlayer(null);
}
}
2 changes: 1 addition & 1 deletion polymer-core/src/main/resources/polymer-core.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"compat.lithium_BlockPaletteMixin",
"compat.fabric.fabricNetworking_ServerPlayNetworking",
"compat.fabric.fabricSync_StateIdTrackerMixin",
"compat.immersive_portals.ip_ChunkDataSyncManagerMixin",
"compat.immersive_portals.ip_PlayerChunkLoadingMixin",
"compat.polymc.polymc_BlockPolyGeneratorMixin",
"entity.AbstractMinecartEntityAccessor",
"entity.DataTrackerAccessor",
Expand Down
4 changes: 2 additions & 2 deletions polymer-virtual-entity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ dependencies {
//modCompileOnly ('nl.theepicblock:PolyMc:5.1.0+1.19')
api include(project(path: ':polymer-common', configuration: 'namedElements'))

modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v3.0.2-mc1.20'
modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:v3.0.2-mc1.20'
modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v4.0.1-mc1.20.2'
modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:v4.0.1-mc1.20.2'
}

afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.chunk.WorldChunk;
import org.jetbrains.annotations.ApiStatus;
import qouteall.imm_ptl.core.chunk_loading.NewChunkTrackingGraph;
import qouteall.imm_ptl.core.chunk_loading.ImmPtlChunkTracking;
import qouteall.imm_ptl.core.network.PacketRedirection;


@ApiStatus.Internal
public class ImmersivePortalsUtils {
public static boolean isPlayerTracking(ServerPlayerEntity player, WorldChunk chunk) {
return NewChunkTrackingGraph.isPlayerWatchingChunk(player, chunk.getWorld().getRegistryKey(), chunk.getPos().x, chunk.getPos().z);
return ImmPtlChunkTracking.isPlayerWatchingChunk(player, chunk.getWorld().getRegistryKey(), chunk.getPos().x, chunk.getPos().z);
}

public static void callRedirected(ServerWorld world, Runnable runnable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class ChunkDataSenderMixin {
}
}

@Inject(method = "unload", at = @At("HEAD"))
@Inject(method = "unload", at = @At("HEAD"), require = 0)
private void polymerVE$chunkUnload(ServerPlayerEntity player, ChunkPos pos, CallbackInfo ci) {
for (var holder : new ArrayList<>(((HolderHolder) player.networkHandler).polymer$getHolders())) {
if (holder.getAttachment() != null && holder.getChunkPos().equals(pos)) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package eu.pb4.polymer.virtualentity.mixin.compat;

import com.llamalad7.mixinextras.sugar.Local;
import eu.pb4.polymer.virtualentity.impl.HolderHolder;
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import net.minecraft.registry.RegistryKey;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import qouteall.imm_ptl.core.chunk_loading.ImmPtlChunkTracking;

import java.util.ArrayList;
import java.util.Map;

@Mixin(ImmPtlChunkTracking.class)
public class ip_ImmPtlChunkTracking {
@Inject(method = "lambda$purge$5", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V"), require = 0)
private static void polymerVE$chunkUnload(Map.Entry e, CallbackInfoReturnable<Boolean> cir, @Local ServerPlayerEntity player, @Local ImmPtlChunkTracking.PlayerWatchRecord record) {
for (var holder : new ArrayList<>(((HolderHolder) player.networkHandler).polymer$getHolders())) {
if (holder.getAttachment() != null && holder.getChunkPos().toLong() == record.chunkPos) {
holder.getAttachment().updateTracking(player.networkHandler);
}
}
}

@Inject(method = "lambda$forceRemovePlayer$16", at = @At(value = "INVOKE", target = "Lqouteall/imm_ptl/core/network/PacketRedirection;sendRedirectedMessage(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/network/packet/Packet;)V"), require = 0)
private static void polymerVE$chunkUnload2(ServerPlayerEntity player, RegistryKey dim, Long2ObjectMap.Entry e, CallbackInfoReturnable<Boolean> cir, @Local ImmPtlChunkTracking.PlayerWatchRecord rec) {
for (var holder : new ArrayList<>(((HolderHolder) player.networkHandler).polymer$getHolders())) {
if (holder.getAttachment() != null && holder.getChunkPos().toLong() == rec.chunkPos) {
holder.getAttachment().updateTracking(player.networkHandler);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package eu.pb4.polymer.virtualentity.mixin.compat;

import eu.pb4.polymer.virtualentity.impl.HolderAttachmentHolder;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.chunk.WorldChunk;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import qouteall.imm_ptl.core.chunk_loading.PlayerChunkLoading;
import qouteall.imm_ptl.core.network.PacketRedirection;

@Pseudo
@Mixin(value = PlayerChunkLoading.class)
public class ip_PlayerChunkLoadingMixin {

@Inject(method = "sendChunkPacket", at = @At("TAIL"), require = 0)
private static void polymerVE$addToPlayerPlayer(ServerPlayNetworkHandler serverGamePacketListenerImpl, ServerWorld serverLevel, WorldChunk levelChunk, CallbackInfo ci) {
if (!serverGamePacketListenerImpl.player.isDead()) {
PacketRedirection.withForceRedirect(serverLevel, () -> {
for (var hologram : ((HolderAttachmentHolder) levelChunk).polymerVE$getHolders()) {
hologram.startWatching(serverGamePacketListenerImpl);
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"block.ServerWorldMixin",
"block.ThreadedAnvilChunkStorageMixin",
"block.WorldChunkMixin",
"compat.ip_ChunkDataSyncManagerMixin"
"compat.ip_ImmPtlChunkTracking",
"compat.ip_PlayerChunkLoadingMixin"
],
"client": [
],
Expand Down

0 comments on commit ab40ae0

Please sign in to comment.