铲Cap
This commit is contained in:
parent
9540027c19
commit
1dbbaaa92e
5 changed files with 17 additions and 30 deletions
|
@ -2,12 +2,13 @@ package com.atsuishio.superbwarfare.block;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.TargetEntity;
|
import com.atsuishio.superbwarfare.entity.TargetEntity;
|
||||||
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
import com.atsuishio.superbwarfare.entity.vehicle.base.CannonEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
|
@ -124,10 +125,8 @@ public class JumpPadBlock extends Block {
|
||||||
level.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), ModSounds.JUMP.get(), SoundSource.BLOCKS, 1, 1, false);
|
level.playLocalSound(pos.getX(), pos.getY(), pos.getZ(), ModSounds.JUMP.get(), SoundSource.BLOCKS, 1, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var capability = entity.getData(ModAttachments.PLAYER_VARIABLE).watch();
|
if (entity instanceof Player player && player.level().isClientSide) {
|
||||||
capability.playerDoubleJump = true;
|
ClientEventHandler.canDoubleJump = true;
|
||||||
|
}
|
||||||
entity.setData(ModAttachments.PLAYER_VARIABLE, capability);
|
|
||||||
capability.sync(entity);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,11 +406,11 @@ public class ClickHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getData(ModAttachments.PLAYER_VARIABLE).playerDoubleJump) {
|
if (canDoubleJump) {
|
||||||
player.setDeltaMovement(new Vec3(player.getLookAngle().x, 0.8, player.getLookAngle().z));
|
player.setDeltaMovement(new Vec3(player.getLookAngle().x, 0.8, player.getLookAngle().z));
|
||||||
level.playLocalSound(x, y, z, ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1, false);
|
level.playLocalSound(x, y, z, ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1, false);
|
||||||
|
PacketDistributor.sendToServer(new DoubleJumpMessage(0));
|
||||||
PacketDistributor.sendToServer(new DoubleJumpMessage(false));
|
canDoubleJump = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,8 @@ public class ClientEventHandler {
|
||||||
public static float cameraRoll;
|
public static float cameraRoll;
|
||||||
public static float cantSprint = 0;
|
public static float cantSprint = 0;
|
||||||
|
|
||||||
|
public static boolean canDoubleJump = false;
|
||||||
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void handleWeaponTurn(RenderHandEvent event) {
|
public static void handleWeaponTurn(RenderHandEvent event) {
|
||||||
|
@ -280,6 +282,10 @@ public class ClientEventHandler {
|
||||||
keysCache = keys;
|
keysCache = keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.onGround() && canDoubleJump) {
|
||||||
|
canDoubleJump = false;
|
||||||
|
}
|
||||||
|
|
||||||
handleVariableDecrease();
|
handleVariableDecrease();
|
||||||
aimAtVillager(player);
|
aimAtVillager(player);
|
||||||
staminaSystem();
|
staminaSystem();
|
||||||
|
|
|
@ -77,17 +77,6 @@ public class PlayerEventHandler {
|
||||||
if (stack.is(ModTags.Items.GUN)) {
|
if (stack.is(ModTags.Items.GUN)) {
|
||||||
handleSpecialWeaponAmmo(player);
|
handleSpecialWeaponAmmo(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGround(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleGround(Player player) {
|
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE);
|
|
||||||
|
|
||||||
if (player.onGround()) {
|
|
||||||
cap.playerDoubleJump = false;
|
|
||||||
player.setData(ModAttachments.PLAYER_VARIABLE, cap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleSpecialWeaponAmmo(Player player) {
|
private static void handleSpecialWeaponAmmo(Player player) {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.network.message.send;
|
package com.atsuishio.superbwarfare.network.message.send;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.Mod;
|
import com.atsuishio.superbwarfare.Mod;
|
||||||
import com.atsuishio.superbwarfare.init.ModAttachments;
|
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
|
@ -14,12 +13,12 @@ import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public record DoubleJumpMessage(boolean canDoubleJump) implements CustomPacketPayload {
|
public record DoubleJumpMessage(int empty) implements CustomPacketPayload {
|
||||||
public static final Type<DoubleJumpMessage> TYPE = new Type<>(Mod.loc("double_jump"));
|
public static final Type<DoubleJumpMessage> TYPE = new Type<>(Mod.loc("double_jump"));
|
||||||
|
|
||||||
public static final StreamCodec<ByteBuf, DoubleJumpMessage> STREAM_CODEC = StreamCodec.composite(
|
public static final StreamCodec<ByteBuf, DoubleJumpMessage> STREAM_CODEC = StreamCodec.composite(
|
||||||
ByteBufCodecs.BOOL,
|
ByteBufCodecs.INT,
|
||||||
DoubleJumpMessage::canDoubleJump,
|
DoubleJumpMessage::empty,
|
||||||
DoubleJumpMessage::new
|
DoubleJumpMessage::new
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -32,12 +31,6 @@ public record DoubleJumpMessage(boolean canDoubleJump) implements CustomPacketPa
|
||||||
double z = player.getZ();
|
double z = player.getZ();
|
||||||
|
|
||||||
level.playSound(null, BlockPos.containing(x, y, z), ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1);
|
level.playSound(null, BlockPos.containing(x, y, z), ModSounds.DOUBLE_JUMP.get(), SoundSource.BLOCKS, 1, 1);
|
||||||
|
|
||||||
var cap = player.getData(ModAttachments.PLAYER_VARIABLE).watch();
|
|
||||||
|
|
||||||
cap.playerDoubleJump = message.canDoubleJump;
|
|
||||||
player.setData(ModAttachments.PLAYER_VARIABLE, cap);
|
|
||||||
cap.sync(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue