Fix MC-149777 - java.util.ConcurrentModificationException when using Java 11 or above (#1176)

* Fix MC-149777

* Fix license
This commit is contained in:
modmuss50 2020-11-23 19:32:55 +00:00 committed by GitHub
parent 23017ec78b
commit 55442f3ace
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.structure;
import java.util.Collections;
import java.util.Map;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
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 net.minecraft.structure.Structure;
import net.minecraft.structure.StructureManager;
import net.minecraft.util.Identifier;
/**
* This fixes a rare CME in the StructureManager when using Java 11 or newer.
*
* <p>See: https://bugs.mojang.com/browse/MC-149777
*
*/
@Mixin(StructureManager.class)
public abstract class StructureManagerMixin {
@Shadow
@Final
@Mutable
private Map<Identifier, Structure> structures;
@Inject(method = "<init>", at = @At(value = "RETURN"))
private void init(CallbackInfo info) {
structures = Collections.synchronizedMap(structures);
}
}

View file

@ -9,6 +9,7 @@
"MixinChunkGeneratorSettings", "MixinChunkGeneratorSettings",
"MixinStructuresConfig", "MixinStructuresConfig",
"StructureFeatureAccessor", "StructureFeatureAccessor",
"StructureManagerMixin",
"StructuresConfigAccessor" "StructuresConfigAccessor"
], ],
"client": [ "client": [