Skip to content

Commit

Permalink
server fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed Aug 16, 2024
1 parent a3933ea commit c8e8666
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package net.id.paradiselost.blocks;

import net.fabricmc.api.EnvType;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FlattenableBlockRegistry;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.fabricmc.fabric.api.registry.TillableBlockRegistry;
import net.fabricmc.loader.api.FabricLoader;
import net.id.paradiselost.util.RenderUtils;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
Expand All @@ -12,6 +14,7 @@
import java.util.function.Consumer;

class ParadiseLostBlockActions {
private static boolean isClient = FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT;
protected static final AbstractBlock.ContextPredicate never = (state, view, pos) -> false;
protected static final AbstractBlock.ContextPredicate always = (state, view, pos) -> true;

Expand All @@ -24,9 +27,9 @@ protected static Consumer<Block> flammable(int spread, int burn) {
protected static final Consumer<Block> flammableLeaves = flammable(60, 30);
protected static final Consumer<Block> flammablePlant = flammable(60, 100);

protected static final Consumer<Block> translucentRenderLayer = (block) -> RenderUtils.transparentRenderLayer(block);
protected static final Consumer<Block> cutoutRenderLayer = (block) -> RenderUtils.cutoutRenderLayer(block);
protected static final Consumer<Block> cutoutMippedRenderLayer = (block) -> RenderUtils.cutoutMippedRenderLayer(block); //TODO
protected static final Consumer<Block> translucentRenderLayer = clientOnly((block) -> RenderUtils.transparentRenderLayer(block));
protected static final Consumer<Block> cutoutRenderLayer = clientOnly((block) -> RenderUtils.cutoutRenderLayer(block));
protected static final Consumer<Block> cutoutMippedRenderLayer = clientOnly((block) -> RenderUtils.cutoutMippedRenderLayer(block));

protected static Consumer<Block> stripsTo(Block stripped) {
return (original) -> StrippableBlockRegistry.register(original, stripped);
Expand All @@ -43,4 +46,9 @@ protected static Consumer<Block> coarseTillable() {
protected static Consumer<Block> flattenable(Block turnInto) {
return (block) -> FlattenableBlockRegistry.register(block, turnInto.getDefaultState());
}

protected static Consumer<Block> clientOnly(Consumer<Block> func) {
if (isClient) return func;
return (block) -> {};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public CloudRendererMixin() {
throw new NullPointerException("null cannot be cast to non-null type net.minecraft.client.world.ClientWorld");
}

@Inject(method = "renderClouds(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/util/math/Matrix4f;FDDD)V", at = @At("HEAD"), cancellable = true)
@Inject(method = "renderClouds(Lnet/minecraft/client/util/math/MatrixStack;Lorg/joml/Matrix4f;FDDD)V", at = @At("HEAD"), cancellable = true)
public void renderClouds(MatrixStack matrices, Matrix4f model, float tickDelta, double cameraX, double cameraY, double cameraZ, CallbackInfo ci) {
if (world.getRegistryKey() == ParadiseLostDimension.PARADISE_LOST_WORLD_KEY) {
internalCloudRender(matrices, model, tickDelta, cameraX, cameraY, cameraZ, 160, 1f, 1f);
Expand Down

0 comments on commit c8e8666

Please sign in to comment.