Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.18.2 Rubidium support #34

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ repositories{
url = "https://modmaven.k-4u.nl"
}

maven {
name "modrinth"
url "https://api.modrinth.com/maven"
}

maven {
url "https://www.cursemaven.com"
}
Expand Down Expand Up @@ -88,8 +93,11 @@ mixin {
sourceSets.main.resources { srcDir 'src/generated/resources' }

dependencies {
minecraft 'net.minecraftforge:forge:1.18.2-40.1.80'
minecraft 'net.minecraftforge:forge:1.18.2-40.2.10'
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'

compileOnly fg.deobf("maven.modrinth:rubidium:${project.rubidium_version}")
//runtimeOnly fg.deobf("maven.modrinth:rubidium:${project.rubidium_version}") //for testing
}

jar {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.daemon=false
rubidium_version=0.5.6
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 16 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://maven.parchmentmc.org' }
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
}
resolutionStrategy {
eachPlugin {
if (requested.id.toString() == 'org.spongepowered.mixin') {
useModule("org.spongepowered:mixingradle:${requested.version}")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
import bottomtextdanny.effective_fg.tables.EffectiveFgParticles;
import bottomtextdanny.effective_fg.tables.EffectiveFgSounds;
import bottomtextdanny.effective_fg.sound.LinearFadeSound;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Camera;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.sounds.SoundManager;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.*;
import java.util.stream.Collectors;
Expand All @@ -23,6 +27,22 @@ public class WaterfallCloudGenerators {
private static boolean resolvingWaterfalls;
private static Level levelO = null;

public static void onRenderFluid(BlockAndTintGetter level, BlockPos pos, FluidState fluidState) {
if (!EffectiveFg.config().cascades.get()) return;

BlockState stateDoubleUp = level.getBlockState(pos.offset(0, 2, 0));
BlockState stateUp = level.getBlockState(pos.offset(0, 1, 0));
if (fluidState.isSource()
&& stateUp.getBlock() == Blocks.WATER
&& !stateUp.getFluidState().isSource()
&& stateUp.getFluidState().getOwnHeight() >= 0.77f
&& stateDoubleUp.is(Blocks.WATER) && !stateDoubleUp.getFluidState().isSource()) {
if (!WaterfallCloudGenerators.isResolvingWaterfalls()) {
addGenerator(new BlockPos(pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f));
}
}
}

public static void addGenerator(BlockPos blockPos) {
GENERATORS.add(blockPos);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,6 @@ public class LiquidBlockRendererMixin {

@Inject(method = "tesselate", at = @At("TAIL"))
public void renderFluid(BlockAndTintGetter level, BlockPos pos, VertexConsumer buffer, BlockState state, FluidState fluidState, CallbackInfoReturnable<Boolean> ci) {
if (!EffectiveFg.config().cascades.get()) return;

BlockState stateDoubleUp = level.getBlockState(pos.offset(0, 2, 0));
BlockState stateUp = level.getBlockState(pos.offset(0, 1, 0));
if (state.getBlock() == Blocks.WATER
&& fluidState.isSource()
&& stateUp.getBlock() == Blocks.WATER
&& !stateUp.getFluidState().isSource()
&& stateUp.getFluidState().getOwnHeight() >= 0.77f
&& stateDoubleUp.is(Blocks.WATER) && !stateDoubleUp.getFluidState().isSource()) {
if (!WaterfallCloudGenerators.isResolvingWaterfalls()) {
WaterfallCloudGenerators.addGenerator(new BlockPos(pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f));
}
}
WaterfallCloudGenerators.onRenderFluid(level, pos, fluidState);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package bottomtextdanny.effective_fg.mixin.integration.rubidium;


import bottomtextdanny.effective_fg.EffectiveFg;
import bottomtextdanny.effective_fg.level.WaterfallCloudGenerators;
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder;
import me.jellysquid.mods.sodium.client.render.pipeline.FluidRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.FluidState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = FluidRenderer.class, remap = false)
public class FluidRendererMixin {

@Inject(method = "render", at = @At("HEAD"))
public void renderFluid(BlockAndTintGetter level, FluidState fluidState, BlockPos pos, BlockPos offset, ChunkModelBuilder buffers, CallbackInfoReturnable<Boolean> cir)
{
WaterfallCloudGenerators.onRenderFluid(level, pos, fluidState);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/effective_fg.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"client": [
"EntityMixin",
"LiquidBlockRendererMixin",
"WaterFluidMixin"
"WaterFluidMixin",
"integration.rubidium.FluidRendererMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down