调炮
This commit is contained in:
parent
a4057cbfd5
commit
23bf1b1737
9 changed files with 99 additions and 67 deletions
|
@ -92,7 +92,7 @@ public class ClickHandler {
|
||||||
if (player.getMainHandItem().is(ModTags.Items.GUN)
|
if (player.getMainHandItem().is(ModTags.Items.GUN)
|
||||||
|| stack.is(ModItems.MONITOR.get())
|
|| stack.is(ModItems.MONITOR.get())
|
||||||
|| player.hasEffect(ModMobEffects.SHOCK.get())
|
|| player.hasEffect(ModMobEffects.SHOCK.get())
|
||||||
|| (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity && player.getMainHandItem().getItem() instanceof CannonShellItem)) {
|
|| (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity)) {
|
||||||
if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
if (button == GLFW.GLFW_MOUSE_BUTTON_LEFT) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
@ -114,9 +114,9 @@ public class ClickHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getMainHandItem().is(ModTags.Items.GUN)
|
if ((player.getMainHandItem().is(ModTags.Items.GUN) && !(player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity))
|
||||||
|| stack.is(ModItems.MONITOR.get())
|
|| stack.is(ModItems.MONITOR.get())
|
||||||
|| (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity && !player.getMainHandItem().is(ModTags.Items.GUN))
|
|| (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity)
|
||||||
|| (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) {
|
|| (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) {
|
||||||
if (button == ModKeyMappings.FIRE.getKey().getValue()) {
|
if (button == ModKeyMappings.FIRE.getKey().getValue()) {
|
||||||
handleWeaponFirePress(player, stack);
|
handleWeaponFirePress(player, stack);
|
||||||
|
@ -235,9 +235,9 @@ public class ClickHandler {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new SensitivityMessage(false));
|
ModUtils.PACKET_HANDLER.sendToServer(new SensitivityMessage(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getMainHandItem().is(ModTags.Items.GUN)
|
if ((player.getMainHandItem().is(ModTags.Items.GUN) && !(player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity))
|
||||||
|| stack.is(ModItems.MONITOR.get())
|
|| stack.is(ModItems.MONITOR.get())
|
||||||
|| (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity && !player.getMainHandItem().is(ModTags.Items.GUN))
|
|| (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity)
|
||||||
|| (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) {
|
|| (stack.is(Items.SPYGLASS) && player.isScoping() && player.getOffhandItem().is(ModItems.FIRING_PARAMETERS.get()))) {
|
||||||
if (key == ModKeyMappings.FIRE.getKey().getValue()) {
|
if (key == ModKeyMappings.FIRE.getKey().getValue()) {
|
||||||
handleWeaponFirePress(player, stack);
|
handleWeaponFirePress(player, stack);
|
||||||
|
@ -293,7 +293,7 @@ public class ClickHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.is(ModTags.Items.GUN)) {
|
if (stack.is(ModTags.Items.GUN) && !(player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity)) {
|
||||||
if ((!(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
if ((!(stack.getOrCreateTag().getBoolean("is_normal_reloading") || stack.getOrCreateTag().getBoolean("is_empty_reloading"))
|
||||||
&& !stack.getOrCreateTag().getBoolean("reloading")
|
&& !stack.getOrCreateTag().getBoolean("reloading")
|
||||||
&& !stack.getOrCreateTag().getBoolean("charging")
|
&& !stack.getOrCreateTag().getBoolean("charging")
|
||||||
|
|
|
@ -5,11 +5,10 @@ import com.atsuishio.superbwarfare.client.RenderHelper;
|
||||||
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.Mk42Entity;
|
import com.atsuishio.superbwarfare.entity.Mk42Entity;
|
||||||
import com.atsuishio.superbwarfare.entity.Mle1934Entity;
|
import com.atsuishio.superbwarfare.entity.Mle1934Entity;
|
||||||
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.tools.TraceTool;
|
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
|
||||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.renderer.GameRenderer;
|
import net.minecraft.client.renderer.GameRenderer;
|
||||||
|
@ -72,10 +71,10 @@ public class CannonHudOverlay {
|
||||||
int k = (w - i) / 2;
|
int k = (w - i) / 2;
|
||||||
int l = (h - j) / 2;
|
int l = (h - j) / 2;
|
||||||
if (ClientEventHandler.zoom) {
|
if (ClientEventHandler.zoom) {
|
||||||
Entity lookingEntity = TraceTool.findLookingEntity(player, 512);
|
Entity lookingEntity = TraceTool.cannonFindLookingEntity(player, 512);
|
||||||
boolean lookAtEntity = false;
|
boolean lookAtEntity = false;
|
||||||
double block_range = player.position().distanceTo((Vec3.atLowerCornerOf(player.level().clip(
|
double block_range = player.position().distanceTo((Vec3.atLowerCornerOf(player.level().clip(
|
||||||
new ClipContext(player.getEyePosition(), player.getEyePosition().add(player.getLookAngle().scale(512)),
|
new ClipContext(new Vec3(player.getX(), player.getEyeY() + 1, player.getZ()), new Vec3(player.getX(), player.getEyeY() + 1, player.getZ()).add(player.getLookAngle().scale(512)),
|
||||||
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
|
ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)).getBlockPos())));
|
||||||
|
|
||||||
double entity_range = 0;
|
double entity_range = 0;
|
||||||
|
@ -135,7 +134,6 @@ public class CannonHudOverlay {
|
||||||
private static boolean shouldRenderCrossHair(Player player) {
|
private static boolean shouldRenderCrossHair(Player player) {
|
||||||
if (player == null) return false;
|
if (player == null) return false;
|
||||||
return !player.isSpectator()
|
return !player.isSpectator()
|
||||||
&& !(player.getMainHandItem().getItem() instanceof GunItem)
|
|
||||||
&& (player.getVehicle() != null && (player.getVehicle() instanceof ICannonEntity));
|
&& (player.getVehicle() != null && (player.getVehicle() instanceof ICannonEntity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
package com.atsuishio.superbwarfare.client.screens;
|
package com.atsuishio.superbwarfare.client.screens;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
import com.atsuishio.superbwarfare.config.client.DisplayConfig;
|
||||||
|
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
||||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.init.ModTags;
|
||||||
|
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
import com.atsuishio.superbwarfare.perk.AmmoPerk;
|
||||||
import com.atsuishio.superbwarfare.perk.Perk;
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
import com.atsuishio.superbwarfare.perk.PerkHelper;
|
||||||
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import net.minecraft.client.CameraType;
|
import net.minecraft.client.CameraType;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
@ -49,6 +50,7 @@ public class CrossHairOverlay {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) return;
|
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) return;
|
||||||
|
if (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity) return;
|
||||||
|
|
||||||
GuiGraphics guiGraphics = event.getGuiGraphics();
|
GuiGraphics guiGraphics = event.getGuiGraphics();
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.atsuishio.superbwarfare.tools.ParticleTool;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.protocol.Packet;
|
import net.minecraft.network.protocol.Packet;
|
||||||
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
import net.minecraft.network.protocol.game.ClientGamePacketListener;
|
||||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||||
|
@ -45,7 +46,6 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
||||||
public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
|
|
||||||
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
||||||
public static final EntityDataAccessor<Integer> TYPE = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
|
||||||
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT);
|
public static final EntityDataAccessor<Float> HEALTH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT);
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
public static final float MAX_HEALTH = 700.0f;
|
public static final float MAX_HEALTH = 700.0f;
|
||||||
|
@ -64,21 +64,18 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
@Override
|
@Override
|
||||||
protected void defineSynchedData() {
|
protected void defineSynchedData() {
|
||||||
this.entityData.define(COOL_DOWN, 0);
|
this.entityData.define(COOL_DOWN, 0);
|
||||||
this.entityData.define(TYPE, 0);
|
|
||||||
this.entityData.define(HEALTH, MAX_HEALTH);
|
this.entityData.define(HEALTH, MAX_HEALTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAdditionalSaveData(CompoundTag compound) {
|
public void addAdditionalSaveData(CompoundTag compound) {
|
||||||
compound.putInt("CoolDown", this.entityData.get(COOL_DOWN));
|
compound.putInt("CoolDown", this.entityData.get(COOL_DOWN));
|
||||||
compound.putInt("Type", this.entityData.get(TYPE));
|
|
||||||
compound.putFloat("Health", this.entityData.get(HEALTH));
|
compound.putFloat("Health", this.entityData.get(HEALTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readAdditionalSaveData(CompoundTag compound) {
|
public void readAdditionalSaveData(CompoundTag compound) {
|
||||||
this.entityData.set(COOL_DOWN, compound.getInt("CoolDown"));
|
this.entityData.set(COOL_DOWN, compound.getInt("CoolDown"));
|
||||||
this.entityData.set(TYPE, compound.getInt("Type"));
|
|
||||||
if (compound.contains("Health")) {
|
if (compound.contains("Health")) {
|
||||||
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
this.entityData.set(HEALTH, compound.getFloat("Health"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -194,14 +191,6 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1);
|
this.entityData.set(COOL_DOWN, this.entityData.get(COOL_DOWN) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.entityData.get(COOL_DOWN) > 28) {
|
|
||||||
if (Math.random() < 0.5) {
|
|
||||||
this.entityData.set(TYPE, -1);
|
|
||||||
} else {
|
|
||||||
this.entityData.set(TYPE, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||||
if (this.onGround()) {
|
if (this.onGround()) {
|
||||||
this.setDeltaMovement(Vec3.ZERO);
|
this.setDeltaMovement(Vec3.ZERO);
|
||||||
|
@ -363,33 +352,46 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
|
|
||||||
if (!(passenger instanceof LivingEntity entity)) return;
|
if (!(passenger instanceof LivingEntity entity)) return;
|
||||||
|
|
||||||
float diffY = entity.getYHeadRot() - this.getYRot();
|
float passengerY = entity.getYHeadRot();
|
||||||
|
|
||||||
|
if (passengerY > 180.0f) {
|
||||||
|
passengerY -= 360.0f;
|
||||||
|
} else if (passengerY < -180.0f) {
|
||||||
|
passengerY += 360.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float diffY = passengerY - this.getYRot();
|
||||||
float diffX = entity.getXRot() - 1.3f - this.getXRot();
|
float diffX = entity.getXRot() - 1.3f - this.getXRot();
|
||||||
if (diffY > 180.0f) {
|
if (diffY > 180.0f) {
|
||||||
diffY -= 360.0f;
|
diffY -= 360.0f;
|
||||||
} else if (diffY < -180.0f) {
|
} else if (diffY < -180.0f) {
|
||||||
diffY += 360.0f;
|
diffY += 360.0f;
|
||||||
}
|
}
|
||||||
diffY = diffY * 0.15f;
|
diffY = Mth.clamp(diffY * 0.15f, -1.75f, 1.75f);
|
||||||
diffX = diffX * 0.15f;
|
diffX = diffX * 0.15f;
|
||||||
|
|
||||||
this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.75f, 1.75f));
|
this.setYRot(this.getYRot() + diffY);
|
||||||
|
|
||||||
|
if (passenger instanceof Player player) {
|
||||||
|
player.displayClientMessage(Component.literal("Angle:" + new java.text.DecimalFormat("##.##").format(this.getYRot()) + " diffY:" + new java.text.DecimalFormat("##.#").format(diffY)), true);
|
||||||
|
}
|
||||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -3f, 3f), -85, 16.3f));
|
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -3f, 3f), -85, 16.3f));
|
||||||
this.setRot(this.getYRot(), this.getXRot());
|
this.setRot(this.getYRot(), this.getXRot());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clampRotation(Entity entity) {
|
protected void clampRotation(Entity entity) {
|
||||||
ItemStack stack = ItemStack.EMPTY;
|
|
||||||
if (entity instanceof Player player) {
|
|
||||||
stack = player.getMainHandItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stack.is(ModTags.Items.GUN)) {
|
|
||||||
float f = Mth.wrapDegrees(entity.getXRot());
|
float f = Mth.wrapDegrees(entity.getXRot());
|
||||||
float f1 = Mth.clamp(f, -85.0F, 16.3F);
|
float f1 = Mth.clamp(f, -85.0F, 16.3F);
|
||||||
entity.xRotO += f1 - f;
|
entity.xRotO += f1 - f;
|
||||||
entity.setXRot(entity.getXRot() + f1 - f);
|
entity.setXRot(entity.getXRot() + f1 - f);
|
||||||
}
|
|
||||||
|
// entity.setYBodyRot(this.getYRot());
|
||||||
|
// float f2 = Mth.wrapDegrees(entity.getYRot() - this.getYRot());
|
||||||
|
// float f3 = Mth.clamp(f2, -60.0F, 60.0F);
|
||||||
|
// entity.yRotO += f3 - f2;
|
||||||
|
// entity.setYRot(entity.getYRot() + f3 - f2);
|
||||||
|
// entity.setYHeadRot(entity.getYRot());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -399,11 +401,7 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
|
|
||||||
private PlayState movementPredicate(AnimationState<Mk42Entity> event) {
|
private PlayState movementPredicate(AnimationState<Mk42Entity> event) {
|
||||||
if (this.entityData.get(COOL_DOWN) > 10) {
|
if (this.entityData.get(COOL_DOWN) > 10) {
|
||||||
if (this.entityData.get(TYPE) == 1) {
|
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire"));
|
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire"));
|
||||||
} else {
|
|
||||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.mk42.fire2"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mk42.idle"));
|
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.mk42.idle"));
|
||||||
|
|
|
@ -437,33 +437,35 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity {
|
||||||
|
|
||||||
if (!(passenger instanceof LivingEntity entity)) return;
|
if (!(passenger instanceof LivingEntity entity)) return;
|
||||||
|
|
||||||
float diffY = entity.getYHeadRot() - this.getYRot();
|
float passengerY = entity.getYHeadRot();
|
||||||
|
|
||||||
|
if (passengerY > 180.0f) {
|
||||||
|
passengerY -= 360.0f;
|
||||||
|
} else if (passengerY < -180.0f) {
|
||||||
|
passengerY += 360.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float diffY = passengerY - this.getYRot();
|
||||||
float diffX = entity.getXRot() - 1.2f - this.getXRot();
|
float diffX = entity.getXRot() - 1.2f - this.getXRot();
|
||||||
if (diffY > 180.0f) {
|
if (diffY > 180.0f) {
|
||||||
diffY -= 360.0f;
|
diffY -= 360.0f;
|
||||||
} else if (diffY < -180.0f) {
|
} else if (diffY < -180.0f) {
|
||||||
diffY += 360.0f;
|
diffY += 360.0f;
|
||||||
}
|
}
|
||||||
diffY = diffY * 0.15f;
|
diffY = Mth.clamp(diffY * 0.15f, -1.25f, 1.25f);
|
||||||
diffX = diffX * 0.15f;
|
diffX = diffX * 0.15f;
|
||||||
this.setYRot(this.getYRot() + Mth.clamp(diffY, -1.25f, 1.25f));
|
|
||||||
|
this.setYRot(this.getYRot() + diffY);
|
||||||
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -2f, 2f), -30, 4));
|
this.setXRot(Mth.clamp(this.getXRot() + Mth.clamp(diffX, -2f, 2f), -30, 4));
|
||||||
this.setRot(this.getYRot(), this.getXRot());
|
this.setRot(this.getYRot(), this.getXRot());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clampRotation(Entity entity) {
|
protected void clampRotation(Entity entity) {
|
||||||
ItemStack stack = ItemStack.EMPTY;
|
|
||||||
if (entity instanceof Player player) {
|
|
||||||
stack = player.getMainHandItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stack.is(ModTags.Items.GUN)) {
|
|
||||||
float f = Mth.wrapDegrees(entity.getXRot());
|
float f = Mth.wrapDegrees(entity.getXRot());
|
||||||
float f1 = Mth.clamp(f, -30.0F, 4.0F);
|
float f1 = Mth.clamp(f, -30.0F, 4.0F);
|
||||||
entity.xRotO += f1 - f;
|
entity.xRotO += f1 - f;
|
||||||
entity.setXRot(entity.getXRot() + f1 - f);
|
entity.setXRot(entity.getXRot() + f1 - f);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPassengerTurned(Entity entity) {
|
public void onPassengerTurned(Entity entity) {
|
||||||
|
|
|
@ -495,6 +495,7 @@ public class ClientEventHandler {
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
if (!player.getMainHandItem().is(ModTags.Items.GUN)) return;
|
if (!player.getMainHandItem().is(ModTags.Items.GUN)) return;
|
||||||
|
if (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity) return;
|
||||||
|
|
||||||
float pose;
|
float pose;
|
||||||
float times = 2 * (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8);
|
float times = 2 * (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8);
|
||||||
|
@ -1014,6 +1015,11 @@ public class ClientEventHandler {
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
|
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && zoom) {
|
||||||
|
event.setFOV(event.getFOV() / 5);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (stack.is(ModTags.Items.GUN)) {
|
if (stack.is(ModTags.Items.GUN)) {
|
||||||
if (!event.usedConfiguredFov()) {
|
if (!event.usedConfiguredFov()) {
|
||||||
return;
|
return;
|
||||||
|
@ -1038,10 +1044,6 @@ public class ClientEventHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && zoom && !stack.is(ModTags.Items.GUN)) {
|
|
||||||
event.setFOV(event.getFOV() / 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using") && stack.getOrCreateTag().getBoolean("Linked")) {
|
||||||
|
|
||||||
droneFovLerp = Mth.lerp(0.1 * Minecraft.getInstance().getDeltaFrameTime(), droneFovLerp, droneFov);
|
droneFovLerp = Mth.lerp(0.1 * Minecraft.getInstance().getDeltaFrameTime(), droneFovLerp, droneFov);
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class MouseHandlerMixin {
|
||||||
|
|
||||||
ItemStack stack = mc.player.getMainHandItem();
|
ItemStack stack = mc.player.getMainHandItem();
|
||||||
|
|
||||||
if (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity && !stack.is(ModTags.Items.GUN)) {
|
if (player.getVehicle() != null && player.getVehicle() instanceof ICannonEntity) {
|
||||||
if (ClientEventHandler.zoom) {
|
if (ClientEventHandler.zoom) {
|
||||||
return 0.15;
|
return 0.15;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package com.atsuishio.superbwarfare.network.message;
|
package com.atsuishio.superbwarfare.network.message;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
import com.atsuishio.superbwarfare.entity.ICannonEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModItems;
|
import com.atsuishio.superbwarfare.init.ModItems;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import com.atsuishio.superbwarfare.init.ModTags;
|
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
import com.atsuishio.superbwarfare.tools.SoundTool;
|
import com.atsuishio.superbwarfare.tools.SoundTool;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
|
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
|
||||||
|
@ -53,7 +52,7 @@ public class ZoomMessage {
|
||||||
capability.syncPlayerVariables(player);
|
capability.syncPlayerVariables(player);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && !stack.is(ModTags.Items.GUN)) {
|
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity) {
|
||||||
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_IN.get(), 2, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +64,7 @@ public class ZoomMessage {
|
||||||
capability.syncPlayerVariables(player);
|
capability.syncPlayerVariables(player);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity && !stack.is(ModTags.Items.GUN)) {
|
if (player.isPassenger() && player.getVehicle() instanceof ICannonEntity) {
|
||||||
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
|
SoundTool.playLocalSound(player, ModSounds.CANNON_ZOOM_OUT.get(), 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,4 +38,35 @@ public class TraceTool {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Entity cannonFindLookingEntity(Entity player, double entityReach) {
|
||||||
|
double distance = entityReach * entityReach;
|
||||||
|
Vec3 eyePos = new Vec3(player.getX(), player.getEyeY() + 1, player.getZ());
|
||||||
|
HitResult hitResult = player.pick(entityReach, 1.0f, false);
|
||||||
|
if (hitResult.getType() != HitResult.Type.MISS) {
|
||||||
|
distance = hitResult.getLocation().distanceToSqr(eyePos);
|
||||||
|
double blockReach = 5;
|
||||||
|
if (distance > blockReach * blockReach) {
|
||||||
|
Vec3 pos = hitResult.getLocation();
|
||||||
|
hitResult = BlockHitResult.miss(pos, Direction.getNearest(eyePos.x, eyePos.y, eyePos.z), BlockPos.containing(pos));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Vec3 viewVec = player.getViewVector(1.0F);
|
||||||
|
Vec3 toVec = eyePos.add(viewVec.x * entityReach, viewVec.y * entityReach, viewVec.z * entityReach);
|
||||||
|
AABB aabb = player.getBoundingBox().expandTowards(viewVec.scale(entityReach)).inflate(1.0D, 1.0D, 1.0D);
|
||||||
|
EntityHitResult entityhitresult = ProjectileUtil.getEntityHitResult(player, eyePos, toVec, aabb, p -> !p.isSpectator(), distance);
|
||||||
|
if (entityhitresult != null) {
|
||||||
|
Vec3 targetPos = entityhitresult.getLocation();
|
||||||
|
double distanceToTarget = eyePos.distanceToSqr(targetPos);
|
||||||
|
if (distanceToTarget > distance || distanceToTarget > entityReach * entityReach) {
|
||||||
|
hitResult = BlockHitResult.miss(targetPos, Direction.getNearest(viewVec.x, viewVec.y, viewVec.z), BlockPos.containing(targetPos));
|
||||||
|
} else if (distanceToTarget < distance) {
|
||||||
|
hitResult = entityhitresult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hitResult.getType() == HitResult.Type.ENTITY) {
|
||||||
|
return ((EntityHitResult) hitResult).getEntity();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue