superb-warfare/src/main/java/net/mcreator/target/procedures/MinigunfireProcedure.java
2024-05-04 14:26:24 +08:00

34 lines
1.3 KiB
Java

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 MinigunfireProcedure {
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.MINIGUN.get()) {
entity.getPersistentData().putDouble("minifiring", 1);
}
}
}
}