Skip to content

Commit

Permalink
GH-4 - Add support for 1.18.1 (#5)
Browse files Browse the repository at this point in the history
* GH-4 - Adjusted versions

* GH-4 - Run remapping command

* GH-4 - Update more necessary stuff

* GH-4 - Added biome category Mountain to generators

* GH-4 - Updated StructureFeatures to 1.18.1

* GH-4 - Small changes

* GH-4 - Fixed derelict_grass not having loot

* GH-4 - Finished 1.18.1 support
  • Loading branch information
xPand4B authored Dec 11, 2021
1 parent 87aac82 commit 3046023
Show file tree
Hide file tree
Showing 19 changed files with 130 additions and 246 deletions.
11 changes: 6 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ body:
label: Mod Version
description: "Please select the used version of 'Towers of the Wild: Reworked'."
options:
- 1.1.0-beta
- 1.0.0-beta
- "2.0.0"
- "1.0.0-beta.1"
- "1.0.0-beta"
validations:
required: true
- type: dropdown
Expand All @@ -69,11 +70,11 @@ body:
label: Java Version
description: "Please select the used version of 'Java'."
options:
- "Java 17 (LTS)"
- "Java 16 (Minimum supported by Minecraft 1.17.1)"
- "Java 17"
- "Java 16"
validations:
required: true
- type: input
- type: textarea
id: fabricVersion
attributes:
label: Fabric Version
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ jobs:
matrix:
# Use these Java versions
java: [
16, # Minimum supported by Minecraft
17, # Current Java LTS
17, # Current Java LTS & minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-2022]
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 2.0.0
* [GH-4](https://github.com/xPand4B/Towers_Of_The_Wild_Reworked/issues/4) - Add support for 1.18.1 by [@xPand4B](https://github.com/xPand4B) in [#5](https://github.com/xPand4B/Towers_Of_The_Wild_Reworked/pull/5)
* Skipped 1.18 because of security exploit
* Fixed derelict_grass tower not having loot inside chest

**Full Changelog**: *[v1.0.0-beta.1...v2.0.0](https://github.com/xPand4B/Towers_Of_The_Wild_Reworked/compare/v1.0.0-beta.1...v2.0.0)*

## 1.0.0-beta.1
* [GH-2](https://github.com/xPand4B/Towers_Of_The_Wild_Reworked/issues/2) - Add support for fabric waystones by [@xPand4B](https://github.com/xPand4B) in [#3](https://github.com/xPand4B/Towers_Of_The_Wild_Reworked/pull/3)
* Shrinked build size
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Have fun using this mod!
## Getting started
![Environment](https://img.shields.io/badge/environment-Client%20and%20Server-informational?style=flat)
![Modloader](https://img.shields.io/badge/modloader-Fabric-informational?style=flat)
![Teamspeak](https://img.shields.io/badge/compatibile%20with-1.17.1-informational?style=flat&logo=curseforge&logoColor=white&color=F26922)
![Teamspeak](https://img.shields.io/badge/compatibile%20with-1.18.1%20|%201.17.1-informational?style=flat&logo=curseforge&logoColor=white&color=F26922)
[![Github SourceCode](https://img.shields.io/badge/SourceCode%20on-Github-informational?style=flat&logo=github&logoColor=white&color=3A414A)](https://github.com/xPand4B/Towers_Of_The_Wild_Reworked)

This mod adds tall towers in your world, inspired by **The Legend Of Zelda: Breath Of The Wild**.
Expand Down Expand Up @@ -59,8 +59,8 @@ This mod does not add any blocks or items to the game (if that matters to you).

## How to install
**Prerequisite:**
* Minecraft 1.17.1
* [Fabric Loader](https://fabricmc.net/use/) 0.12.5 or higher
* Minecraft 1.18.1
* [Fabric Loader](https://fabricmc.net/use/)
* [Fabric API](https://www.curseforge.com/minecraft/mc-mods/fabric-api) inside your `.minecraft/mods` directory

Simply put the file `towers_of_the_wild-*.jar` inside you mods directory.
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
id 'com.matthewprenger.cursegradle' version '1.4.0'
}

sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -38,8 +38,8 @@ processResources {
}

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.17 (21w19a) upwards uses Java 16.
it.options.release = 16
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}

java {
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ org.gradle.jvmargs=-Xmx4G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.65
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.2
loader_version=0.12.11

# Mod Properties
mod_name = Towers of the Wild: Reworked
mod_version = 1.0.0-beta.1
mod_version = 2.0.0
maven_group = waldinet.towers_of_the_wild_reworked
archives_base_name = towers_of_the_wild_reworked

# Dependencies
fabric_version=0.44.0+1.17
fabric_version=0.44.0+1.18
# cloth_config_version=5.1.40
# mod_menu_version=2.0.2

# Curseforge
curseforge_id=552655
curseforge_release_type=beta
curseforge_minecraft_version=1.17.1
curseforge_release_type=release
curseforge_minecraft_version=1.18.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public class TowersOfTheWildReworked implements ModInitializer
//#region Structures
public static final StructureFeature<StructurePoolFeatureConfig> DERELICT_GRASS_TOWER = new DerelictTowerStructure();
public static final StructureFeature<StructurePoolFeatureConfig> DERELICT_TOWER = new DerelictTowerStructure();
public static final StructureFeature<StructurePoolFeatureConfig> ICE_TOWER = new TowerStructure(9);
public static final StructureFeature<StructurePoolFeatureConfig> JUNGLE_TOWER = new TowerStructure(7);
public static final StructureFeature<StructurePoolFeatureConfig> ICE_TOWER = new TowerStructure();
public static final StructureFeature<StructurePoolFeatureConfig> JUNGLE_TOWER = new TowerStructure();
public static final StructureFeature<StructurePoolFeatureConfig> OCEAN_TOWER = new OceanTowerStructure();
public static final StructureFeature<StructurePoolFeatureConfig> OCEAN_WARM_TOWER = new OceanTowerStructure();
public static final StructureFeature<StructurePoolFeatureConfig> REGULAR_TOWER = new TowerStructure(5);
public static final StructureFeature<StructurePoolFeatureConfig> REGULAR_TOWER = new TowerStructure();
//#endregion

// private TowersOfTheWildReworkedConfig _config;
Expand Down Expand Up @@ -74,13 +74,13 @@ private void registerStructures()
Log("Registering structures...");

// https://github.dev/frqnny/mostructures
RegUtils.registerStructure(StructUtils.DERELICT_GRASS_TOWER, DERELICT_GRASS_TOWER, ConfiguredFeatures.DERELICT_GRASS_TOWER, 72, 8, 1689781);
RegUtils.registerStructure(StructUtils.DERELICT_TOWER, DERELICT_TOWER, ConfiguredFeatures.DERELICT_TOWER, 72, 8, 1689780);
RegUtils.registerStructure(StructUtils.ICE_TOWER, ICE_TOWER, ConfiguredFeatures.ICE_TOWER, 35, 8, 1689779);
RegUtils.registerStructure(StructUtils.JUNGLE_TOWER, JUNGLE_TOWER, ConfiguredFeatures.JUNGLE_TOWER, 38, 8, 1689778);
RegUtils.registerStructure(StructUtils.OCEAN_TOWER, OCEAN_TOWER, ConfiguredFeatures.OCEAN_TOWER, 38, 8, 1689782);
RegUtils.registerStructure(StructUtils.OCEAN_WARM_TOWER, OCEAN_WARM_TOWER, ConfiguredFeatures.OCEAN_WARM_TOWER, 32, 8, 1689782);
RegUtils.registerStructure(StructUtils.REGULAR_TOWER, REGULAR_TOWER, ConfiguredFeatures.REGULAR_TOWER, 42, 8, 1689777);
RegUtils.registerStructure(StructUtils.DERELICT_GRASS_TOWER, DERELICT_GRASS_TOWER, 72, 8, 1689781);
RegUtils.registerStructure(StructUtils.DERELICT_TOWER, DERELICT_TOWER, 72, 8, 1689780);
RegUtils.registerStructure(StructUtils.ICE_TOWER, ICE_TOWER, 35, 8, 1689779);
RegUtils.registerStructure(StructUtils.JUNGLE_TOWER, JUNGLE_TOWER, 38, 8, 1689778);
RegUtils.registerStructure(StructUtils.OCEAN_TOWER, OCEAN_TOWER, 38, 8, 1689782);
RegUtils.registerStructure(StructUtils.OCEAN_WARM_TOWER, OCEAN_WARM_TOWER, 32, 8, 1689782);
RegUtils.registerStructure(StructUtils.REGULAR_TOWER, REGULAR_TOWER, 42, 8, 1689777);

Log("Registration finished!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class DerelictGrassTowerGenerator extends AbstractTowerGenerator
Biome.Category.FOREST,
Biome.Category.SWAMP,
Biome.Category.MUSHROOM,
Biome.Category.MOUNTAIN,
};

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class DerelictTowerGenerator extends AbstractTowerGenerator
public static Biome.Category[] BIOME_CATEGORIES = new Biome.Category[]{
Biome.Category.MESA,
Biome.Category.DESERT,
Biome.Category.ICY,
Biome.Category.ICY,
Biome.Category.MOUNTAIN,
};

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class RegularTowerGenerator extends AbstractTowerGenerator
Biome.Category.FOREST,
Biome.Category.DESERT,
Biome.Category.SWAMP,
Biome.Category.MUSHROOM
Biome.Category.MUSHROOM,
Biome.Category.MOUNTAIN,
};

static {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
package waldinet.towers_of_the_wild_reworked.structure;

import java.util.Optional;

import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.Heightmap;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
import waldinet.towers_of_the_wild_reworked.utils.StructUtils;

/**
* Helper class to move all the IDs from former Structure classes
*/
public class DerelictTowerStructure extends TowerStructure
public class DerelictTowerStructure extends StructureFeature<StructurePoolFeatureConfig>
{
public DerelictTowerStructure()
{
super(18);
super(StructurePoolFeatureConfig.CODEC, context -> {
if (! DerelictTowerStructure.isFlatTerrain(context.chunkGenerator(), context.chunkPos(), context.world())) {
return Optional.empty();
}

StructUtils.initPools();

return TowerStructure.generate(context);
});
}

@Override
protected boolean isFlatTerrain(ChunkGenerator chunkGenerator, ChunkPos chunkPos, HeightLimitView world)
/**
* @internal
*/
private static boolean isFlatTerrain(ChunkGenerator chunkGenerator, ChunkPos chunkPos, HeightLimitView world)
{
int offset = 18;
int xStart = chunkPos.x * 16;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package waldinet.towers_of_the_wild_reworked.structure;

import net.minecraft.structure.PoolStructurePiece;
import net.minecraft.structure.StructureManager;
import net.minecraft.structure.StructureStart;
import net.minecraft.structure.pool.StructurePoolBasedGenerator;
import net.minecraft.util.math.BlockPos;
import java.util.Optional;

import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.world.HeightLimitView;
import net.minecraft.world.Heightmap;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.gen.ChunkRandom;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.StructureFeature;
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
Expand All @@ -20,83 +13,37 @@
/**
* Helper class to move all the IDs from former Structure classes
*/
public class OceanTowerStructure extends TowerStructure
public class OceanTowerStructure extends StructureFeature<StructurePoolFeatureConfig>
{
public OceanTowerStructure()
{
super(7);
}
super(StructurePoolFeatureConfig.CODEC, context -> {
if (! OceanTowerStructure.oceanIsDeepEnough(context.chunkGenerator(), context.chunkPos(), context.world())) {
return Optional.empty();
}

@Override
public StructureStartFactory<StructurePoolFeatureConfig> getStructureStartFactory()
{
return OceanTowerStructure.Start::new;
}

@SuppressWarnings("ObjectAllocationInLoop")
@Override
protected boolean shouldStartAt(
ChunkGenerator chunkGenerator,
BiomeSource biomeSource,
long worldSeed,
ChunkRandom random,
ChunkPos pos,
Biome biome,
ChunkPos chunkPos,
StructurePoolFeatureConfig config,
HeightLimitView world
) {
if (! isFlatTerrain(chunkGenerator, chunkPos, world)) {
return false;
}
StructUtils.initPools();

int x = pos.x * 16;
int z = pos.z * 16;
int oceanFloor = chunkGenerator.getHeight(x, z, Heightmap.Type.OCEAN_FLOOR_WG, world);
ChunkPos chunkPos = context.chunkPos();
int x = chunkPos.x * 16;
int z = chunkPos.z * 16;
int oceanFloor = context.chunkGenerator().getHeight(x, z, Heightmap.Type.OCEAN_FLOOR_WG, context.world());
int surfaceFloor = context.chunkGenerator().getHeight(x, z, Heightmap.Type.WORLD_SURFACE_WG, context.world());
int y = oceanFloor - surfaceFloor;

return oceanFloor <= 38;
return TowerStructure.generate(context, y);
});
}

public static class Start extends StructureStart<StructurePoolFeatureConfig>
/**
* @internal
*/
private static boolean oceanIsDeepEnough(ChunkGenerator chunkGenerator, ChunkPos chunkPos, HeightLimitView world)
{
//#region Constructor
public Start(StructureFeature<StructurePoolFeatureConfig> structureFeature, ChunkPos chunkPos, int i, long l)
{
super(structureFeature, chunkPos, i, l);
}
//#endregion

@Override
public void init(
DynamicRegistryManager registryManager,
ChunkGenerator chunkGenerator,
StructureManager manager,
ChunkPos pos,
Biome biome,
StructurePoolFeatureConfig config,
HeightLimitView world
) {
OceanTowerStructure structure = (OceanTowerStructure) this.getFeature();

int x = pos.x * 16;
int z = pos.z * 16 ;
int y = chunkGenerator.getHeight(x, z, Heightmap.Type.OCEAN_FLOOR_WG, world) - chunkGenerator.getHeight(x, z, Heightmap.Type.WORLD_SURFACE_WG, world);
int x = chunkPos.x * 16;
int z = chunkPos.z * 16;
int oceanFloor = chunkGenerator.getHeight(x, z, Heightmap.Type.OCEAN_FLOOR_WG, world);

StructUtils.initPools();
StructurePoolBasedGenerator.generate(
registryManager,
config,
PoolStructurePiece::new,
chunkGenerator,
manager,
new BlockPos(x, y, z),
this,
this.random,
structure.modifyBoundingBox,
structure.surface,
world
);
this.setBoundingBoxFromChildren();
}
return oceanFloor <= 38;
}
}
Loading

0 comments on commit 3046023

Please sign in to comment.