Skip to content

Commit

Permalink
Fix stalling bug
Browse files Browse the repository at this point in the history
  • Loading branch information
FxMorin committed Jun 3, 2022
1 parent 3bec319 commit 4915458
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.fxco.moreculling.mixin;

import ca.fxco.moreculling.patches.BakedTransparency;
import ca.fxco.moreculling.utils.BlockUtils;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -46,7 +47,7 @@ public class BlockModelRenderer_drawSideMixin {
private void getBakedQuadsSmooth(BlockRenderView world, BakedModel model, BlockState state, BlockPos pos,
MatrixStack matrices, VertexConsumer vertexConsumer, boolean cull, Random random,
long seed, int overlay, CallbackInfoReturnable<Boolean> cir) {
this.hasTransparency.set(model.hasTransparency());
this.hasTransparency.set(((BakedTransparency)model).hasTransparency());
}


Expand Down Expand Up @@ -85,7 +86,7 @@ private boolean shouldDrawSideSmooth(BlockState state, BlockView world,
private void getBakedQuadsFlat(BlockRenderView world, BakedModel model, BlockState state, BlockPos pos,
MatrixStack matrices, VertexConsumer vertexConsumer, boolean cull, Random random,
long seed, int overlay, CallbackInfoReturnable<Boolean> cir) {
this.hasTransparency.set(model.hasTransparency());
this.hasTransparency.set(((BakedTransparency)model).hasTransparency());
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.fxco.moreculling.mixin;

import ca.fxco.moreculling.patches.BakedTransparency;
import ca.fxco.moreculling.utils.BlockUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
Expand All @@ -23,6 +24,6 @@ public class Block_drawSideMixin {
@Overwrite
public static boolean shouldDrawSide(BlockState state, BlockView world, BlockPos pos, Direction side, BlockPos otherPos) {
if (blockRenderManager == null) blockRenderManager = MinecraftClient.getInstance().getBlockRenderManager();
return BlockUtils.shouldDrawSideTransparency(blockRenderManager, state, world, pos, side, otherPos, blockRenderManager.getModel(state).hasTransparency());
return BlockUtils.shouldDrawSideTransparency(blockRenderManager, state, world, pos, side, otherPos, ((BakedTransparency)blockRenderManager.getModel(state)).hasTransparency());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ca.fxco.moreculling.mixin.models;

import ca.fxco.moreculling.patches.BakedTransparency;
import net.minecraft.client.render.model.BakedModel;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(BakedModel.class)
public interface BakedModel_extendsMixin extends BakedTransparency {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ca.fxco.moreculling.mixin.models;

import ca.fxco.moreculling.patches.BakedTransparency;
import ca.fxco.moreculling.utils.SpriteUtils;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.BasicBakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
Expand All @@ -18,7 +18,7 @@
import java.util.Map;

@Mixin(BasicBakedModel.class)
public abstract class BasicBakedModel_cacheMixin implements BakedModel {
public abstract class BasicBakedModel_cacheMixin implements BakedTransparency {

@Unique
private boolean hasTransparency;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ca.fxco.moreculling.mixin.models;

import ca.fxco.moreculling.patches.BakedTransparency;
import ca.fxco.moreculling.utils.SpriteUtils;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BuiltinBakedModel;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.json.ModelTransformation;
Expand All @@ -13,7 +13,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(BuiltinBakedModel.class)
public abstract class BuiltinBakedModel_cacheMixin implements BakedModel {
public abstract class BuiltinBakedModel_cacheMixin implements BakedTransparency {

@Unique
private boolean hasTransparency;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package ca.fxco.moreculling.mixin.models;

import net.minecraft.client.render.model.BakedModel;
import ca.fxco.moreculling.patches.BakedTransparency;
import net.minecraft.client.render.model.MultipartBakedModel;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(MultipartBakedModel.class)
public abstract class MultipartBakedModel_cacheMixin implements BakedModel {
public abstract class MultipartBakedModel_cacheMixin implements BakedTransparency {

@Override
public boolean hasTransparency() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.fxco.moreculling.mixin.models;

import ca.fxco.moreculling.patches.BakedTransparency;
import ca.fxco.moreculling.utils.SpriteUtils;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.WeightedBakedModel;
Expand All @@ -15,7 +16,7 @@
import java.util.List;

@Mixin(WeightedBakedModel.class)
public abstract class WeightedBakedModel_cacheMixin implements BakedModel {
public abstract class WeightedBakedModel_cacheMixin implements BakedTransparency {

@Shadow
@Final
Expand All @@ -38,6 +39,6 @@ private void onInit(List<Weighted.Present<BakedModel>> models, CallbackInfo ci)
hasTransparency = SpriteUtils.doesHaveTransparency(this.defaultModel.getParticleSprite());
if (!hasTransparency)
for (Weighted.Present<BakedModel> bakedModelPresent : models)
hasTransparency |= bakedModelPresent.getData().hasTransparency();
hasTransparency |= ((BakedTransparency)bakedModelPresent.getData()).hasTransparency();
}
}
5 changes: 2 additions & 3 deletions src/main/java/ca/fxco/moreculling/utils/BlockUtils.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package ca.fxco.moreculling.utils;

import ca.fxco.moreculling.mixin.accessors.AbstractBlockAccessor;
import ca.fxco.moreculling.patches.BakedTransparency;
import it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap;
import net.minecraft.block.*;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.block.BlockModelRenderer;
import net.minecraft.client.render.block.BlockRenderManager;
import net.minecraft.util.function.BooleanBiFunction;
import net.minecraft.util.math.BlockPos;
Expand All @@ -24,7 +23,7 @@ public static boolean shouldDrawSideTransparency(BlockRenderManager blockRenderM
if (state.isSideInvisible(blockState, side)) return false;
Block block = blockState.getBlock();
if (blockState.isOpaque() || (!hasTransparency && ((AbstractBlockAccessor)block).getCollidable() &&
!blockRenderManager.getModel(blockState).hasTransparency())) {
!((BakedTransparency)blockRenderManager.getModel(blockState)).hasTransparency())) {
if (block instanceof LeavesBlock || block instanceof DoorBlock) return true; // Replace to a blockTag instead
Block.NeighborGroup neighborGroup = new Block.NeighborGroup(state, blockState, side);
Object2ByteLinkedOpenHashMap<Block.NeighborGroup> object2ByteLinkedOpenHashMap = FACE_CULL_MAP.get();
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
"mc-publish": {
"curseforge": 630104,
"modrinth": "51shyZVL"
},
"loom:injected_interfaces": {
"net/minecraft/class_1087": ["ca/fxco/moreculling/patches/BakedTransparency"]
}
}
}
7 changes: 5 additions & 2 deletions src/main/resources/moreculling.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"package": "ca.fxco.moreculling.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"BlockModelRenderer_drawSideMixin",
"Block_drawSideMixin",
"BlockModelRenderer_drawSideMixin",
"accessors.AbstractBlockAccessor",
"models.BasicBakedModel_cacheMixin",
"models.BuiltinBakedModel_cacheMixin",
Expand All @@ -14,5 +14,8 @@
],
"injectors": {
"defaultRequire": 1
}
},
"mixins": [
"models.BakedModel_extendsMixin"
]
}

0 comments on commit 4915458

Please sign in to comment.