Skip to content

Commit

Permalink
v1.6.3 - Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
DakotaPride committed Feb 4, 2024
1 parent fecaed9 commit 0a15327
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package net.dakotapride.garnished.mixin;

import io.github.fabricators_of_create.porting_lib.util.FluidStack;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;

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.CallbackInfo;

import com.simibubi.create.content.fluids.FluidReactions;
import com.simibubi.create.foundation.fluid.FluidHelper;

import net.dakotapride.garnished.registry.GarnishedFluids;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.Fluids;

@Mixin(value = FluidReactions.class, remap = false)
public class FluidReactionsMixin {

@Inject(method = "handlePipeFlowCollision", at = @At("HEAD"))
private static void handlePipeFlowCollisionFallback(Level world, BlockPos pos, FluidStack fluid, FluidStack fluid2, CallbackInfo ci) {
Fluid f1 = fluid.getFluid();
Fluid f2 = fluid2.getFluid();

if (f1 == Fluids.LAVA && FluidHelper.hasBlockState(f2)) {
BlockState lavaInteraction = GarnishedFluids.getLavaInteraction(FluidHelper.convertToFlowing(f2).defaultFluidState());
if (lavaInteraction != null) {
world.setBlockAndUpdate(pos, lavaInteraction);
}
} else if (f2 == Fluids.LAVA && FluidHelper.hasBlockState(f1)) {
BlockState lavaInteraction = GarnishedFluids.getLavaInteraction(FluidHelper.convertToFlowing(f1).defaultFluidState());
if (lavaInteraction != null) {
world.setBlockAndUpdate(pos, lavaInteraction);
}
}
}

@Inject(method = "handlePipeSpillCollision", at = @At("HEAD"))
private static void handlePipeSpillCollisionFallback(Level world, BlockPos pos, Fluid pipeFluid, FluidState worldFluid, CallbackInfo ci) {
Fluid pf = FluidHelper.convertToStill(pipeFluid);
Fluid wf = worldFluid.getType();

if (FluidHelper.isTag(pf, FluidTags.WATER) && wf == Fluids.LAVA) {
world.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState());
}

if (pf == Fluids.LAVA) {
BlockState lavaInteraction = GarnishedFluids.getLavaInteraction(wf.defaultFluidState());
if (lavaInteraction != null) {
world.setBlockAndUpdate(pos, lavaInteraction);
}
} else if (wf == Fluids.FLOWING_LAVA && FluidHelper.hasBlockState(pf)) {
BlockState lavaInteraction = GarnishedFluids.getLavaInteraction(FluidHelper.convertToFlowing(pf).defaultFluidState());
if (lavaInteraction != null) {
world.setBlockAndUpdate(pos, lavaInteraction);
}
}
}

}
1 change: 1 addition & 0 deletions src/main/resources/garnished.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"BoatMixin",
"BoatTypeMixin",
"EnderManMixin",
"FluidReactionsMixin",
"ItemStackMixin",
"LivingEntityMixin",
"PotionBrewingMixin"
Expand Down

0 comments on commit 0a15327

Please sign in to comment.