1.16.2-pre1

This commit is contained in:
modmuss50 2020-07-29 16:52:10 +01:00
parent deaf48319c
commit bf0e62bd42
3 changed files with 22 additions and 13 deletions
build.gradle
fabric-registry-sync-v0
build.gradle
src/main/java/net/fabricmc/fabric/mixin/registry/sync

View file

@ -18,8 +18,8 @@ plugins {
def ENV = System.getenv()
class Globals {
static def baseVersion = "0.16.0"
static def mcVersion = "20w30a"
static def baseVersion = "0.16.1"
static def mcVersion = "1.16.2-pre1"
static def yarnVersion = "+build.1"
}

View file

@ -1,5 +1,5 @@
archivesBaseName = "fabric-registry-sync-v0"
version = getSubprojectVersion(project, "0.3.10")
version = getSubprojectVersion(project, "0.4.0")
dependencies {
compile project(path: ':fabric-api-base', configuration: 'dev')

View file

@ -31,8 +31,10 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.ObjectList;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
@ -41,7 +43,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.Int2ObjectBiMap;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.SimpleRegistry;
import net.minecraft.util.registry.RegistryKey;
@ -59,11 +60,17 @@ import net.fabricmc.fabric.impl.registry.sync.RemappableRegistry;
@Mixin(SimpleRegistry.class)
public abstract class MixinIdRegistry<T> implements RemappableRegistry, ListenableRegistry {
@Shadow
protected Int2ObjectBiMap<T> indexedEntries;
@Final
private ObjectList<T> field_26682;
@Shadow
protected BiMap<Identifier, T> entriesById;
@Final
private Object2IntMap<T> field_26683;
@Shadow
protected BiMap<RegistryKey<T>, T> entriesByKey;
@Final
private BiMap<Identifier, T> entriesById;
@Shadow
@Final
private BiMap<RegistryKey<T>, T> entriesByKey;
@Shadow
private int nextId;
@Unique
@ -129,7 +136,7 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
@SuppressWarnings({"unchecked", "ConstantConditions"})
@Inject(method = "set", at = @At("HEAD"))
public void setPre(int id, RegistryKey<T> registryId, Object object, CallbackInfoReturnable info) {
int indexedEntriesId = indexedEntries.getRawId((T) object);
int indexedEntriesId = field_26683.getInt((T) object);
if (indexedEntriesId >= 0) {
throw new RuntimeException("Attempted to register object " + object + " twice! (at raw IDs " + indexedEntriesId + " and " + id + " )");
@ -141,7 +148,7 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
T oldObject = entriesById.get(registryId.getValue());
if (oldObject != null && oldObject != object) {
int oldId = indexedEntries.getRawId(oldObject);
int oldId = field_26683.getInt(oldObject);
if (oldId != id) {
throw new RuntimeException("Attempted to register ID " + registryId + " at different raw IDs (" + oldId + ", " + id + ")! If you're trying to override an item, use .set(), not .register()!");
@ -298,7 +305,7 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
Int2IntMap idMap = new Int2IntOpenHashMap();
for (Object o : indexedEntries) {
for (Object o : field_26682) {
Identifier id = registry.getId(o);
int rid = registry.getRawId(o);
@ -309,7 +316,8 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
}
// entries was handled above, if it was necessary.
indexedEntries.clear();
field_26682.clear();
field_26683.clear();
nextId = 0;
List<Identifier> orderedRemoteEntries = new ArrayList<>(remoteIndexedEntries.keySet());
@ -333,7 +341,8 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
}
// Add the new object, increment nextId to match.
indexedEntries.put(object, id);
field_26682.set(id, object);
field_26683.put(object, id);
if (nextId <= id) {
nextId = id + 1;
@ -370,7 +379,7 @@ public abstract class MixinIdRegistry<T> implements RemappableRegistry, Listenab
remap(name, fabric_prevIndexedEntries, RemapMode.AUTHORITATIVE);
for (Identifier id : addedIds) {
fabric_getAddObjectEvent().invoker().onEntryAdded(indexedEntries.getRawId(entriesById.get(id)), id, entriesById.get(id));
fabric_getAddObjectEvent().invoker().onEntryAdded(field_26683.getInt(entriesById.get(id)), id, entriesById.get(id));
}
fabric_prevIndexedEntries = null;