Skip to content

Commit 8dd9093

Browse files
authored
Merge pull request #7 from LolHens/merged
Merged 1.16.1 and 1.16.2 branches
2 parents c8a609f + 1ab32b5 commit 8dd9093

File tree

65 files changed

+1265
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1265
-130
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ jobs:
2828
run: ./gradlew build
2929
- uses: actions/upload-artifact@v2
3030
with:
31-
path: build/libs/*
31+
path: '*/build/libs/*'

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
run: ./gradlew build
2727
- uses: actions/upload-artifact@v2
2828
with:
29-
path: build/libs/*
29+
path: '*/build/libs/*'
3030
- uses: AButler/[email protected]
3131
with:
32-
files: build/libs/*
32+
files: '*/build/libs/*'
3333
repo-token: ${{ secrets.GITHUB_TOKEN }}

build.gradle

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1 @@
1-
plugins {
2-
id 'scala'
3-
id 'fabric-loom' version '0.4-SNAPSHOT'
4-
id 'maven-publish'
5-
}
6-
7-
sourceCompatibility = JavaVersion.VERSION_1_8
8-
targetCompatibility = JavaVersion.VERSION_1_8
9-
10-
archivesBaseName = project.archives_base_name
11-
version = project.mod_version
12-
group = project.maven_group
13-
14-
def tagPrefix = "refs/tags/"
15-
if ((System.getenv("CI_VERSION") ?: "").startsWith(tagPrefix)) {
16-
version = System.getenv("CI_VERSION").drop(tagPrefix.length()).takeWhile { it != '+' }
17-
}
18-
19-
version = version + "+" + project.minecraft_version
20-
21-
configurations {
22-
shadow
23-
compile.extendsFrom(shadow)
24-
}
25-
26-
dependencies {
27-
//to change the versions see the gradle.properties file
28-
minecraft "com.mojang:minecraft:${project.minecraft_version}"
29-
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
30-
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
31-
32-
// Fabric API. This is technically optional, but you probably want it anyway.
33-
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
34-
35-
modImplementation "net.fabricmc:fabric-language-scala:0.3.1.+"
36-
37-
shadow "io.circe:circe-parser_2.13:0.13.0"
38-
shadow "io.circe:circe-generic_2.13:0.13.0"
39-
shadow "io.circe:circe-generic-extras_2.13:0.13.0"
40-
shadow "io.circe:circe-config_2.13:0.7.0"
41-
42-
compileOnly group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
43-
44-
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
45-
// You may need to force-disable transitiveness on them.
46-
47-
}
48-
49-
processResources {
50-
inputs.property "version", project.version
51-
52-
from(sourceSets.main.resources.srcDirs) {
53-
include "fabric.mod.json"
54-
expand "version": project.version
55-
}
56-
57-
from(sourceSets.main.resources.srcDirs) {
58-
exclude "fabric.mod.json"
59-
}
60-
}
61-
62-
// ensure that the encoding is set to UTF-8, no matter what the system default is
63-
// this fixes some edge cases with special characters not displaying correctly
64-
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
65-
tasks.withType(JavaCompile) {
66-
options.encoding = "UTF-8"
67-
}
68-
69-
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
70-
// if it is present.
71-
// If you remove this task, sources will not be generated.
72-
task sourcesJar(type: Jar, dependsOn: classes) {
73-
classifier = "sources"
74-
from sourceSets.main.allSource
75-
}
76-
77-
jar {
78-
from "LICENSE"
79-
from {
80-
configurations.shadow.collect { it.toString().contains("scala-library") ? null : it.isDirectory() ? it : zipTree(it) }
81-
}
82-
}
83-
84-
// configure the maven publication
85-
publishing {
86-
publications {
87-
mavenJava(MavenPublication) {
88-
// add all the jars that should be included when publishing to maven
89-
artifact(remapJar) {
90-
builtBy remapJar
91-
}
92-
artifact(sourcesJar) {
93-
builtBy remapSourcesJar
94-
}
95-
}
96-
}
97-
98-
// select the repositories you want to publish to
99-
repositories {
100-
// uncomment to publish to the local maven
101-
// mavenLocal()
102-
}
103-
}
1+
apply plugin: 'idea'

fabric-1.16.1/build.gradle

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
maven {
5+
name = 'Fabric'
6+
url = 'https://maven.fabricmc.net/'
7+
}
8+
gradlePluginPortal()
9+
}
10+
dependencies {
11+
classpath group: 'net.fabricmc', name: 'fabric-loom', version: '0.5.9'
12+
}
13+
}
14+
apply plugin: 'scala'
15+
apply plugin: 'fabric-loom'
16+
apply plugin: 'maven-publish'
17+
18+
sourceCompatibility = JavaVersion.VERSION_1_8
19+
targetCompatibility = JavaVersion.VERSION_1_8
20+
21+
archivesBaseName = project.archives_base_name
22+
version = project.mod_version
23+
group = project.maven_group
24+
25+
def tagPrefix = "refs/tags/"
26+
if ((System.getenv("CI_VERSION") ?: "").startsWith(tagPrefix)) {
27+
version = System.getenv("CI_VERSION").drop(tagPrefix.length()).takeWhile { it != '+' }
28+
}
29+
30+
version = version + "+fabric-" + project.minecraft_version
31+
32+
configurations {
33+
shadow
34+
compile.extendsFrom(shadow)
35+
}
36+
37+
dependencies {
38+
//to change the versions see the gradle.properties file
39+
minecraft "com.mojang:minecraft:${project.minecraft_version}"
40+
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
41+
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
42+
43+
// Fabric API. This is technically optional, but you probably want it anyway.
44+
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
45+
46+
modImplementation "net.fabricmc:fabric-language-scala:0.3.1.+"
47+
48+
shadow "io.circe:circe-parser_2.13:0.13.0"
49+
shadow "io.circe:circe-generic_2.13:0.13.0"
50+
shadow "io.circe:circe-generic-extras_2.13:0.13.0"
51+
shadow "io.circe:circe-config_2.13:0.7.0"
52+
53+
compileOnly group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
54+
55+
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
56+
// You may need to force-disable transitiveness on them.
57+
58+
}
59+
60+
processResources {
61+
inputs.property "version", project.version
62+
63+
from(sourceSets.main.resources.srcDirs) {
64+
include "fabric.mod.json"
65+
expand "version": project.version
66+
}
67+
68+
from(sourceSets.main.resources.srcDirs) {
69+
exclude "fabric.mod.json"
70+
}
71+
}
72+
73+
// ensure that the encoding is set to UTF-8, no matter what the system default is
74+
// this fixes some edge cases with special characters not displaying correctly
75+
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
76+
tasks.withType(JavaCompile) {
77+
options.encoding = "UTF-8"
78+
}
79+
80+
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
81+
// if it is present.
82+
// If you remove this task, sources will not be generated.
83+
task sourcesJar(type: Jar, dependsOn: classes) {
84+
classifier = "sources"
85+
from sourceSets.main.allSource
86+
}
87+
88+
jar {
89+
from "LICENSE"
90+
from {
91+
configurations.shadow.collect { it.toString().contains("scala-library") ? null : it.isDirectory() ? it : zipTree(it) }
92+
}
93+
}
94+
95+
// configure the maven publication
96+
publishing {
97+
publications {
98+
mavenJava(MavenPublication) {
99+
// add all the jars that should be included when publishing to maven
100+
artifact(remapJar) {
101+
builtBy remapJar
102+
}
103+
artifact(sourcesJar) {
104+
builtBy remapSourcesJar
105+
}
106+
}
107+
}
108+
109+
// select the repositories you want to publish to
110+
repositories {
111+
// uncomment to publish to the local maven
112+
// mavenLocal()
113+
}
114+
}

fabric-1.16.1/gradle.properties

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Done to increase the memory available to gradle.
2+
org.gradle.jvmargs=-Xmx1G
3+
# Fabric Properties
4+
# check these on https://fabricmc.net/use
5+
minecraft_version=1.16.1
6+
yarn_mappings=1.16.1+build.20
7+
loader_version=0.8.9+build.203
8+
# Mod Properties
9+
mod_version=0.0.1-SNAPSHOT
10+
maven_group=de.lolhens
11+
archives_base_name=fluidphysics
12+
# Dependencies
13+
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
14+
fabric_version=0.14.1+build.372-1.16

fabric-1.16.1/settings.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pluginManagement {
2+
repositories {
3+
jcenter()
4+
maven {
5+
name = 'Fabric'
6+
url = 'https://maven.fabricmc.net/'
7+
}
8+
gradlePluginPortal()
9+
}
10+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package de.lolhens.minecraft.fluidphysics.config
2+
3+
import de.lolhens.minecraft.fluidphysics.FluidPhysicsMod
4+
import de.lolhens.minecraft.fluidphysics.config.FluidPhysicsConfig.{RainRefillConfig, SpringConfig, registryGet}
5+
import io.circe.Codec
6+
import net.minecraft.block.Block
7+
import net.minecraft.fluid.{Fluid, Fluids}
8+
import net.minecraft.util.Identifier
9+
import net.minecraft.util.math.BlockPos
10+
import net.minecraft.util.registry.Registry
11+
import net.minecraft.world.World
12+
import net.minecraft.world.biome.Biome
13+
14+
case class FluidPhysicsConfig(fluidWhitelist: Seq[Identifier] = Seq(Fluids.WATER, Fluids.LAVA).map(Registry.FLUID.getId),
15+
findSourceMaxIterations: Int = 255,
16+
biomeDependentFluidInfinity: Boolean = false,
17+
flowOverSources: Boolean = true,
18+
debugFluidState: Boolean = false,
19+
spring: Option[SpringConfig] = Some(SpringConfig()),
20+
rainRefill: Option[RainRefillConfig] = Some(RainRefillConfig())) {
21+
lazy val getFluidWhitelist: Seq[Fluid] = fluidWhitelist.map(registryGet(Registry.FLUID, _))
22+
23+
def enabledFor(fluid: Fluid): Boolean = getFluidWhitelist.exists(_.matchesType(fluid))
24+
}
25+
26+
object FluidPhysicsConfig extends Config[FluidPhysicsConfig] {
27+
override val default: FluidPhysicsConfig = FluidPhysicsConfig()
28+
29+
override protected def codec: Codec[FluidPhysicsConfig] = makeCodec
30+
31+
private def registryGet[A](registry: Registry[A], id: Identifier): A = {
32+
require(registry.containsId(id), "Registry does not contain identifier: " + id)
33+
registry.get(id)
34+
}
35+
36+
case class SpringConfig(block: Identifier = FluidPhysicsMod.SPRING_BLOCK_ID,
37+
updateBlocksInWorld: Boolean = false,
38+
allowInfiniteWater: Boolean = true) {
39+
lazy val getBlock: Block = registryGet(Registry.BLOCK, block)
40+
41+
def shouldUpdateBlocksInWorld: Boolean =
42+
block != FluidPhysicsMod.SPRING_BLOCK_ID && updateBlocksInWorld
43+
}
44+
45+
case class RainRefillConfig(probability: Double = 0.2,
46+
fluidWhitelist: Seq[Identifier] = Seq(Fluids.WATER).map(Registry.FLUID.getId),
47+
biomeDependent: Boolean = true) {
48+
lazy val getFluidWhitelist: Seq[Fluid] = fluidWhitelist.map(registryGet(Registry.FLUID, _))
49+
50+
def canRefillFluid(fluid: Fluid): Boolean = getFluidWhitelist.exists(_.matchesType(fluid))
51+
52+
def canRainAt(world: World, pos: BlockPos): Boolean =
53+
!biomeDependent || {
54+
val biome = world.getBiome(pos)
55+
biome.getPrecipitation == Biome.Precipitation.RAIN && biome.getTemperature(pos) >= 0.15F
56+
}
57+
}
58+
59+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package de.lolhens.minecraft.fluidphysics.mixin;
2+
3+
import de.lolhens.minecraft.fluidphysics.util.SpringFeature;
4+
import net.minecraft.util.math.BlockPos;
5+
import net.minecraft.world.ServerWorldAccess;
6+
import net.minecraft.world.gen.StructureAccessor;
7+
import net.minecraft.world.gen.chunk.ChunkGenerator;
8+
import net.minecraft.world.gen.feature.SpringFeatureConfig;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
import org.spongepowered.asm.mixin.injection.Inject;
12+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
13+
14+
import java.util.Random;
15+
16+
@Mixin(net.minecraft.world.gen.feature.SpringFeature.class)
17+
public class SpringFeatureMixin {
18+
@Inject(at = @At("RETURN"), method = "generate", cancellable = true)
19+
public void generate(ServerWorldAccess world,
20+
StructureAccessor structureAccessor,
21+
ChunkGenerator chunkGenerator,
22+
Random random,
23+
BlockPos blockPos,
24+
SpringFeatureConfig springFeatureConfig,
25+
CallbackInfoReturnable<Boolean> info) {
26+
if (info.getReturnValue()) {
27+
SpringFeature.generate(world, structureAccessor, chunkGenerator, random, blockPos, springFeatureConfig);
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)