Skip to content

Commit

Permalink
Port remapping system to v2 and port to every supported version
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed May 5, 2024
1 parent dec3757 commit 6f5bf3b
Show file tree
Hide file tree
Showing 52 changed files with 868 additions and 336 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.legacyfabric.fabric.mixin.networking.versioned;

import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.PacketByteBuf;

import net.legacyfabric.fabric.impl.networking.PacketByteBufExtension;

@Mixin(PacketByteBuf.class)
public abstract class PacketByteBufMixin implements PacketByteBufExtension {
@Shadow
public abstract PacketByteBuf writeNbtCompound(@Nullable NbtCompound nbt);

@Override
public PacketByteBuf writeCompound(NbtCompound tag) {
return writeNbtCompound(tag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import net.legacyfabric.fabric.impl.networking.PacketByteBufExtension;

@Mixin(PacketByteBuf.class)
public class PacketByteBufMixin implements PacketByteBufExtension {
public abstract class PacketByteBufMixin implements PacketByteBufExtension {
@Override
@Environment(EnvType.CLIENT)
public Packet createCustomPayloadC2SPacket(String channelName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.legacyfabric.fabric.mixin.networking.versioned;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.PacketByteBuf;

import net.legacyfabric.fabric.impl.networking.PacketByteBufExtension;

@Mixin(PacketByteBuf.class)
public abstract class PacketByteBufMixin implements PacketByteBufExtension {
@Shadow
public abstract void writeNbtCompound(NbtCompound par1);

@Override
public PacketByteBuf writeCompound(NbtCompound tag) {
this.writeNbtCompound(tag);
return (PacketByteBuf) (Object) this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"CustomPayloadC2SPacketMixin",
"MinecraftServerMixin",
"PacketByteBufMixin",
"PlayerManagerMixin"
"PlayerManagerMixin",
"versioned.PacketByteBufMixin"
],
"client": [
"client.CustomPayloadS2CPacketMixin",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.legacyfabric.fabric.mixin.networking.versioned;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.PacketByteBuf;

import net.legacyfabric.fabric.impl.networking.PacketByteBufExtension;

@Mixin(PacketByteBuf.class)
public abstract class PacketByteBufMixin implements PacketByteBufExtension {
@Shadow
public abstract void writeNbtCompound(NbtCompound par1);

@Override
public PacketByteBuf writeCompound(NbtCompound tag) {
this.writeNbtCompound(tag);
return (PacketByteBuf) (Object) this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"ClientConnectionMixin",
"CustomPayloadC2SPacketMixin",
"MinecraftServerMixin",
"PlayerManagerMixin"
"PlayerManagerMixin",
"versioned.PacketByteBufMixin"
],
"client": [
"client.CustomPayloadS2CPacketMixin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@

package net.legacyfabric.fabric.impl.networking;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.Packet;
import net.minecraft.util.PacketByteBuf;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

public interface PacketByteBufExtension {
@Environment(EnvType.CLIENT)
Packet createCustomPayloadC2SPacket(String channelName);
Packet createCustomPayloadS2CPacket(String channelName);
default Packet createCustomPayloadC2SPacket(String channelName) {
return null;
}
default Packet createCustomPayloadS2CPacket(String channelName) {
return null;
}

PacketByteBuf writeCompound(NbtCompound tag);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"mixins": [
"SimpleRegistryMixin",
"class_2929Mixin",
"PlayerManagerMixin",
"BlockMixin",
"ItemMixin",
"PacketByteBufMixin",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"mixins": [
"SimpleRegistryMixin",
"class_2929Mixin",
"PlayerManagerMixin",
"BlockMixin",
"ItemMixin",
"PacketByteBufMixin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
},
"mixins": [
"SimpleRegistryMixin",
"PlayerManagerMixin",
"PacketByteBufMixin",
"BlockEntityAccessor",
"BlockEntityMixin",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
accessWidener v1 named
accessWidener v2 named

accessible method net/minecraft/block/Block <init> (Lnet/minecraft/block/material/Material;)V
transitive-accessible method net/minecraft/block/Block <init> (Lnet/minecraft/block/material/Material;)V

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
},
"mixins": [
"SimpleRegistryMixin",
"PlayerManagerMixin",
"BlockMixin",
"ItemMixin",
"PacketByteBufMixin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
},
"mixins": [
"SimpleRegistryMixin",
"PlayerManagerMixin",
"BlockMixin",
"ItemMixin",
"PacketByteBufMixin",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
accessWidener v1 named
accessWidener v2 named

accessible method net/minecraft/block/Block <init> (Lnet/minecraft/block/material/Material;)V
transitive-accessible method net/minecraft/block/Block <init> (Lnet/minecraft/block/material/Material;)V
Loading

0 comments on commit 6f5bf3b

Please sign in to comment.