-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
126 additions
and
89 deletions.
There are no files selected for viewing
123 changes: 70 additions & 53 deletions
123
enderio-conduits/src/main/java/com/enderio/conduits/client/ConduitFacadeRendering.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
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
30 changes: 18 additions & 12 deletions
30
...onduits/src/main/java/com/enderio/conduits/client/model/conduit/facades/FacadeHelper.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 |
---|---|---|
@@ -1,29 +1,35 @@ | ||
package com.enderio.conduits.client.model.conduit.facades; | ||
|
||
import com.enderio.conduits.common.conduit.block.ConduitBundleBlockEntity; | ||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.core.SectionPos; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
// TODO: In future, support hiding specific conduit types too. | ||
public class FacadeHelper { | ||
|
||
private static boolean FACADES_VISIBLE = true; | ||
|
||
public static void setFacadesVisible(boolean visible) { | ||
if (visible != FACADES_VISIBLE) { | ||
Set<SectionPos> facadeSections = new HashSet<>(); | ||
|
||
ConduitBundleBlockEntity.FACADES.keySet().forEach((pos) -> facadeSections.add(SectionPos.of(pos))); | ||
|
||
RenderSystem.recordRenderCall(() -> { | ||
facadeSections.forEach((section) -> { | ||
Minecraft.getInstance().levelRenderer.setSectionDirty(section.x(), section.y(), section.z()); | ||
}); | ||
}); | ||
} | ||
|
||
FACADES_VISIBLE = visible; | ||
} | ||
|
||
public static boolean areFacadesVisible() { | ||
return FACADES_VISIBLE; | ||
} | ||
|
||
public static void rebuildChunkMeshes() { | ||
var minecraft = Minecraft.getInstance(); | ||
|
||
if (minecraft.levelRenderer.viewArea == null) { | ||
return; | ||
} | ||
|
||
for (var section : minecraft.levelRenderer.viewArea.sections) { | ||
section.setDirty(false); | ||
} | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
enderio-conduits/src/main/java/com/enderio/conduits/mixin/BlockRenderDispatcherMixin.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,23 @@ | ||
package com.enderio.conduits.mixin; | ||
|
||
import com.enderio.conduits.common.conduit.block.ConduitBundleBlockEntity; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import net.minecraft.client.renderer.block.BlockModelShaper; | ||
import net.minecraft.client.renderer.block.BlockRenderDispatcher; | ||
import net.minecraft.client.resources.model.BakedModel; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.BlockAndTintGetter; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(BlockRenderDispatcher.class) | ||
public class BlockRenderDispatcherMixin { | ||
@WrapOperation(method = "renderBreakingTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/neoforged/neoforge/client/model/data/ModelData;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockModelShaper;getBlockModel(Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/client/resources/model/BakedModel;")) | ||
public BakedModel enderio$checkFacades(BlockModelShaper instance, BlockState state, Operation<BakedModel> original, BlockState localState, BlockPos pos, BlockAndTintGetter level) { | ||
BlockState facadeState = ConduitBundleBlockEntity.FACADES.getOrDefault(pos, null); | ||
|
||
return original.call(instance, facadeState == null ? state : facadeState); | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
enderio-conduits/src/main/resources/enderioconduits.mixins.json
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,9 @@ | ||
{ | ||
"required" : true, | ||
"package" : "com.enderio.conduits.mixin", | ||
"compatibilityLevel" : "JAVA_17", | ||
"client" : [ | ||
"BlockRenderDispatcherMixin" | ||
], | ||
"minVersion" : "0.8" | ||
} |