Merge remote-tracking branch 'origin/1.18' into 1.19.2

This commit is contained in:
embeddedt 2023-04-26 20:56:15 -04:00
commit 4f30edd960
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
3 changed files with 48 additions and 0 deletions

View File

@ -59,6 +59,7 @@ public class ModernFixEarlyConfig {
this.addMixinRule("perf.compress_blockstate", false);
this.addMixinRule("bugfix.concurrency", true);
this.addMixinRule("bugfix.edge_chunk_not_saved", true);
this.addMixinRule("perf.fast_forge_dummies", true);
this.addMixinRule("perf.dynamic_structure_manager", true);
this.addMixinRule("bugfix.chunk_deadlock", true);
this.addMixinRule("perf.thread_priorities", true);

View File

@ -0,0 +1,46 @@
package org.embeddedt.modernfix.mixin.perf.fast_forge_dummies;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistryEntry;
import org.jetbrains.annotations.Nullable;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Map;
import java.util.function.Function;
@Mixin(targets = { "net/minecraftforge/registries/NamespacedHolderHelper" })
public class NamespacedHolderHelperMixin<T extends IForgeRegistryEntry<T>> {
@Shadow private Map<ResourceLocation, Holder.Reference<T>> holdersByName;
@Shadow @Final private @Nullable Function<T, Holder.Reference<T>> holderLookup;
@Shadow private Map<T, Holder.Reference<T>> holders;
@Shadow @Final private Registry<T> self;
@Inject(method = "freeze", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraftforge/registries/NamespacedHolderHelper;holdersByName:Ljava/util/Map;"), cancellable = true, remap = false)
private void fastDummyCheck(CallbackInfoReturnable<Registry<T>> cir) {
// Quickly iterate without making any streams, etc. to see if everything is fine
// Use the slow path (by returning without cancelling) when there is an error
for(Holder.Reference<T> ref : this.holdersByName.values()) {
if(!ref.isBound())
return;
}
if (this.holderLookup != null) {
for(Holder.Reference<T> ref : this.holders.values()) {
if(ref.getType() == Holder.Reference.Type.INTRUSIVE && !ref.isBound())
return;
}
}
// Skip the creation of streams
cir.setReturnValue(this.self);
}
}

View File

@ -14,6 +14,7 @@
"perf.dynamic_structure_manager.StructureManagerMixin",
"bugfix.chunk_deadlock.ServerChunkCacheMixin",
"perf.dedicated_reload_executor.MinecraftServerMixin",
"perf.fast_forge_dummies.NamespacedHolderHelperMixin",
"perf.remove_biome_temperature_cache.BiomeMixin",
"perf.reduce_blockstate_cache_rebuilds.GameDataMixin",
"perf.reduce_blockstate_cache_rebuilds.BlockCallbacksMixin",