Fix MC-218112
This commit is contained in:
parent
cc79bf7274
commit
db95e37d22
|
|
@ -36,6 +36,7 @@ public class ModernFixEarlyConfig {
|
||||||
this.addMixinRule("bugfix.edge_chunk_not_saved", true);
|
this.addMixinRule("bugfix.edge_chunk_not_saved", true);
|
||||||
this.addMixinRule("bugfix.packet_leak", false);
|
this.addMixinRule("bugfix.packet_leak", false);
|
||||||
this.addMixinRule("bugfix.structure_manager_crash", true);
|
this.addMixinRule("bugfix.structure_manager_crash", true);
|
||||||
|
this.addMixinRule("bugfix.mc218112", true);
|
||||||
this.addMixinRule("perf.async_jei", true);
|
this.addMixinRule("perf.async_jei", true);
|
||||||
this.addMixinRule("perf.thread_priorities", true);
|
this.addMixinRule("perf.thread_priorities", true);
|
||||||
this.addMixinRule("perf.preload_block_classes", false);
|
this.addMixinRule("perf.preload_block_classes", false);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package org.embeddedt.modernfix.mixin.bugfix.mc218112;
|
||||||
|
|
||||||
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
|
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.CallbackInfo;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
|
|
||||||
|
@Mixin(SynchedEntityData.class)
|
||||||
|
public class SynchedEntityDataMixin {
|
||||||
|
@Shadow @Final private Map<Integer, SynchedEntityData.DataItem<?>> itemsById;
|
||||||
|
|
||||||
|
@Shadow @Final private ReadWriteLock lock;
|
||||||
|
|
||||||
|
@Shadow private boolean isEmpty;
|
||||||
|
|
||||||
|
@Inject(method = "createDataItem", at = @At(value = "INVOKE", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
|
||||||
|
private <T> void putWithLock(EntityDataAccessor<T> key, T value, CallbackInfo ci, SynchedEntityData.DataItem<T> item) {
|
||||||
|
ci.cancel();
|
||||||
|
try {
|
||||||
|
this.itemsById.put(key.getId(), item);
|
||||||
|
this.isEmpty = false;
|
||||||
|
} finally {
|
||||||
|
this.lock.writeLock().unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package org.embeddedt.modernfix.mixin.bugfix.mc218112;
|
||||||
|
|
||||||
|
import net.minecraft.network.syncher.SynchedEntityData;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Overwrite;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
|
|
||||||
|
@Mixin(SynchedEntityData.class)
|
||||||
|
public abstract class SynchedEntityDataMixin_Client {
|
||||||
|
@Shadow @Final private ReadWriteLock lock;
|
||||||
|
|
||||||
|
@Shadow private boolean isDirty;
|
||||||
|
|
||||||
|
@Shadow protected abstract <T> void assignValue(SynchedEntityData.DataItem<T> target, SynchedEntityData.DataItem<?> source);
|
||||||
|
|
||||||
|
@Shadow @Final private Entity entity;
|
||||||
|
|
||||||
|
@Shadow @Final private Map<Integer, SynchedEntityData.DataItem<?>> itemsById;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author embeddedt
|
||||||
|
* @reason always unlock
|
||||||
|
*/
|
||||||
|
@Overwrite
|
||||||
|
public void assignValues(List<SynchedEntityData.DataItem<?>> entries) {
|
||||||
|
this.lock.writeLock().lock();
|
||||||
|
try {
|
||||||
|
for(SynchedEntityData.DataItem<?> dataentry : entries) {
|
||||||
|
SynchedEntityData.DataItem<?> dataentry1 = this.itemsById.get(dataentry.getAccessor().getId());
|
||||||
|
if (dataentry1 != null) {
|
||||||
|
this.assignValue(dataentry1, dataentry);
|
||||||
|
this.entity.onSyncedDataUpdated(dataentry.getAccessor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
this.lock.writeLock().unlock();
|
||||||
|
}
|
||||||
|
this.isDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -52,6 +52,7 @@
|
||||||
"perf.fast_registry_validation.ForgeRegistryMixin",
|
"perf.fast_registry_validation.ForgeRegistryMixin",
|
||||||
"perf.cache_strongholds.ChunkGeneratorMixin",
|
"perf.cache_strongholds.ChunkGeneratorMixin",
|
||||||
"perf.cache_upgraded_structures.StructureManagerMixin",
|
"perf.cache_upgraded_structures.StructureManagerMixin",
|
||||||
|
"bugfix.mc218112.SynchedEntityDataMixin",
|
||||||
"perf.cache_strongholds.ServerLevelMixin"
|
"perf.cache_strongholds.ServerLevelMixin"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
|
|
@ -94,6 +95,7 @@
|
||||||
"perf.reuse_datapacks.MinecraftServerMixin",
|
"perf.reuse_datapacks.MinecraftServerMixin",
|
||||||
"perf.use_integrated_resources.LootTableHelperMixin",
|
"perf.use_integrated_resources.LootTableHelperMixin",
|
||||||
"perf.use_integrated_resources.PiglinBarteringRecipeBuilderMixin",
|
"perf.use_integrated_resources.PiglinBarteringRecipeBuilderMixin",
|
||||||
|
"bugfix.mc218112.SynchedEntityDataMixin_Client",
|
||||||
"perf.faster_singleplayer_load.MinecraftServerMixin"
|
"perf.faster_singleplayer_load.MinecraftServerMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user