mirror of
https://github.com/FabricMC/fabric.git
synced 2025-07-28 15:09:35 -04:00
Fix a vanilla bug causing missing structures to reset chunks when upgrading a world from previous versions. (#2045)
This commit is contained in:
parent
f88a7f1a6a
commit
0d9ab37284
3 changed files with 82 additions and 1 deletions
fabric-registry-sync-v0/src/main
java/net/fabricmc/fabric/mixin/registry/sync
resources
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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.registry.sync;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import net.minecraft.world.ChunkSerializer;
|
||||
|
||||
@Mixin(ChunkSerializer.class)
|
||||
public class MixinChunkSerializer {
|
||||
@Redirect(method = "readStructureReferences", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V"))
|
||||
private static void log(Logger logger, String msg, Object identifier, Object chunkPos) {
|
||||
// Drop to debug log level.
|
||||
logger.debug(msg, identifier, chunkPos);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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.registry.sync;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.datafixer.fix.StructuresToConfiguredStructuresFix;
|
||||
|
||||
@Mixin(StructuresToConfiguredStructuresFix.class)
|
||||
public class MixinStructuresToConfiguredStructuresFix {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger("MixinStructuresToConfiguredStructuresFix");
|
||||
|
||||
/**
|
||||
* Vanilla throws a IllegalStateException when there is no mapping for a structure to upgrade, this causes the chunk to reset and regenerate.
|
||||
* Now we just return the previous value, this can still cause a missing structure log warning, but it is a lot better than resetting the chunk.
|
||||
*/
|
||||
@Inject(method = "method_41022", at = @At(value = "INVOKE", target = "Ljava/lang/IllegalStateException;<init>(Ljava/lang/String;)V"), cancellable = true)
|
||||
private void method_41022(Pair<Dynamic<?>, Dynamic<?>> pair, Dynamic<?> dynamic, CallbackInfoReturnable<Dynamic<?>> cir) {
|
||||
String id = pair.getFirst().asString("UNKNOWN").toLowerCase(Locale.ROOT);
|
||||
LOGGER.debug("Found unknown structure: {}", id);
|
||||
cir.setReturnValue(pair.getSecond().createString(id));
|
||||
}
|
||||
}
|
|
@ -7,13 +7,15 @@
|
|||
"AccessorLevelStorageSession",
|
||||
"AccessorRegistry",
|
||||
"MixinBootstrap",
|
||||
"MixinChunkSerializer",
|
||||
"MixinDynamicRegistryManager",
|
||||
"MixinIdList",
|
||||
"MixinIdRegistry",
|
||||
"MixinLevelStorageSession",
|
||||
"MixinRegistry",
|
||||
"MixinMinecraftServer",
|
||||
"MixinSimpleRegistry"
|
||||
"MixinSimpleRegistry",
|
||||
"MixinStructuresToConfiguredStructuresFix"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinBlockColorMap",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue