fix mobs not spawning in structures
This commit is contained in:
1 parent
69574468d9
commit
bb7a64b629
2 files changed
+79
-35
No files matched your search
@@ -1,13 +1,10 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.utils.SpawnOverrides;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.data.worldgen.StructureFeatures;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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.CallbackInfoReturnable;
|
||||
@@ -27,47 +24,20 @@ import java.util.Map;
|
||||
@Mixin(ChunkGenerator.class)
|
||||
public abstract class ChunkGenerator_customMobSpawnsMixin
|
||||
{
|
||||
|
||||
@Shadow protected abstract void ensureGenerated();
|
||||
|
||||
private static final WeightedRandomList<MobSpawnSettings.SpawnerData> PYRAMID_SPAWNS = WeightedRandomList.create(new MobSpawnSettings.SpawnerData(EntityType.HUSK, 1, 1, 1));
|
||||
private static final WeightedRandomList<MobSpawnSettings.SpawnerData> SHULKER_SPAWNS = WeightedRandomList.create(new MobSpawnSettings.SpawnerData(EntityType.SHULKER, 10, 4, 4));
|
||||
private static final WeightedRandomList<MobSpawnSettings.SpawnerData> BASTION_SPAWNS = WeightedRandomList.create(
|
||||
new MobSpawnSettings.SpawnerData(EntityType.PIGLIN_BRUTE, 5, 1, 2),
|
||||
new MobSpawnSettings.SpawnerData(EntityType.PIGLIN, 10, 2, 4),
|
||||
new MobSpawnSettings.SpawnerData(EntityType.HOGLIN, 2, 1, 2)
|
||||
);
|
||||
|
||||
@Inject(
|
||||
method = "getMobsAt", locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/Map$Entry;getKey()Ljava/lang/Object;"
|
||||
), cancellable = true)
|
||||
private void isInsidePyramid(Holder<Biome> holder, StructureFeatureManager structureFeatureManager, MobCategory mobCategory, BlockPos blockPos,
|
||||
private void checkCMSpawns(Holder<Biome> holder, StructureFeatureManager structureFeatureManager, MobCategory mobCategory, BlockPos blockPos,
|
||||
CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir,
|
||||
Map<ConfiguredStructureFeature<?, ?>, LongSet> map, Iterator<?> var6, Map.Entry<ConfiguredStructureFeature<?, ?>, LongSet> entry)
|
||||
{
|
||||
if (mobCategory == MobCategory.MONSTER)
|
||||
WeightedRandomList<MobSpawnSettings.SpawnerData> res = SpawnOverrides.test(structureFeatureManager, entry.getValue(), mobCategory, entry.getKey(), blockPos);
|
||||
if (res != null)
|
||||
{
|
||||
ConfiguredStructureFeature<?, ?> str = entry.getKey();
|
||||
if (CarpetSettings.huskSpawningInTemples
|
||||
&& str.feature == StructureFeatures.DESERT_PYRAMID.value().feature
|
||||
&& structureFeatureManager.getStructureAt(blockPos, StructureFeatures.DESERT_PYRAMID.value()).isValid()) {
|
||||
cir.setReturnValue(PYRAMID_SPAWNS);
|
||||
return;
|
||||
}
|
||||
if (CarpetSettings.shulkerSpawningInEndCities
|
||||
&& str.feature == StructureFeatures.END_CITY.value().feature
|
||||
&& structureFeatureManager.getStructureAt(blockPos, StructureFeatures.END_CITY.value()).isValid()) {
|
||||
cir.setReturnValue(SHULKER_SPAWNS);
|
||||
return;
|
||||
}
|
||||
if (CarpetSettings.piglinsSpawningInBastions
|
||||
&& str.feature == StructureFeatures.BASTION_REMNANT.value().feature
|
||||
&& structureFeatureManager.getStructureAt(blockPos, StructureFeatures.BASTION_REMNANT.value()).isValid()) {
|
||||
cir.setReturnValue(BASTION_SPAWNS);
|
||||
}
|
||||
cir.setReturnValue(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user