Skip to content

Commit

Permalink
修正鱼线在 oculus 下的渲染问题 (#630)
Browse files Browse the repository at this point in the history
  • Loading branch information
286799714 authored Dec 27, 2024
1 parent dd2bdda commit 853c520
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.github.tartaricacid.touhoulittlemaid.client.overlay.BroomTipsOverlay;
import com.github.tartaricacid.touhoulittlemaid.client.overlay.MaidTipsOverlay;
import com.github.tartaricacid.touhoulittlemaid.compat.immersivemelodies.ImmersiveMelodiesCompat;
import com.github.tartaricacid.touhoulittlemaid.compat.oculus.OculusCompat;
import com.github.tartaricacid.touhoulittlemaid.compat.simplehats.SimpleHatsCompat;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RegisterGuiOverlaysEvent;
Expand All @@ -26,6 +27,7 @@ public static void onClientSetup(FMLClientSetupEvent event) {
// 客户端兼容
SimpleHatsCompat.init();
ImmersiveMelodiesCompat.init();
OculusCompat.init();
}

@SubscribeEvent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.github.tartaricacid.touhoulittlemaid.client.renderer.entity;

import com.github.tartaricacid.touhoulittlemaid.compat.oculus.OculusCompat;
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import com.github.tartaricacid.touhoulittlemaid.entity.projectile.MaidFishingHook;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.blaze3d.vertex.*;
import com.mojang.math.Axis;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
Expand Down Expand Up @@ -92,6 +92,9 @@ protected void renderFishingLine(T fishingHook, float partialTicks, PoseStack po
for (int i = 0; i <= 16; ++i) {
stringVertex(x, y, z, lineConsumer, lasted, fraction(i), fraction(i + 1), colors[0], colors[1], colors[2]);
}
if (OculusCompat.isOculusInstalled()) {
lineConsumer.vertex(0.0, 0.0, 0.0).color(0, 0, 0, 255).normal(0.0F, 0.0F, 0.0F).endVertex();
}
}

protected float fraction(int numerator) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.github.tartaricacid.touhoulittlemaid.compat.oculus;

import net.minecraftforge.fml.ModList;

public final class OculusCompat {
public static final String OCULUS = "oculus";
public static boolean IS_OCULUS_INSTALLED = false;

public static void init() {
IS_OCULUS_INSTALLED = ModList.get().getModContainerById(OCULUS).isPresent();
}

public static boolean isOculusInstalled() {
return IS_OCULUS_INSTALLED;
}
}

0 comments on commit 853c520

Please sign in to comment.