Skip to content

Commit

Permalink
Make Biome and Structure Modifiers not crash when attempted to be re-…
Browse files Browse the repository at this point in the history
…applied (#1545)
  • Loading branch information
TelepathicGrunt authored Sep 30, 2024
1 parent 85e7ec0 commit e8b9d12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
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;

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;

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

0 comments on commit e8b9d12

Please sign in to comment.