优化“滋崩”逻辑
This commit is contained in:
parent
dd1f63cf05
commit
03805792c5
4 changed files with 26 additions and 14 deletions
|
@ -368,7 +368,7 @@ public class ClientEventHandler {
|
||||||
&& (!player.isAlliedTo(lookingEntity) || lookingEntity.getTeam() == null || lookingEntity.getTeam().getName().equals("TDM"));
|
&& (!player.isAlliedTo(lookingEntity) || lookingEntity.getTeam() == null || lookingEntity.getTeam().getName().equals("TDM"));
|
||||||
|
|
||||||
if (canAttack) {
|
if (canAttack) {
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new LaserShootMessage(stack.getOrCreateTag().getInt("FireTick") >= 10 ? 45 : 1, lookingEntity.getUUID()));
|
ModUtils.PACKET_HANDLER.sendToServer(new LaserShootMessage(1, lookingEntity.getUUID()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@ import com.atsuishio.superbwarfare.capability.LaserHandler;
|
||||||
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
import com.atsuishio.superbwarfare.capability.ModCapabilities;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.LaserEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.LaserEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModSounds;
|
import com.atsuishio.superbwarfare.init.ModSounds;
|
||||||
|
import com.atsuishio.superbwarfare.network.message.LaserShootMessage;
|
||||||
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
||||||
|
import com.atsuishio.superbwarfare.tools.TraceTool;
|
||||||
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
|
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
@ -67,23 +69,13 @@ public class BeamTest extends Item {
|
||||||
return InteractionResultHolder.consume(player.getItemInHand(hand));
|
return InteractionResultHolder.consume(player.getItemInHand(hand));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
|
||||||
if (stack.getOrCreateTag().getBoolean("LaserFiring")) {
|
|
||||||
stack.getOrCreateTag().putInt("FireTick", stack.getOrCreateTag().getInt("FireTick") + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releaseUsing(ItemStack stack, Level level, LivingEntity livingEntity, int timeCharged) {
|
public void releaseUsing(ItemStack stack, Level level, LivingEntity livingEntity, int timeCharged) {
|
||||||
if (livingEntity instanceof Player player) {
|
if (livingEntity instanceof Player player) {
|
||||||
player.getCapability(ModCapabilities.LASER_CAPABILITY).ifPresent(LaserCapability.ILaserCapability::stop);
|
player.getCapability(ModCapabilities.LASER_CAPABILITY).ifPresent(LaserCapability.ILaserCapability::stop);
|
||||||
stack.getOrCreateTag().putBoolean("LaserFiring", false);
|
stack.getOrCreateTag().putBoolean("LaserFiring", false);
|
||||||
stack.getOrCreateTag().putInt("FireTick", 0);
|
|
||||||
player.getCooldowns().addCooldown(stack.getItem(), 20);
|
|
||||||
}
|
}
|
||||||
if (stack.getOrCreateTag().getInt("FireTick") < 10 && livingEntity instanceof ServerPlayer serverPlayer && stack.getItem() instanceof BeamTest beamTest) {
|
if (livingEntity instanceof ServerPlayer serverPlayer && stack.getItem() instanceof BeamTest beamTest) {
|
||||||
stopGunChargeSound(serverPlayer,beamTest);
|
stopGunChargeSound(serverPlayer,beamTest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,18 +99,36 @@ public class BeamTest extends Item {
|
||||||
if (pLivingEntity instanceof Player player) {
|
if (pLivingEntity instanceof Player player) {
|
||||||
player.getCapability(ModCapabilities.LASER_CAPABILITY).ifPresent(LaserCapability.ILaserCapability::stop);
|
player.getCapability(ModCapabilities.LASER_CAPABILITY).ifPresent(LaserCapability.ILaserCapability::stop);
|
||||||
pStack.getOrCreateTag().putBoolean("LaserFiring", false);
|
pStack.getOrCreateTag().putBoolean("LaserFiring", false);
|
||||||
pStack.getOrCreateTag().putInt("FireTick", 0);
|
|
||||||
if (player instanceof ServerPlayer serverPlayer) {
|
if (player instanceof ServerPlayer serverPlayer) {
|
||||||
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(30,10,20, serverPlayer.getX(), serverPlayer.getEyeY(), serverPlayer.getZ()));
|
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(30,10,20, serverPlayer.getX(), serverPlayer.getEyeY(), serverPlayer.getZ()));
|
||||||
}
|
}
|
||||||
player.getCooldowns().addCooldown(pStack.getItem(), 20);
|
player.getCooldowns().addCooldown(pStack.getItem(), 20);
|
||||||
|
|
||||||
|
if (player.level().isClientSide()) {
|
||||||
|
beamShoot(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.finishUsingItem(pStack, pLevel, pLivingEntity);
|
return super.finishUsingItem(pStack, pLevel, pLivingEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void beamShoot(Player player) {
|
||||||
|
Entity lookingEntity = TraceTool.laserfindLookingEntity(player, 512);
|
||||||
|
|
||||||
|
if (lookingEntity == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean canAttack = lookingEntity != player && !(lookingEntity instanceof Player player_ && (player_.isCreative() || player_.isSpectator()))
|
||||||
|
&& (!player.isAlliedTo(lookingEntity) || lookingEntity.getTeam() == null || lookingEntity.getTeam().getName().equals("TDM"));
|
||||||
|
|
||||||
|
if (canAttack) {
|
||||||
|
ModUtils.PACKET_HANDLER.sendToServer(new LaserShootMessage(45, lookingEntity.getUUID()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUseDuration(ItemStack stack) {
|
public int getUseDuration(ItemStack stack) {
|
||||||
return 11;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -189,6 +189,7 @@
|
||||||
"des.superbwarfare.transcript.score": "Score: ",
|
"des.superbwarfare.transcript.score": "Score: ",
|
||||||
"des.superbwarfare.transcript.distance": "Distance: ",
|
"des.superbwarfare.transcript.distance": "Distance: ",
|
||||||
"des.superbwarfare.transcript.total": "Total: ",
|
"des.superbwarfare.transcript.total": "Total: ",
|
||||||
|
"item.superbwarfare.beam_test": "[ZzzzBoom!]",
|
||||||
|
|
||||||
"attribute.superbwarfare.bullet_resistance": "Bullet Resistance",
|
"attribute.superbwarfare.bullet_resistance": "Bullet Resistance",
|
||||||
|
|
||||||
|
|
|
@ -189,6 +189,7 @@
|
||||||
"des.superbwarfare.transcript.score": "环数:",
|
"des.superbwarfare.transcript.score": "环数:",
|
||||||
"des.superbwarfare.transcript.distance": "距离:",
|
"des.superbwarfare.transcript.distance": "距离:",
|
||||||
"des.superbwarfare.transcript.total": "总环数:",
|
"des.superbwarfare.transcript.total": "总环数:",
|
||||||
|
"item.superbwarfare.beam_test": "[滋崩]",
|
||||||
|
|
||||||
"attribute.superbwarfare.bullet_resistance": "子弹防护",
|
"attribute.superbwarfare.bullet_resistance": "子弹防护",
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue