From dd2bdda9e812ca8d86a92ff18b953c3e8861b727 Mon Sep 17 00:00:00 2001 From: Mgazul Date: Wed, 25 Dec 2024 23:10:57 +0800 Subject: [PATCH 1/2] Fixed https://github.com/TartaricAcid/TouhouLittleMaid/issues/523 (#628) --- .../touhoulittlemaid/entity/passive/EntityMaid.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/passive/EntityMaid.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/passive/EntityMaid.java index abd5fb1d9..eacf41aca 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/passive/EntityMaid.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/passive/EntityMaid.java @@ -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; From 853c5208bef02a5d23807d64a09e01eb020ef733 Mon Sep 17 00:00:00 2001 From: MaydayMemory <41233300+286799714@users.noreply.github.com> Date: Fri, 27 Dec 2024 18:45:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=B1=BC=E7=BA=BF?= =?UTF-8?q?=E5=9C=A8=20oculus=20=E4=B8=8B=E7=9A=84=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#630)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/init/ClientSetupEvent.java | 2 ++ .../renderer/entity/MaidFishingHookRenderer.java | 7 +++++-- .../compat/oculus/OculusCompat.java | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/oculus/OculusCompat.java diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/init/ClientSetupEvent.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/init/ClientSetupEvent.java index 42525f93e..8223ca945 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/init/ClientSetupEvent.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/init/ClientSetupEvent.java @@ -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; @@ -26,6 +27,7 @@ public static void onClientSetup(FMLClientSetupEvent event) { // 客户端兼容 SimpleHatsCompat.init(); ImmersiveMelodiesCompat.init(); + OculusCompat.init(); } @SubscribeEvent diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/renderer/entity/MaidFishingHookRenderer.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/renderer/entity/MaidFishingHookRenderer.java index 861553409..315c81d0a 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/renderer/entity/MaidFishingHookRenderer.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/client/renderer/entity/MaidFishingHookRenderer.java @@ -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; @@ -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) { diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/oculus/OculusCompat.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/oculus/OculusCompat.java new file mode 100644 index 000000000..441552439 --- /dev/null +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/compat/oculus/OculusCompat.java @@ -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; + } +}