优化Vector开火流程

This commit is contained in:
Light_Quanta 2024-05-11 03:41:35 +08:00
parent 123736546a
commit b094f4db87
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
3 changed files with 21 additions and 38 deletions

View file

@ -20,7 +20,7 @@ public class PressFireProcedure {
SentinelFireProcedure.execute(player);
MarlinfireProcedure.execute(player);
M870fireProcedure.execute(player);
VecfireProcedure.execute(player);
VectorFireProcedure.execute(player);
player.getPersistentData().putDouble("firing", 1);
if (player.getMainHandItem().is(ItemTags.create(new ResourceLocation("target:gun")))
&& !(player.getMainHandItem().getItem() == TargetModItems.BOCEK.get())

View file

@ -1,37 +0,0 @@
package net.mcreator.target.procedures;
import net.minecraft.world.level.GameType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.client.Minecraft;
import net.mcreator.target.init.TargetModItems;
public class VecfireProcedure {
public static void execute(Entity entity) {
if (entity == null)
return;
ItemStack usehand = ItemStack.EMPTY;
if (!(new Object() {
public boolean checkGamemode(Entity _ent) {
if (_ent instanceof ServerPlayer _serverPlayer) {
return _serverPlayer.gameMode.getGameModeForPlayer() == GameType.SPECTATOR;
} else if (_ent.level().isClientSide() && _ent instanceof Player _player) {
return Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()) != null && Minecraft.getInstance().getConnection().getPlayerInfo(_player.getGameProfile().getId()).getGameMode() == GameType.SPECTATOR;
}
return false;
}
}.checkGamemode(entity))) {
usehand = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
if (usehand.getItem() == TargetModItems.VECTOR.get()) {
if (usehand.getOrCreateTag().getDouble("firemode") == 1 && usehand.getOrCreateTag().getDouble("burst") == 0) {
usehand.getOrCreateTag().putDouble("burst", 3);
}
}
}
}
}

View file

@ -0,0 +1,20 @@
package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
public class VectorFireProcedure {
public static void execute(Player entity) {
if (entity.isSpectator()) return;
ItemStack mainHandItem = entity.getMainHandItem();
if (mainHandItem.getItem() != TargetModItems.VECTOR.get()) return;
CompoundTag tag = mainHandItem.getOrCreateTag();
if (tag.getDouble("firemode") == 1 && tag.getDouble("burst") == 0) {
tag.putDouble("burst", 3);
}
}
}