Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.20' into 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
TartaricAcid committed Jan 1, 2025
2 parents 9ceddc7 + 853c520 commit daa45fb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,11 @@ public ItemStack getProjectile(ItemStack weaponStack) {
if (this.getOffhandItem().getItem() instanceof FireworkRocketItem) {
return this.getOffhandItem();
}
if (!(this.getMainHandItem().getItem() instanceof ProjectileWeaponItem weaponItem)) {
return ItemStack.EMPTY;
}
CombinedInvWrapper handler = this.getAvailableInv(true);
int slot = ItemsUtil.findStackSlot(handler, ((CrossbowItem) this.getMainHandItem().getItem()).getAllSupportedProjectiles());
int slot = ItemsUtil.findStackSlot(handler, weaponItem.getAllSupportedProjectiles());
if (slot < 0) {
// 不存在时,返回空
return ItemStack.EMPTY;
Expand Down

0 comments on commit daa45fb

Please sign in to comment.