Skip to content

Commit

Permalink
Registry sync v2 - API (#167)
Browse files Browse the repository at this point in the history
* Initial work on registry-sync-v2

* More progress on registry api v2
- differentiate "synced" Index-Key-Value registries from simple Key-Value registries
- start preparing registry remapping

* Start working on new registry remapper

* Rename some classes

* Port remapping system to v2 and port to every supported version

* Ensure backward compatibility with registry-sync-api-v1

* Fix a few possible crashes when using registries

* Add more useful methods to RegistryHelper

* Make vanilla registries first assignable id 1 instead of 0

* Some improvements and bug fixes.

* Create a default implementation of IdsHolder and SyncedRegistrableRegistry.

* Start working on wrapper for non-standard registry forms

* Clean up and fix style

* Fix missing events in MapRegistryWrapper

* Avoid using sysout

* Allow Synchronized Registry to declare themselves not to be synchronized

* Allow setting the min id possible of a registry

* Fix entry count in IdsHolder

* SyncedArrayMapRegistryWrapper

* Make Map+Array-based registry min id be 1 instead of 0

* SyncedArrayRegistryWrapper

* RegistryWrapper Improvements

* Fix defaulted registries default value not being interpreted as entry missing when it should.

* Fix defaulted registries default value not being interpreted as entry missing when it should. (again)

* Allow registering multiple entries together with a defined offset between their numerical ids.

* Fix missing ids being taken over by new entries when entering an existing world

* Fix style

* Fix style and compiling errors

* Disable complex registering for now

* Clean up registry-sync-v1

* apache commons lang3 isn't available in 1.7.10

* Fix some parameter names

* Add javadoc to deprecated classes and members

* Rename some api classes/interfaces

* Fix style

* Small mixins clean-up

* Document registry-sync-v2 apis + Add missing utility methods
  • Loading branch information
thecatcore authored Dec 22, 2024
1 parent 77f3414 commit 0524871
Show file tree
Hide file tree
Showing 218 changed files with 3,245 additions and 8,428 deletions.
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ allprojects {
useLegacyMixinAp = true
}

interfaceInjection {
enableDependencyInterfaceInjection = true
}

runs {
"testModClient$mcVersion" {
client()
Expand Down Expand Up @@ -443,7 +447,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.1
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;
}

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);
return writeNbtCompound(compound);
}
}
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,20 +15,20 @@
* 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) {
Expand Down
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,20 +15,20 @@
* 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) {
Expand Down
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.

This file was deleted.

Loading

0 comments on commit 0524871

Please sign in to comment.