Skip to content

Commit

Permalink
fix carpet:hello packet handling for easy place protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
sakura-ryoko committed Jun 22, 2024
1 parent 8e28551 commit 15f2c6f
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 35 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ author = masa
mod_file_name = litematica-fabric

# Current mod version
mod_version = 0.18.999-sakura.7
mod_version = 0.18.999-sakura.8

# Required malilib version
malilib_version = 0.19.999-sakura.3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package fi.dy.masa.litematica.mixin;

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.CallbackInfo;
import net.minecraft.client.network.ClientCommonNetworkHandler;
import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket;
import fi.dy.masa.litematica.Litematica;
import fi.dy.masa.litematica.data.DataManager;

/**
* They keep moving where the effective CustomPayload handling is... keeping them both
*/
@Mixin(ClientCommonNetworkHandler.class)
public class MixinClientCommonNetworkHandler
{
@Inject(method = "onCustomPayload(Lnet/minecraft/network/packet/s2c/common/CustomPayloadS2CPacket;)V", at = @At("HEAD"))
private void litematica_onCustomPayload(CustomPayloadS2CPacket packet, CallbackInfo ci)
{
if (packet.payload().getId().id().equals(DataManager.CARPET_HELLO))
{
Litematica.debugLog("ClientCommonNetworkHandler#litematica_onCustomPayload(): received carpet hello packet");
DataManager.setIsCarpetServer(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.network.packet.s2c.play.ChunkDataS2CPacket;
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
import net.minecraft.network.packet.s2c.play.UnloadChunkS2CPacket;
import fi.dy.masa.litematica.Litematica;
import fi.dy.masa.litematica.config.Configs;
import fi.dy.masa.litematica.data.DataManager;
import fi.dy.masa.litematica.util.SchematicWorldRefresher;
Expand Down Expand Up @@ -53,11 +54,15 @@ private void litematica_onGameMessage(GameMessageS2CPacket packet, CallbackInfo
}
}

/**
* They keep moving where the effective onCustomPayload handling is... keeping them both
*/
@Inject(method = "onCustomPayload", at = @At("HEAD"))
private void litematica_onCustomPayload(CustomPayload payload, CallbackInfo ci)
{
if (payload.getId().id().equals(DataManager.CARPET_HELLO))
{
Litematica.debugLog("MixinClientPlayNetworkHandler#litematica_onCustomPayload(): received carpet hello packet");
DataManager.setIsCarpetServer(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public static EasyPlaceProtocol getEffectiveProtocolVersion()
return EasyPlaceProtocol.SLAB_ONLY;
}

Litematica.debugLog("getEffectiveProtocolVersion(): {}", protocol.name());

return protocol;
}

Expand Down
69 changes: 35 additions & 34 deletions src/main/resources/mixins.litematica.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
{
"required": true,
"package": "fi.dy.masa.litematica.mixin",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
"IMixinChunkDeltaUpdateS2CPacket",
"IMixinEntity",
"IMixinFenceGateBlock",
"IMixinHandledScreen",
"IMixinRedstoneWireBlock",
"IMixinSignBlockEntity",
"IMixinStairsBlock",
"IMixinVineBlock",
"IMixinWorldTickScheduler",
"MixinAbstractSignEditScreen",
"MixinBlock",
"MixinBlockItem",
"MixinBlockStateFlattening",
"MixinChestBlock",
"MixinClientPlayNetworkHandler",
"MixinClientWorld",
"MixinDebugHud",
"MixinHandledScreen",
"MixinIntegratedServer",
"MixinMinecraftClient",
"MixinModelOverrideList",
"MixinRailBlocks",
"MixinServerPlayNetworkHandler",
"MixinWorld",
"MixinWorldChunk",
"MixinWorldRenderer"
],
"injectors": {
"defaultRequire": 1
"required": true,
"package": "fi.dy.masa.litematica.mixin",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
"IMixinChunkDeltaUpdateS2CPacket",
"IMixinEntity",
"IMixinFenceGateBlock",
"IMixinHandledScreen",
"IMixinRedstoneWireBlock",
"IMixinSignBlockEntity",
"IMixinStairsBlock",
"IMixinVineBlock",
"IMixinWorldTickScheduler",
"MixinAbstractSignEditScreen",
"MixinBlock",
"MixinBlockItem",
"MixinBlockStateFlattening",
"MixinChestBlock",
"MixinClientCommonNetworkHandler",
"MixinClientPlayNetworkHandler",
"MixinClientWorld",
"MixinDebugHud",
"MixinHandledScreen",
"MixinIntegratedServer",
"MixinMinecraftClient",
"MixinModelOverrideList",
"MixinRailBlocks",
"MixinServerPlayNetworkHandler",
"MixinWorld",
"MixinWorldChunk",
"MixinWorldRenderer"
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit 15f2c6f

Please sign in to comment.