修改视角摇晃mixin的瞄准判定
This commit is contained in:
parent
2fa0f1ee5d
commit
9fea16c9b6
2 changed files with 3 additions and 59 deletions
|
@ -1,39 +0,0 @@
|
||||||
//package net.mcreator.target.client;
|
|
||||||
//
|
|
||||||
//import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
//import com.mojang.math.Axis;
|
|
||||||
//import net.minecraft.client.Minecraft;
|
|
||||||
//import net.minecraft.util.Mth;
|
|
||||||
//import net.minecraft.world.entity.player.Player;
|
|
||||||
//import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
//import net.minecraftforge.client.event.RenderHandEvent;
|
|
||||||
//import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
||||||
//import net.minecraftforge.fml.common.Mod;
|
|
||||||
//
|
|
||||||
//@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
|
|
||||||
//public class GunRenderingHandler {
|
|
||||||
//
|
|
||||||
// @SubscribeEvent
|
|
||||||
// public static void onRenderOverlay(RenderHandEvent event) {
|
|
||||||
// PoseStack poseStack = event.getPoseStack();
|
|
||||||
// poseStack.pushPose();
|
|
||||||
// /* Applies custom bobbing animations */
|
|
||||||
// applyBobbingTransforms(poseStack, event.getPartialTick());
|
|
||||||
//
|
|
||||||
// poseStack.popPose();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static void applyBobbingTransforms(PoseStack poseStack, float partialTicks) {
|
|
||||||
// Minecraft mc = Minecraft.getInstance();
|
|
||||||
// if (mc.options.bobView().get() && mc.getCameraEntity() instanceof Player player) {
|
|
||||||
// float deltaDistanceWalked = player.walkDist - player.walkDistO;
|
|
||||||
// float distanceWalked = -(player.walkDist + deltaDistanceWalked * partialTicks);
|
|
||||||
// float bobbing = Mth.lerp(partialTicks, player.oBob, player.bob);
|
|
||||||
//
|
|
||||||
// /* Reverses the original bobbing rotations and translations so it can be controlled */
|
|
||||||
// poseStack.mulPose(Axis.XP.rotationDegrees(-(Math.abs(Mth.cos(distanceWalked * (float) Math.PI - 0.2F) * bobbing) * 5.0F)));
|
|
||||||
// poseStack.mulPose(Axis.ZP.rotationDegrees(-(Mth.sin(distanceWalked * (float) Math.PI) * bobbing * 3.0F)));
|
|
||||||
// poseStack.translate(-(Mth.sin(distanceWalked * (float) Math.PI) * bobbing * 0.5F), -(-Math.abs(Mth.cos(distanceWalked * (float) Math.PI) * bobbing)), 0.0D);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
|
@ -5,6 +5,7 @@ import net.mcreator.target.init.TargetModTags;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
@ -12,32 +13,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
@Mixin(GameRenderer.class)
|
@Mixin(GameRenderer.class)
|
||||||
public class GameRendererMixin {
|
public class GameRendererMixin {
|
||||||
// private boolean flag;
|
|
||||||
|
|
||||||
// @Inject(method = "renderItemInHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/Camera;F)V", at = @At("HEAD"))
|
|
||||||
// public void renderItemInHand(PoseStack p_109121_, Camera p_109122_, float p_109123_, CallbackInfo ci) {
|
|
||||||
// Minecraft minecraft = Minecraft.getInstance();
|
|
||||||
// Player player = minecraft.player;
|
|
||||||
// if (player != null) {
|
|
||||||
// flag = minecraft.options.bobView().get();
|
|
||||||
// ItemStack heldItem = player.getMainHandItem();
|
|
||||||
// if (heldItem.is(ItemTags.create(new ResourceLocation("target", "gun"))) && heldItem.getOrCreateTag().getBoolean("aiming")) {
|
|
||||||
// minecraft.options.bobView().set(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @Inject(method = "renderItemInHand(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/Camera;F)V", at = @At("RETURN"))
|
|
||||||
// public void renderItemInHandEnd(PoseStack p_109121_, Camera p_109122_, float p_109123_, CallbackInfo ci) {
|
|
||||||
// Minecraft.getInstance().options.bobView().set(flag);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Inject(method = "bobView(Lcom/mojang/blaze3d/vertex/PoseStack;F)V", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "bobView(Lcom/mojang/blaze3d/vertex/PoseStack;F)V", at = @At("HEAD"), cancellable = true)
|
||||||
public void bobView(PoseStack p_109139_, float p_109140_, CallbackInfo ci) {
|
public void bobView(PoseStack p_109139_, float p_109140_, CallbackInfo ci) {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
Player player = mc.player;
|
Player player = mc.player;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
if (player.getMainHandItem().is(TargetModTags.Items.GUN)) {
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
if (stack.is(TargetModTags.Items.GUN) && stack.getOrCreateTag().getBoolean("aiming")) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue