Skip to content
Open
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 @@ -4,6 +4,7 @@
import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.Codec;
import com.teamabnormals.environmental.common.entity.animal.zebroid.Zebra;
import com.teamabnormals.environmental.core.EnvironmentalConfig;
import com.teamabnormals.environmental.core.registry.EnvironmentalEntityTypes;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.BlockTags;
Expand All @@ -26,13 +27,31 @@ public ZebraDazzleFeature(Codec<NoneFeatureConfiguration> config) {

@Override
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {

if(EnvironmentalConfig.COMMON.enableZebraDazzles.get() == false
|| (EnvironmentalConfig.COMMON.zebraGroupSize.get() == 0
&& EnvironmentalConfig.COMMON.zebraExtraSpawns.get() == 0))
{
return false;
}

BlockPos pos = context.origin();
WorldGenLevel level = context.level();
RandomSource random = context.random();
List<Pair<Zebra, Vec3>> zebras = Lists.newArrayList();

int spawnedZebras = 0;
int zebraCount = 18 + random.nextInt(3) + random.nextInt(3) + random.nextInt(3);

int extraZebras = EnvironmentalConfig.COMMON.zebraExtraSpawns.get();
int zebraCount = EnvironmentalConfig.COMMON.zebraGroupSize.get();

if(extraZebras > 0)
{
zebraCount += random.nextInt(extraZebras + 1);
zebraCount += random.nextInt(extraZebras + 1);
zebraCount += random.nextInt(extraZebras + 1);
}

for (int i = 0; i < 64; ++i) {
int spawnRange = 8;
double d0 = (double) pos.getX() + (random.nextDouble() - random.nextDouble()) * (double) spawnRange + 0.5D;
Expand All @@ -51,7 +70,9 @@ public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
}
}

if (zebras.size() > 16) {
/* Check if zebra group size is equal to or greater than size set in config.
previously checked for greater than 16? magic numbers bad!*/
if (zebras.size() >= EnvironmentalConfig.COMMON.zebraGroupSize.get()) {
for (Pair<Zebra, Vec3> pair : zebras) {
Zebra zebra = pair.getFirst();
Vec3 zebraPos = pair.getSecond();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import org.apache.commons.lang3.tuple.Pair;
import org.checkerframework.common.value.qual.IntVal;

@EventBusSubscriber(modid = Environmental.MOD_ID)
public class EnvironmentalConfig {
Expand All @@ -27,6 +28,10 @@ public static class Common {
public final IntValue minimumAdditionalHoglets;
public final IntValue maximumAdditionalHoglets;

public final BooleanValue enableZebraDazzles;
public final IntValue zebraGroupSize;
public final IntValue zebraExtraSpawns;

public final BooleanValue muddyPigs;
public final BooleanValue naturalMuddyPigs;
public final DoubleValue muddyPigDecorationChance;
Expand All @@ -42,6 +47,11 @@ public static class Common {

Common(ForgeConfigSpec.Builder builder) {
builder.push("mobs");
builder.push("zebra");
enableZebraDazzles = builder.comment("Whether or not to spawn Zebra Dazzles").define("Spawn Zebra Dazzles", true);
zebraGroupSize = builder.comment("Define group size for zebras dazzles").defineInRange("Zebra Group Size", 18, 0, 100);
zebraExtraSpawns = builder.comment("Random range which spawns extra zebras. default is 3. set to 0 to spawn exactly the amount of zebras specified in group size with no variation").defineInRange("Extra Zebra Ranges", 3, 0, 100);
builder.pop();
builder.push("deer");
deerFlowerReproducing = builder.comment("If Deer can reproduce and spread flowers by feeding them an Apple followed by a flower").define("Deer flower reproducing", true);
deerAntlerChance = builder.comment("The chance Deer have to spawn with Antlers; 0.0 for never, 1.0 for always").defineInRange("Deer Antler chance", 0.5D, 0.0D, 1.0D);
Expand Down