Skip to content

Commit

Permalink
fix rubber tree config crashing with some specific values (#1538)
Browse files Browse the repository at this point in the history
Co-authored-by: YoungOnion <[email protected]>
  • Loading branch information
screret and YoungOnionMC authored Jul 5, 2024
1 parent f6ca8fd commit 528fdc7
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"button_texture": {
"type": "item",
"res": "gtceu:polybenzimidazole_mallet"
"res": "gtceu:silicone_rubber_mallet"
},
"items": [
"#forge:tools/mallets"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"button_texture": {
"type": "item",
"res": "gtceu:polybenzimidazole_plunger"
"res": "gtceu:silicone_rubber_plunger"
},
"items": [
"#forge:tools/plungers"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
]
},
{
"type": "minecraft:count",
"count": {
"type": "gtceu:rubber_tree_chance"
}
"type": "gtceu:rubber_tree_chance"
},
{
"type": "minecraft:in_square"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public CommonProxy() {
GTCommandArguments.init(eventBus);
GTMobEffects.init(eventBus);
GTParticleTypes.init(eventBus);
GTIntProviderTypes.init(eventBus);
// init common features
GTRegistries.GLOBAL_LOOT_MODIFIES.register("tool", () -> ToolLootModifier.CODEC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.gregtechceu.gtceu.api.data.worldgen.modifier.FrequencyModifier;
import com.gregtechceu.gtceu.common.worldgen.feature.FluidSproutFeature;
import com.gregtechceu.gtceu.common.worldgen.feature.StoneBlobFeature;
import com.gregtechceu.gtceu.common.worldgen.modifier.RubberTreeChancePlacement;

import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -36,6 +37,7 @@ public static void init() {
Object inst = FrequencyModifier.FREQUENCY_MODIFIER; // seemingly useless access to init the class in time
inst = DimensionFilter.DIMENSION_FILTER;
inst = BiomePlacement.BIOME_PLACEMENT;
inst = RubberTreeChancePlacement.RUBBER_TREE_CHANCE_PLACEMENT;
}

public static void init(IEventBus modEventBus) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.data.worldgen.BiomeWeightModifier;
import com.gregtechceu.gtceu.api.data.worldgen.modifier.BiomePlacement;
import com.gregtechceu.gtceu.common.worldgen.RubberTreeChanceWeightedListInt;
import com.gregtechceu.gtceu.common.worldgen.modifier.RubberTreeChancePlacement;
import com.gregtechceu.gtceu.data.recipe.CustomTags;

import net.minecraft.core.HolderGetter;
Expand Down Expand Up @@ -41,7 +41,7 @@ public static void bootstrap(BootstapContext<PlacedFeature> ctx) {
PlacementUtils.register(ctx, RUBBER_CHECKED, featureLookup.getOrThrow(GTConfiguredFeatures.RUBBER),
new BiomePlacement(List.of(
new BiomeWeightModifier(() -> biomeLookup.getOrThrow(CustomTags.IS_SWAMP), 50))),
CountPlacement.of(RubberTreeChanceWeightedListInt.INSTANCE),
RubberTreeChancePlacement.INSTANCE,
InSquarePlacement.spread(),
SurfaceWaterDepthFilter.forMaxDepth(0),
PlacementUtils.HEIGHTMAP_TOP_SOLID,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.gregtechceu.gtceu.common.worldgen.modifier;

import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.config.ConfigHolder;

import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.placement.PlacementModifierType;
import net.minecraft.world.level.levelgen.placement.RepeatingPlacement;

import com.mojang.serialization.Codec;

public class RubberTreeChancePlacement extends RepeatingPlacement {

public static final PlacementModifierType<RubberTreeChancePlacement> RUBBER_TREE_CHANCE_PLACEMENT = GTRegistries
.register(
BuiltInRegistries.PLACEMENT_MODIFIER_TYPE, GTCEu.id("rubber_tree_chance"),
() -> RubberTreeChancePlacement.CODEC);

public static final RubberTreeChancePlacement INSTANCE = new RubberTreeChancePlacement();
public static final Codec<RubberTreeChancePlacement> CODEC = Codec.unit(INSTANCE);

@Override
protected int count(RandomSource random, BlockPos pos) {
return random.nextFloat() < ConfigHolder.INSTANCE.worldgen.rubberTreeSpawnChance ? 1 : 0;
}

@Override
public PlacementModifierType<?> type() {
return RUBBER_TREE_CHANCE_PLACEMENT;
}
}

0 comments on commit 528fdc7

Please sign in to comment.