修改beamtest为滋崩逻辑
This commit is contained in:
parent
786267a1d5
commit
59926f020f
2 changed files with 30 additions and 3 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(2, lookingEntity.getUUID()));
|
ModUtils.PACKET_HANDLER.sendToServer(new LaserShootMessage(stack.getOrCreateTag().getInt("FireTick") >= 14 ? 45 : 1, lookingEntity.getUUID()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,12 @@ import com.atsuishio.superbwarfare.capability.LaserCapability;
|
||||||
import com.atsuishio.superbwarfare.capability.LaserHandler;
|
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 net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
@ -35,18 +39,39 @@ public class BeamTest extends Item {
|
||||||
capability.init(new LaserHandler(player, laserEntity, 0));
|
capability.init(new LaserHandler(player, laserEntity, 0));
|
||||||
capability.start();
|
capability.start();
|
||||||
|
|
||||||
stack.getOrCreateTag().putBoolean("LaserFiring", true);
|
if (!stack.getOrCreateTag().getBoolean("LaserFiring") && !(player.getCooldowns().isOnCooldown(stack.getItem()))) {
|
||||||
|
stack.getOrCreateTag().putBoolean("LaserFiring", true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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")) {
|
||||||
|
entity.playSound(ModSounds.MINIGUN_ROT.get(), 2, 1);
|
||||||
|
stack.getOrCreateTag().putInt("FireTick", stack.getOrCreateTag().getInt("FireTick") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (stack.getOrCreateTag().getInt("FireTick") >= 14) {
|
||||||
|
if (entity instanceof ServerPlayer serverPlayer) {
|
||||||
|
serverPlayer.level().playSound(null, serverPlayer.getOnPos(), ModSounds.SENTINEL_CHARGE_FIRE_3P.get(), SoundSource.PLAYERS, 1, 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(), 5);
|
||||||
}
|
}
|
||||||
super.releaseUsing(stack, level, livingEntity, timeCharged);
|
super.releaseUsing(stack, level, livingEntity, timeCharged);
|
||||||
}
|
}
|
||||||
|
@ -56,12 +81,14 @@ 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);
|
||||||
|
player.getCooldowns().addCooldown(pStack.getItem(), 5);
|
||||||
}
|
}
|
||||||
return super.finishUsingItem(pStack, pLevel, pLivingEntity);
|
return super.finishUsingItem(pStack, pLevel, pLivingEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUseDuration(ItemStack stack) {
|
public int getUseDuration(ItemStack stack) {
|
||||||
return 6000;
|
return 15;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue