修复了旁观者模式能开火的问题
This commit is contained in:
parent
557503e28c
commit
6d64b57f22
6 changed files with 37 additions and 29 deletions
|
@ -0,0 +1,21 @@
|
|||
package net.mcreator.superbwarfare.block;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ReforgingTableBlock extends Block implements EntityBlock {
|
||||
|
||||
public ReforgingTableBlock(Properties pProperties) {
|
||||
super(pProperties);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -61,6 +61,9 @@ public class ClickHandler {
|
|||
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if (player == null) return;
|
||||
|
||||
if (player.isSpectator()) return;
|
||||
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
int button = event.getButton();
|
||||
|
@ -160,8 +163,6 @@ public class ClickHandler {
|
|||
}
|
||||
|
||||
setKeyState(event.getKey(), clicked ? 1 : 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,6 @@ import net.minecraftforge.fml.common.Mod;
|
|||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||
public class AmmoBarOverlay {
|
||||
// private static final ResourceLocation BUTTON = new ResourceLocation(TargetMod.MODID, "textures/gun_icon/fire_mode/button.png");
|
||||
private static final ResourceLocation LINE = new ResourceLocation(ModUtils.MODID, "textures/gun_icon/fire_mode/line.png");
|
||||
private static final ResourceLocation SEMI = new ResourceLocation(ModUtils.MODID, "textures/gun_icon/fire_mode/semi.png");
|
||||
private static final ResourceLocation BURST = new ResourceLocation(ModUtils.MODID, "textures/gun_icon/fire_mode/burst.png");
|
||||
|
@ -35,6 +34,10 @@ public class AmmoBarOverlay {
|
|||
return;
|
||||
}
|
||||
|
||||
if (player.isSpectator()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (stack.getItem() instanceof GunItem gunItem) {
|
||||
PoseStack poseStack = event.getGuiGraphics().pose();
|
||||
|
@ -51,16 +54,6 @@ public class AmmoBarOverlay {
|
|||
16);
|
||||
|
||||
// 渲染开火模式切换按键
|
||||
// event.getGuiGraphics().blit(BUTTON,
|
||||
// w - 115,
|
||||
// h - 20,
|
||||
// 0,
|
||||
// 0,
|
||||
// 10,
|
||||
// 10,
|
||||
// 10,
|
||||
// 10);
|
||||
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
"[" + ModKeyMappings.FIRE_MODE.getKey().getDisplayName().getString() + "]",
|
||||
|
@ -93,7 +86,6 @@ public class AmmoBarOverlay {
|
|||
8,
|
||||
8);
|
||||
|
||||
|
||||
// 渲染当前弹药量
|
||||
poseStack.pushPose();
|
||||
poseStack.scale(1.5f, 1.5f, 1f);
|
||||
|
|
|
@ -93,24 +93,22 @@ public class ClientEventHandler {
|
|||
if (drone != null) {
|
||||
|
||||
if (data.getDouble("droneRotZ") > drone.getEntityData().get(ROT_Z)) {
|
||||
data.putDouble("droneRotZ", Mth.clamp(data.getDouble("droneRotZ") - 0.3 * Math.pow(drone.getEntityData().get(ROT_Z) - data.getDouble("droneRotZ"), 2),drone.getEntityData().get(ROT_Z),Double.POSITIVE_INFINITY));
|
||||
data.putDouble("droneRotZ", Mth.clamp(data.getDouble("droneRotZ") - 0.3 * Math.pow(drone.getEntityData().get(ROT_Z) - data.getDouble("droneRotZ"), 2), drone.getEntityData().get(ROT_Z), Double.POSITIVE_INFINITY));
|
||||
} else {
|
||||
data.putDouble("droneRotZ", Mth.clamp(data.getDouble("droneRotZ") + 0.3 * Math.pow(drone.getEntityData().get(ROT_Z) - data.getDouble("droneRotZ"), 2),Double.NEGATIVE_INFINITY,drone.getEntityData().get(ROT_Z)));
|
||||
data.putDouble("droneRotZ", Mth.clamp(data.getDouble("droneRotZ") + 0.3 * Math.pow(drone.getEntityData().get(ROT_Z) - data.getDouble("droneRotZ"), 2), Double.NEGATIVE_INFINITY, drone.getEntityData().get(ROT_Z)));
|
||||
}
|
||||
|
||||
if (data.getDouble("droneRotX") > drone.getEntityData().get(ROT_X)) {
|
||||
data.putDouble("droneRotX", Mth.clamp(data.getDouble("droneRotX") - 0.2 * Math.pow(drone.getEntityData().get(ROT_X) - data.getDouble("droneRotX"), 2),drone.getEntityData().get(ROT_X),Double.POSITIVE_INFINITY));
|
||||
data.putDouble("droneRotX", Mth.clamp(data.getDouble("droneRotX") - 0.2 * Math.pow(drone.getEntityData().get(ROT_X) - data.getDouble("droneRotX"), 2), drone.getEntityData().get(ROT_X), Double.POSITIVE_INFINITY));
|
||||
} else {
|
||||
data.putDouble("droneRotX", Mth.clamp(data.getDouble("droneRotX") + 0.2 * Math.pow(drone.getEntityData().get(ROT_X) - data.getDouble("droneRotX"), 2),Double.NEGATIVE_INFINITY,drone.getEntityData().get(ROT_X)));
|
||||
data.putDouble("droneRotX", Mth.clamp(data.getDouble("droneRotX") + 0.2 * Math.pow(drone.getEntityData().get(ROT_X) - data.getDouble("droneRotX"), 2), Double.NEGATIVE_INFINITY, drone.getEntityData().get(ROT_X)));
|
||||
}
|
||||
|
||||
event.setPitch((float) (pitch + data.getDouble("droneCameraRotX") - 0.15f * Mth.RAD_TO_DEG * data.getDouble("droneRotZ")));
|
||||
event.setRoll((float) (roll + data.getDouble("droneCameraRotY") - 0.5f * Mth.RAD_TO_DEG * data.getDouble("droneRotX")));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void handleCannonCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) {
|
||||
var data = entity.getPersistentData();
|
||||
double yaw = event.getYaw();
|
||||
|
@ -120,7 +118,6 @@ public class ClientEventHandler {
|
|||
event.setPitch((float) (pitch + 1 * data.getDouble("Cannon_xRot") + data.getDouble("cannon_camera_rot_x")));
|
||||
event.setYaw((float) (yaw + 1 * data.getDouble("Cannon_yRot") + data.getDouble("cannon_camera_rot_y")));
|
||||
event.setRoll((float) (roll + data.getDouble("cannon_camera_rot_z")));
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -159,7 +156,7 @@ public class ClientEventHandler {
|
|||
double spread = stack.getOrCreateTag().getDouble("spread");
|
||||
double zoomSpread = stack.getOrCreateTag().getDouble("zoomSpread");
|
||||
|
||||
double gunSpread = (float) (zoom? zoomSpread : spread);
|
||||
double gunSpread = (float) (zoom ? zoomSpread : spread);
|
||||
|
||||
if (data.getDouble("crosshair") > gunSpread) {
|
||||
data.putDouble("crosshair", data.getDouble("crosshair") - 0.05 * Math.pow(gunSpread - data.getDouble("crosshair"), 2) * times);
|
||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraftforge.network.PacketDistributor;
|
|||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class PlayerEventHandler {
|
||||
|
||||
|
@ -41,7 +40,6 @@ public class PlayerEventHandler {
|
|||
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using")) {
|
||||
stack.getOrCreateTag().putBoolean("Using", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -142,14 +140,14 @@ public class PlayerEventHandler {
|
|||
|
||||
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).tacticalSprint) {
|
||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.tacticalSprintTime = Mth.clamp(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).tacticalSprintTime - sprint_cost,0,600);
|
||||
capability.tacticalSprintTime = Mth.clamp(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).tacticalSprintTime - sprint_cost, 0, 600);
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
player.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SPEED, 2, 0, false, false));
|
||||
|
||||
} else {
|
||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||
capability.tacticalSprintTime = Mth.clamp(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).tacticalSprintTime + 5,0,600);
|
||||
capability.tacticalSprintTime = Mth.clamp(player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).tacticalSprintTime + 5, 0, 600);
|
||||
capability.syncPlayerVariables(player);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@ public class FireMessage {
|
|||
|
||||
var tag = handItem.getOrCreateTag();
|
||||
|
||||
|
||||
if (handItem.getItem() == ModItems.TASER.get()) {
|
||||
handleTaserFire(player);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue