Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registry sync v2 - API #167

Open
wants to merge 31 commits into
base: feature/registry-sync-v2/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ec8fbe7
Initial work on registry-sync-v2
thecatcore Mar 17, 2024
58f6a52
More progress on registry api v2
thecatcore Mar 23, 2024
2b0538b
Start working on new registry remapper
thecatcore Mar 24, 2024
aa17b4a
Rename some classes
thecatcore Apr 24, 2024
69b1df9
Port remapping system to v2 and port to every supported version
thecatcore May 5, 2024
10653d6
Ensure backward compatibility with registry-sync-api-v1
thecatcore May 5, 2024
7f88334
Fix a few possible crashes when using registries
thecatcore May 7, 2024
285e4a9
Add more useful methods to RegistryHelper
thecatcore May 7, 2024
40eff6f
Make vanilla registries first assignable id 1 instead of 0
thecatcore May 8, 2024
612a85d
Some improvements and bug fixes.
thecatcore May 8, 2024
1f29898
Create a default implementation of IdsHolder and SyncedRegistrableReg…
thecatcore May 8, 2024
f5d879f
Start working on wrapper for non-standard registry forms
thecatcore May 8, 2024
134b16d
Clean up and fix style
thecatcore May 8, 2024
3664dd9
Fix missing events in MapRegistryWrapper
thecatcore May 8, 2024
a8f6652
Avoid using sysout
thecatcore May 8, 2024
fd13568
Allow Synchronized Registry to declare themselves not to be synchronized
thecatcore May 8, 2024
719d9cb
Allow setting the min id possible of a registry
thecatcore Jun 6, 2024
fc96dd5
Fix entry count in IdsHolder
thecatcore Jun 6, 2024
d405761
SyncedArrayMapRegistryWrapper
thecatcore Aug 29, 2024
4cf43de
Make Map+Array-based registry min id be 1 instead of 0
thecatcore Jun 6, 2024
8b54985
SyncedArrayRegistryWrapper
thecatcore Aug 29, 2024
79f8851
RegistryWrapper Improvements
thecatcore Aug 29, 2024
22fc4f2
Fix defaulted registries default value not being interpreted as entry…
thecatcore Jul 6, 2024
4954eae
Fix defaulted registries default value not being interpreted as entry…
thecatcore Jul 9, 2024
ea04cdb
Allow registering multiple entries together with a defined offset bet…
thecatcore Aug 29, 2024
3866502
Fix missing ids being taken over by new entries when entering an exis…
thecatcore Jul 20, 2024
32e5666
Fix style
thecatcore Aug 29, 2024
8b323b7
Fix style and compiling errors
thecatcore Aug 29, 2024
d5e2551
Disable complex registering for now
thecatcore Aug 29, 2024
3a74c69
Clean up registry-sync-v1
thecatcore Aug 29, 2024
f6a4d3c
apache commons lang3 isn't available in 1.7.10
thecatcore Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ allprojects {
useLegacyMixinAp = true
}

interfaceInjection {
enableDependencyInterfaceInjection = true
}

runs {
"testModClient$mcVersion" {
client()
Expand Down Expand Up @@ -451,7 +455,8 @@ def addPomMetadataInformation(Project project, MavenPom pom) {
def modJsonFile = project.file("src/main/resources/fabric.mod.json")

if (!modJsonFile.exists()) {
modJsonFile = project.file("src/client/resources/fabric.mod.json")
logger.error("Can't find fabric.mod.json at ${modJsonFile.toString()}!")
return;
}

def modJson = new JsonSlurper().parse(modJsonFile)
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ legacy-fabric-logger-api-v1.version = 1.0.4
legacy-fabric-networking-api-v1.version = 2.0.2
legacy-fabric-permissions-api-v1.version = 1.1.0
legacy-fabric-registry-sync-api-v1.version = 2.2.0
legacy-fabric-registry-sync-api-v2.version = 1.0.0
legacy-fabric-rendering-api-v1.version = 1.0.0
legacy-fabric-resource-loader-v1.version = 2.2.2
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public String toString() {
return this.namespace + ':' + this.path;
}

public String toTranslationKey() {
return this.namespace + "." + this.path;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused - any reason why we need this? items, blocks and such have their own format for translation keys

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used later in the registry implementation to set the translation key automatically, which was something already done in registry sync v1 previously.

}

public boolean equals(Object object) {
if (this == object) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@
* limitations under the License.
*/

package net.legacyfabric.fabric.mixin.registry.sync;
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.registry.sync.compat.PacketByteBufCompat;
import net.legacyfabric.fabric.impl.networking.PacketByteBufExtension;

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

@Override
public PacketByteBuf writeCompound(NbtCompound compound) {
return this.writeNbtCompound(compound);
public PacketByteBuf writeCompound(NbtCompound tag) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tag -> nbt / compound

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
Expand Up @@ -15,24 +15,24 @@
* limitations under the License.
*/

package net.legacyfabric.fabric.mixin.registry.sync;
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.registry.sync.compat.PacketByteBufCompat;
import net.legacyfabric.fabric.impl.networking.PacketByteBufExtension;

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

@Override
public PacketByteBuf writeCompound(NbtCompound compound) {
this.writeNbtCompound(compound);
public PacketByteBuf writeCompound(NbtCompound tag) {
this.writeNbtCompound(tag);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tag -> nbt / compound

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
Expand Up @@ -15,24 +15,24 @@
* limitations under the License.
*/

package net.legacyfabric.fabric.mixin.registry.sync;
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.registry.sync.compat.PacketByteBufCompat;
import net.legacyfabric.fabric.impl.networking.PacketByteBufExtension;

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

@Override
public PacketByteBuf writeCompound(NbtCompound compound) {
this.writeNbtCompound(compound);
public PacketByteBuf writeCompound(NbtCompound tag) {
this.writeNbtCompound(tag);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

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);
}
2 changes: 0 additions & 2 deletions legacy-fabric-registry-sync-api-v1/1.10.2/gradle.properties

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading