修复了旁观者模式能开火的问题
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;
|
Player player = Minecraft.getInstance().player;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
|
if (player.isSpectator()) return;
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
int button = event.getButton();
|
int button = event.getButton();
|
||||||
|
@ -160,8 +163,6 @@ public class ClickHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
setKeyState(event.getKey(), clicked ? 1 : 0);
|
setKeyState(event.getKey(), clicked ? 1 : 0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,7 +19,6 @@ import net.minecraftforge.fml.common.Mod;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class AmmoBarOverlay {
|
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 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 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");
|
private static final ResourceLocation BURST = new ResourceLocation(ModUtils.MODID, "textures/gun_icon/fire_mode/burst.png");
|
||||||
|
@ -35,6 +34,10 @@ public class AmmoBarOverlay {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.isSpectator()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (stack.getItem() instanceof GunItem gunItem) {
|
if (stack.getItem() instanceof GunItem gunItem) {
|
||||||
PoseStack poseStack = event.getGuiGraphics().pose();
|
PoseStack poseStack = event.getGuiGraphics().pose();
|
||||||
|
@ -51,16 +54,6 @@ public class AmmoBarOverlay {
|
||||||
16);
|
16);
|
||||||
|
|
||||||
// 渲染开火模式切换按键
|
// 渲染开火模式切换按键
|
||||||
// event.getGuiGraphics().blit(BUTTON,
|
|
||||||
// w - 115,
|
|
||||||
// h - 20,
|
|
||||||
// 0,
|
|
||||||
// 0,
|
|
||||||
// 10,
|
|
||||||
// 10,
|
|
||||||
// 10,
|
|
||||||
// 10);
|
|
||||||
|
|
||||||
event.getGuiGraphics().drawString(
|
event.getGuiGraphics().drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
"[" + ModKeyMappings.FIRE_MODE.getKey().getDisplayName().getString() + "]",
|
"[" + ModKeyMappings.FIRE_MODE.getKey().getDisplayName().getString() + "]",
|
||||||
|
@ -93,7 +86,6 @@ public class AmmoBarOverlay {
|
||||||
8,
|
8,
|
||||||
8);
|
8);
|
||||||
|
|
||||||
|
|
||||||
// 渲染当前弹药量
|
// 渲染当前弹药量
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
poseStack.scale(1.5f, 1.5f, 1f);
|
poseStack.scale(1.5f, 1.5f, 1f);
|
||||||
|
|
|
@ -107,10 +107,8 @@ public class ClientEventHandler {
|
||||||
event.setPitch((float) (pitch + data.getDouble("droneCameraRotX") - 0.15f * Mth.RAD_TO_DEG * data.getDouble("droneRotZ")));
|
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")));
|
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) {
|
private static void handleCannonCamera(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) {
|
||||||
var data = entity.getPersistentData();
|
var data = entity.getPersistentData();
|
||||||
double yaw = event.getYaw();
|
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.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.setYaw((float) (yaw + 1 * data.getDouble("Cannon_yRot") + data.getDouble("cannon_camera_rot_y")));
|
||||||
event.setRoll((float) (roll + data.getDouble("cannon_camera_rot_z")));
|
event.setRoll((float) (roll + data.getDouble("cannon_camera_rot_z")));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -30,7 +30,6 @@ import net.minecraftforge.network.PacketDistributor;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
|
||||||
@Mod.EventBusSubscriber
|
@Mod.EventBusSubscriber
|
||||||
public class PlayerEventHandler {
|
public class PlayerEventHandler {
|
||||||
|
|
||||||
|
@ -41,7 +40,6 @@ public class PlayerEventHandler {
|
||||||
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using")) {
|
if (stack.is(ModItems.MONITOR.get()) && stack.getOrCreateTag().getBoolean("Using")) {
|
||||||
stack.getOrCreateTag().putBoolean("Using", false);
|
stack.getOrCreateTag().putBoolean("Using", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|
|
@ -84,7 +84,6 @@ public class FireMessage {
|
||||||
|
|
||||||
var tag = handItem.getOrCreateTag();
|
var tag = handItem.getOrCreateTag();
|
||||||
|
|
||||||
|
|
||||||
if (handItem.getItem() == ModItems.TASER.get()) {
|
if (handItem.getItem() == ModItems.TASER.get()) {
|
||||||
handleTaserFire(player);
|
handleTaserFire(player);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue