Skip to content

Commit

Permalink
Updated to v17.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Hex27 committed Oct 23, 2024
1 parent 55e611c commit ca274b8
Show file tree
Hide file tree
Showing 28 changed files with 1,948 additions and 4 deletions.
1 change: 1 addition & 0 deletions buildProj/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
implementation(project(":implementation:v1_20_R3"))
implementation(project(":implementation:v1_20_R4"))
implementation(project(":implementation:v1_21_R1"))
implementation(project(":implementation:v1_21_R2"))
implementation("com.github.AvarionMC:yaml:1.1.3")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void populateSmallItems(TerraformWorld world,
.isSolid())
{
// Dense grass
if (GenUtils.chance(random, 5, 10)) {
if (GenUtils.chance(random, TConfig.c.BIOME_SAVANNA_TALLGRASSCHANCE, 10000)) {
PlantBuilder.TALL_GRASS.build(data, rawX, surfaceY + 1, rawZ);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package org.terraform.coregen;

public enum NaturalSpawnType {
GUARDIAN, PILLAGER
GUARDIAN, PILLAGER, WITCH
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,16 @@ public enum TerraLootTable {
SHEPHERD_GIFT("gameplay/hero_of_the_village/shepherd_gift"),
TOOLSMITH_GIFT("gameplay/hero_of_the_village/toolsmith_gift"),
WEAPONSMITH_GIFT("gameplay/hero_of_the_village/weaponsmith_gift"),
UNEMPLOYED_GIFT("gameplay/hero_of_the_village/unemployed_gift"),
BABY_VILLAGER_GIFT("gameplay/hero_of_the_village/baby_gift"),
SNIFFER_DIGGING("gameplay/sniffer_digging"),
CHICKEN_LAY("gameplay/chicken_lay"),
ARMADILLO_SHED("gameplay/armadillo_shed"),
SHEAR_MOOSHROOM("gameplay/mooshroom"),
SHEAR_RED_MOOSHROOM("gameplay/mooshroom/red"),
SHEAR_BROWN_MOOSHROOM("gameplay/mooshroom/brown"),
SHEAR_SNOW_GOLEM("gameplay/snow_golem"),
SHEAR_SHEEP("gameplay/sheep"),
PANDA_SNEEZE("gameplay/panda_sneeze"),
PIGLIN_BARTERING("gameplay/piglin_bartering"),
SPAWNER_TRIAL_CHAMBER_KEY("spawners/trial_chamber/key"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TerraformAnimalPopulator extends BlockPopulator {
private static final AnimalPopulator[] ANIMAL_POPULATORS = {
null, // Slot for goat
null, // Slot for armadillo

null, // Slot for frog
new AnimalPopulator(EntityType.PIG,
TConfig.c.ANIMALS_PIG_MINHERDSIZE,
TConfig.c.ANIMALS_PIG_MAXHERDSIZE,
Expand Down Expand Up @@ -359,6 +359,18 @@ public TerraformAnimalPopulator(TerraformWorld tw) {
BiomeBank.BADLANDS_CANYON
);
}
if (Version.isAtLeast(19)) {
ANIMAL_POPULATORS[2] = new AnimalPopulator(EntityType.valueOf("FROG"),
TConfig.c.ANIMALS_FROG_MINHERDSIZE,
TConfig.c.ANIMALS_FROG_MAXHERDSIZE,
TConfig.c.ANIMALS_FROG_CHANCE,
true,
BiomeBank.SWAMP,
BiomeBank.MUDDY_BOG,
BiomeBank.MUDFLATS,
BiomeBank.MANGROVE
);
}
}

@Override
Expand Down
9 changes: 9 additions & 0 deletions common/src/main/java/org/terraform/main/config/TConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ public static void init(final File f) throws IOException {
public int BIOME_ERODED_PLAINS_WEIGHT = 6;
@YamlKey("biome.savanna.weight")
public int BIOME_SAVANNA_WEIGHT = 6;
@YamlKey("biome.savanna.tallgrass-chance-of-10000")
public int BIOME_SAVANNA_TALLGRASSCHANCE = 5000;
@YamlKey("biome.muddybog.weight")
public int BIOME_MUDDYBOG_WEIGHT = 2;
@YamlKey("biome.forest.weight")
Expand Down Expand Up @@ -625,6 +627,13 @@ public static void init(final File f) throws IOException {
public int ANIMALS_TURTLE_MAXHERDSIZE = 5;
@YamlKey("animals.turtle.chance")
public int ANIMALS_TURTLE_CHANCE = 1;
// FROG
@YamlKey("animals.frog.min-herd-size")
public int ANIMALS_FROG_MINHERDSIZE = 2;
@YamlKey("animals.frog.max-herd-size")
public int ANIMALS_FROG_MAXHERDSIZE = 5;
@YamlKey("animals.frog.chance")
public int ANIMALS_FROG_CHANCE = 1;
// DOLPHIN
@YamlKey("animals.dolphin.min-herd-size")
public int ANIMALS_DOLPHIN_MINHERDSIZE = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;
import org.terraform.biome.BiomeBank;
import org.terraform.coregen.NaturalSpawnType;
import org.terraform.coregen.TerraLootTable;
import org.terraform.coregen.bukkit.TerraformGenerator;
import org.terraform.coregen.populatordata.PopulatorDataAbstract;
import org.terraform.coregen.populatordata.PopulatorDataPostGen;
import org.terraform.data.MegaChunk;
import org.terraform.data.SimpleBlock;
import org.terraform.data.TerraformWorld;
Expand All @@ -26,6 +28,7 @@
import java.io.FileNotFoundException;
import java.util.EnumSet;
import java.util.Locale;
import java.util.Objects;
import java.util.Random;

public class WitchHutPopulator extends MultiMegaChunkStructurePopulator {
Expand Down Expand Up @@ -89,6 +92,19 @@ public void spawnSwampHut(TerraformWorld tw,
TerraformGeneratorPlugin.logger.stackTrace(e);
}

//Register this as a swamp hut with custom spawns
//7x7x9 (x,y,z)
Objects.requireNonNull(TerraformGeneratorPlugin.injector.getICAData(data))
.registerNaturalSpawns(
NaturalSpawnType.WITCH,
x - 3,
y,
z - 4,
x + 3,
y + 7,
z + 4
);

}

private boolean rollSpawnRatio(@NotNull TerraformWorld tw, int chunkX, int chunkZ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public enum SupportedVersion {
V_1_20_R3("v1_20_R3", 20.3, 20.4),
V_1_20_R4("v1_20_R4", 20.5, 20.6),
V_1_21_R1("v1_21_R1", 21.0, 21.1),
V_1_21_R2("v1_21_R2", 21.2, 21.3),
;
private final double[] versionDouble;
private final String packageName;
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: TerraformGenerator
author: Hex_27
version: 16.5.0
version: 17.0.0
api-version: 1.18
description: World Generator
main: org.terraform.main.TerraformGeneratorPlugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public void registerNaturalSpawns(@NotNull NaturalSpawnType type, int x0, int y0
ResourceKey<StructureFeature<?, ?>> structureKey = switch (type) {
case GUARDIAN -> BuiltinStructures.l; // Ocean Monument
case PILLAGER -> BuiltinStructures.a; // Pillager Outpost
case WITCH -> BuiltinStructures.j; // Swamp Hut
}; // Monument

CraftServer craftserver = (CraftServer) Bukkit.getServer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public void registerNaturalSpawns(@NotNull NaturalSpawnType type, int x0, int y0
ResourceKey<Structure> structureKey = switch (type) {
case GUARDIAN -> BuiltinStructures.l; // Ocean Monument
case PILLAGER -> BuiltinStructures.a; // Pillager Outpost
case WITCH -> BuiltinStructures.j; // Swamp Hut
};

// ax is STRUCTURE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public void registerNaturalSpawns(@NotNull NaturalSpawnType type, int x0, int y0
ResourceKey<Structure> structureKey = switch (type) {
case GUARDIAN -> BuiltinStructures.l; // Ocean Monument
case PILLAGER -> BuiltinStructures.a; // Pillager Outpost
case WITCH -> BuiltinStructures.j; // Swamp Hut
};

// ax is STRUCTURE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public void registerNaturalSpawns(@NotNull NaturalSpawnType type, int x0, int y0
ResourceKey<Structure> structureKey = switch (type) {
case GUARDIAN -> BuiltinStructures.l; // Ocean Monument
case PILLAGER -> BuiltinStructures.a; // Pillager Outpost
case WITCH -> BuiltinStructures.j; // Swamp Hut
};

// az is STRUCTURE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public void registerNaturalSpawns(@NotNull NaturalSpawnType type, int x0, int y0
ResourceKey<Structure> structureKey = switch (type) {
case GUARDIAN -> BuiltinStructures.l; // Ocean Monument
case PILLAGER -> BuiltinStructures.a; // Pillager Outpost
case WITCH -> BuiltinStructures.j; // Swamp Hut
};

// aD is STRUCTURE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public void registerNaturalSpawns(@NotNull NaturalSpawnType type, int x0, int y0
ResourceKey<Structure> structureKey = switch (type) {
case GUARDIAN -> BuiltinStructures.l; // Ocean Monument
case PILLAGER -> BuiltinStructures.a; // Pillager Outpost
case WITCH -> BuiltinStructures.j; // Swamp Hut
};

// bc is registryAccess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public void registerNaturalSpawns(@NotNull NaturalSpawnType type, int x0, int y0
ResourceKey<Structure> structureKey = switch (type) {
case GUARDIAN -> BuiltinStructures.l; // Ocean Monument
case PILLAGER -> BuiltinStructures.a; // Pillager Outpost
case WITCH -> BuiltinStructures.j; // Swamp Hut
};

// bc is registryAccess
Expand Down
1 change: 1 addition & 0 deletions implementation/v1_21_R2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build/
10 changes: 10 additions & 0 deletions implementation/v1_21_R2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dependencies {
implementation(project(":common"))
compileOnly(group = "org.spigotmc", name = "spigot", version = "1.21.2-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:20.1.0")
compileOnly("com.github.AvarionMC:yaml:1.1.3")
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.terraform.v1_21_R2;

import org.bukkit.Tag;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Wall;
import org.bukkit.block.data.type.Wall.Height;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.terraform.coregen.BlockDataFixerAbstract;
import org.terraform.data.SimpleBlock;
import org.terraform.utils.BlockUtils;

public class BlockDataFixer extends BlockDataFixerAbstract {

// --------[1.16 stuff]
public static void correctWallData(@NotNull SimpleBlock target) {
if (!(target.getBlockData() instanceof Wall data)) {
return;
}
for (BlockFace face : BlockUtils.directBlockFaces) {
if (target.getRelative(face).isSolid() && !target.getRelative(face)
.getType()
.toString()
.contains("PRESSURE_PLATE"))
{
data.setHeight(face, Height.LOW);
if (target.getRelative(BlockFace.UP).isSolid()) {
data.setHeight(face, Height.TALL);
}
}
else {
data.setHeight(face, Height.NONE);
}
}

// target.setBlockData(data);
}

public static void correctSurroundingWallData(@NotNull SimpleBlock target) {
if (!(target.getBlockData() instanceof Wall)) {
return;
}

correctWallData(target);
for (BlockFace face : BlockUtils.directBlockFaces) {
if (Tag.WALLS.isTagged(target.getRelative(face).getType())) {
correctWallData(target.getRelative(face));
}
}
}

@Override
public String updateSchematic(double schematicVersion, String schematic) {
return schematic;
}

@Override
public void correctFacing(Vector v, @Nullable SimpleBlock b, @Nullable BlockData data, BlockFace face) {
if (data == null && b != null) {
data = b.getBlockData();
}

if (!hasFlushed && data instanceof Wall) {
this.pushChanges(v);
return;
}

if (data instanceof Wall && b != null) {
// 1.16 stuff.
correctSurroundingWallData(b);
}
}

}
Loading

0 comments on commit ca274b8

Please sign in to comment.