-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert waterfall generator generation at initial fluid rendering, fix…
… concurrent modification crashes
- Loading branch information
Showing
9 changed files
with
209 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ladysnake.effective.mixin; | ||
|
||
import ladysnake.effective.client.Config; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.particle.ParticleTypes; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.Random; | ||
|
||
@Mixin(Block.class) | ||
public abstract class BlockMixin { | ||
@Shadow | ||
public abstract BlockState getDefaultState(); | ||
|
||
@Inject(method = "randomDisplayTick", at = @At("RETURN")) | ||
protected void illuminations$randomDisplayTick(BlockState state, World world, BlockPos pos, Random random, CallbackInfo ci) { | ||
if (Config.enableWaterfallParticles && state.getBlock() == Blocks.WATER && !world.getBlockState(pos.add(0, 1, 0)).getFluidState().isStill() && world.getBlockState(pos.add(0, 1, 0)).getBlock() == Blocks.WATER && !world.getBlockState(pos.add(0, 1, 0)).getFluidState().isStill() && world.getBlockState(pos.add(0, 1, 0)).getFluidState().getHeight() >= 0.77f) { | ||
Vec3d vec3d = state.getFluidState().getVelocity(world, pos); | ||
for (int i = 0; i < random.nextInt(50); i++) { | ||
world.addParticle(ParticleTypes.SPLASH, pos.getX() + .5 + random.nextGaussian() / 2f, pos.getY() + 1 + random.nextFloat(), pos.getZ() + .5 + random.nextGaussian() / 2f, vec3d.getX() * random.nextFloat(), random.nextFloat() / 10f, vec3d.getZ() * random.nextFloat()); | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/ladysnake/effective/mixin/BlockRenderManagerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ladysnake.effective.mixin; | ||
|
||
import ladysnake.effective.client.world.WaterfallCloudGenerators; | ||
import net.minecraft.client.render.VertexConsumer; | ||
import net.minecraft.client.render.block.BlockRenderManager; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.BlockRenderView; | ||
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(BlockRenderManager.class) | ||
public class BlockRenderManagerMixin { | ||
@Inject(method = "renderFluid", at = @At("TAIL")) | ||
public void renderFluid(BlockPos pos, BlockRenderView world, VertexConsumer vertexConsumer, FluidState state, CallbackInfoReturnable<Boolean> callbackInfoReturnable) { | ||
WaterfallCloudGenerators.tryAddGenerator(world, pos); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/ladysnake/effective/mixin/CompatMixinPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package ladysnake.effective.mixin; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class CompatMixinPlugin implements IMixinConfigPlugin { | ||
private static final Logger logger = LogManager.getLogger("Effective"); | ||
|
||
@Override | ||
public void onLoad(String mixinPackage) { | ||
// NOOP | ||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
if (mixinClassName.equals("ladysnake.effective.mixin.compat.CanvasTerrainRenderContextMixin")) { | ||
final boolean canvasIsLoaded = FabricLoader.getInstance().isModLoaded("canvas"); | ||
|
||
if (canvasIsLoaded) { | ||
logger.info("Canvas found. Applying compatibility mixin..."); | ||
} | ||
|
||
return canvasIsLoaded; | ||
} | ||
|
||
if (mixinClassName.equals("ladysnake.effective.mixin.compat.SodiumFluidRendererMixin")) { | ||
final boolean sodiumIsLoaded = FabricLoader.getInstance().isModLoaded("sodium"); | ||
|
||
if (sodiumIsLoaded) { | ||
logger.info("Sodium found. Applying compatibility mixin..."); | ||
} | ||
|
||
return sodiumIsLoaded; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
|
||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
// NOOP | ||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
// NOOP | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
src/main/java/ladysnake/effective/mixin/WaterFluidMixin.java
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
src/main/java/ladysnake/effective/mixin/compat/CanvasTerrainRenderContextMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ladysnake.effective.mixin.compat; | ||
|
||
import grondag.canvas.apiimpl.rendercontext.CanvasTerrainRenderContext; | ||
import io.vram.frex.api.model.BlockModel; | ||
import ladysnake.effective.client.world.WaterfallCloudGenerators; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.util.math.BlockPos; | ||
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; | ||
|
||
@Mixin(CanvasTerrainRenderContext.class) | ||
public class CanvasTerrainRenderContextMixin { | ||
@Inject(method = "renderFluid", at = @At("TAIL")) | ||
public void renderFluid(BlockState blockState, BlockPos blockPos, boolean defaultAo, BlockModel model, CallbackInfo ci) { | ||
WaterfallCloudGenerators.tryAddGenerator(MinecraftClient.getInstance().world, blockPos); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/ladysnake/effective/mixin/compat/SodiumFluidRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package ladysnake.effective.mixin.compat; | ||
|
||
import ladysnake.effective.client.world.WaterfallCloudGenerators; | ||
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder; | ||
import me.jellysquid.mods.sodium.client.render.pipeline.FluidRenderer; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.BlockRenderView; | ||
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(FluidRenderer.class) | ||
public class SodiumFluidRendererMixin { | ||
@Inject(method = "render", at = @At("HEAD")) | ||
public void renderFluid(BlockRenderView world, FluidState fluidState, BlockPos pos, BlockPos offset, ChunkModelBuilder buffers, CallbackInfoReturnable<Boolean> cir) { | ||
WaterfallCloudGenerators.tryAddGenerator(world, pos); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters