Skip to content

Commit

Permalink
Fix spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Dec 30, 2024
1 parent 99716ac commit 54d7078
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import com.enderio.conduits.client.model.conduit.facades.FacadeHelper;
import com.enderio.conduits.common.conduit.block.ConduitBundleBlockEntity;
import com.mojang.blaze3d.vertex.VertexConsumer;
import java.util.Map;

import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import java.util.Map;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.texture.OverlayTexture;
Expand All @@ -24,7 +23,8 @@
@EventBusSubscriber(bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
public class ConduitFacadeRendering {

private static final ThreadLocal<RandomSource> RANDOM = ThreadLocal.withInitial(() -> new SingleThreadedRandomSource(42L));
private static final ThreadLocal<RandomSource> RANDOM = ThreadLocal
.withInitial(() -> new SingleThreadedRandomSource(42L));

@SubscribeEvent
static void renderFacade(AddSectionGeometryEvent event) {
Expand All @@ -36,7 +36,8 @@ static void renderFacade(AddSectionGeometryEvent event) {
}
}

if (facades.isEmpty()) return;
if (facades.isEmpty())
return;

event.addRenderer(new FacadeRenderer(facades, FacadeHelper.areFacadesVisible()));
}
Expand All @@ -59,27 +60,25 @@ public void render(AddSectionGeometryEvent.SectionRenderingContext context) {
for (Map.Entry<BlockPos, BlockState> entry : facades.entrySet()) {
context.getPoseStack().pushPose();
context.getPoseStack()
.translate(entry.getKey().getX() & 15,
entry.getKey().getY() & 15,
entry.getKey().getZ() & 15);
.translate(entry.getKey().getX() & 15, entry.getKey().getY() & 15, entry.getKey().getZ() & 15);

var state = entry.getValue();
var pos = entry.getKey();

random.setSeed(42L);

var model = Minecraft.getInstance()
.getModelManager()
.getBlockModelShaper()
.getBlockModel(entry.getValue());
.getModelManager()
.getBlockModelShaper()
.getBlockModel(entry.getValue());

for (var renderType : model.getRenderTypes(entry.getValue(), random, ModelData.EMPTY)) {
VertexConsumer consumer = wrapper == null ? context.getOrCreateChunkBuffer(renderType) : wrapper;
Minecraft.getInstance().getBlockRenderer().getModelRenderer().tesselateBlock(context.getRegion(),
model, state, pos, context.getPoseStack(),
consumer, true, random,
42L, OverlayTexture.NO_OVERLAY,
ModelData.EMPTY, renderType);
Minecraft.getInstance()
.getBlockRenderer()
.getModelRenderer()
.tesselateBlock(context.getRegion(), model, state, pos, context.getPoseStack(), consumer,
true, random, 42L, OverlayTexture.NO_OVERLAY, ModelData.EMPTY, renderType);
}

context.getPoseStack().popPose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.enderio.conduits.api.ConduitNode;
import com.enderio.conduits.api.facade.FacadeType;
import com.enderio.conduits.api.model.ConduitCoreModelModifier;
import com.enderio.conduits.client.ConduitFacadeColor;
import com.enderio.conduits.client.model.conduit.facades.FacadeHelper;
import com.enderio.conduits.client.model.conduit.modifier.ConduitCoreModelModifiers;
import com.enderio.conduits.common.Area;
Expand All @@ -34,7 +33,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
Expand All @@ -50,7 +48,6 @@
import net.minecraft.util.RandomSource;
import net.minecraft.world.inventory.InventoryMenu;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.SingleThreadedRandomSource;
import net.neoforged.neoforge.client.ChunkRenderTypeSet;
Expand All @@ -77,8 +74,8 @@ public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction
// If the facade should hide the conduits, escape early.
if (conduitBundle.hasFacade()) {
boolean areConduitsHidden = conduitBundle.facadeType()
.map(FacadeType::doesHideConduits)
.orElse(false);
.map(FacadeType::doesHideConduits)
.orElse(false);

if (areConduitsHidden) {
return quads;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

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;
import net.minecraft.client.Minecraft;
import net.minecraft.core.SectionPos;

// TODO: In future, support hiding specific conduit types too.
public class FacadeHelper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
@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) {
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);
Expand Down

0 comments on commit 54d7078

Please sign in to comment.