Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Biome and Structure Modifiers not crash when attempted to be re-applied #1545

Merged
merged 4 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.mojang.serialization.DynamicOps;
import com.mojang.serialization.JsonOps;
import java.util.List;
import java.util.Locale;
import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.RegistryOps;
Expand Down Expand Up @@ -67,20 +66,18 @@ public BiomeInfo getModifiedBiomeInfo() {
}

/**
* Internal forge method; the game will crash if mods invoke this.
* Internal NeoForge method. Will do nothing if this modifier had already been applied.
* Creates and caches the modified biome info.
*
* @param biome named biome with original data.
* @param biomeModifiers biome modifiers to apply.
*
* @return whether the biome's network-synced data was modified
*
* @throws IllegalStateException if invoked more than once.
*/
@ApiStatus.Internal
public boolean applyBiomeModifiers(final Holder<Biome> biome, final List<BiomeModifier> biomeModifiers, RegistryAccess registryAccess) {
if (this.modifiedBiomeInfo != null)
throw new IllegalStateException(String.format(Locale.ENGLISH, "Biome %s already modified", biome));
return true;
TelepathicGrunt marked this conversation as resolved.
Show resolved Hide resolved

BiomeInfo original = this.getOriginalBiomeInfo();
final BiomeInfo.Builder builder = BiomeInfo.Builder.copyOf(original);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package net.neoforged.neoforge.common.world;

import java.util.List;
import java.util.Locale;
import net.minecraft.core.Holder;
import net.minecraft.world.level.levelgen.structure.Structure;
import net.minecraft.world.level.levelgen.structure.Structure.StructureSettings;
Expand Down Expand Up @@ -55,18 +54,16 @@ public StructureInfo getModifiedStructureInfo() {
}

/**
* Internal neoforge method; the game will crash if mods invoke this.
* Internal NeoForge method. Will do nothing if this modifier had already been applied.
* Creates and caches the modified structure info.
*
* @param structure named structure with original data.
* @param structureModifiers structure modifiers to apply.
*
* @throws IllegalStateException if invoked more than once.
*/
@ApiStatus.Internal
public void applyStructureModifiers(final Holder<Structure> structure, final List<StructureModifier> structureModifiers) {
if (this.modifiedStructureInfo != null)
throw new IllegalStateException(String.format(Locale.ENGLISH, "Structure %s already modified", structure));
return;
TelepathicGrunt marked this conversation as resolved.
Show resolved Hide resolved

StructureInfo original = this.getOriginalStructureInfo();
final StructureInfo.Builder builder = StructureInfo.Builder.copyOf(original);
Expand Down