移除子弹相关procedure
This commit is contained in:
parent
311fe83c15
commit
4cdecaec32
5 changed files with 55 additions and 108 deletions
|
@ -1,27 +1,27 @@
|
|||
package net.mcreator.target.client.screens;
|
||||
|
||||
import net.mcreator.target.procedures.AmmobarXianShiYouXiNeiDieJiaCengProcedure;
|
||||
import net.mcreator.target.procedures.AmmocountProcedure;
|
||||
import net.mcreator.target.event.PlayerEventHandler;
|
||||
import net.mcreator.target.init.TargetModTags;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderGuiEvent;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber({Dist.CLIENT})
|
||||
public class AmmobarOverlay {
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT)
|
||||
public class AmmoBarOverlay {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||
public static void eventHandler(RenderGuiEvent.Pre event) {
|
||||
int w = event.getWindow().getGuiScaledWidth();
|
||||
int h = event.getWindow().getGuiScaledHeight();
|
||||
Player entity = Minecraft.getInstance().player;
|
||||
if (AmmobarXianShiYouXiNeiDieJiaCengProcedure.execute(entity)) {
|
||||
if (entity != null && entity.getMainHandItem().is(TargetModTags.Items.GUN)) {
|
||||
event.getGuiGraphics().drawString(
|
||||
Minecraft.getInstance().font,
|
||||
AmmocountProcedure.execute(entity),
|
||||
PlayerEventHandler.handleAmmoCount(entity),
|
||||
w / 2 + 92,
|
||||
h - 11,
|
||||
-16711936,
|
|
@ -1,5 +1,6 @@
|
|||
package net.mcreator.target.event;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.init.TargetModTags;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -46,6 +47,7 @@ public class PlayerEventHandler {
|
|||
handlePlayerSprint(player);
|
||||
handleWeaponLevel(player);
|
||||
handleWeaponSway(player);
|
||||
handleAmmoCount(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,4 +148,50 @@ public class PlayerEventHandler {
|
|||
Thread recoilThread = new Thread(recoilRunnable);
|
||||
recoilThread.start();
|
||||
}
|
||||
|
||||
public static String handleAmmoCount(Player player) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
String firemode = "";
|
||||
if (stack.getOrCreateTag().getDouble("firemode") == 2) {
|
||||
firemode = "Auto";
|
||||
} else if (stack.getOrCreateTag().getDouble("firemode") == 1) {
|
||||
firemode = "Burst";
|
||||
} else if (stack.getOrCreateTag().getDouble("firemode") == 0) {
|
||||
firemode = "Semi";
|
||||
}
|
||||
if (stack.getItem() == TargetModItems.BOCEK.get()) {
|
||||
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("maxammo"))) + " " + firemode;
|
||||
}
|
||||
if (stack.getItem() == TargetModItems.MINIGUN.get()) {
|
||||
return new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo) + " " + firemode;
|
||||
}
|
||||
if (stack.getOrCreateTag().getDouble("rifle") == 1) {
|
||||
stack.getOrCreateTag().putDouble("maxammo",
|
||||
((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo));
|
||||
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo) + " " + firemode;
|
||||
}
|
||||
if (stack.getOrCreateTag().getDouble("handgun") == 1
|
||||
|| stack.getOrCreateTag().getDouble("smg") == 1) {
|
||||
stack.getOrCreateTag().putDouble("maxammo",
|
||||
((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo));
|
||||
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo) + " " + firemode;
|
||||
}
|
||||
if (stack.getOrCreateTag().getDouble("shotgun") == 1) {
|
||||
stack.getOrCreateTag().putDouble("maxammo",
|
||||
((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo));
|
||||
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo) + " " + firemode;
|
||||
}
|
||||
if (stack.getOrCreateTag().getDouble("sniperguns") == 1) {
|
||||
stack.getOrCreateTag().putDouble("maxammo",
|
||||
((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo));
|
||||
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ new java.text.DecimalFormat("##").format((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo) + " " + firemode;
|
||||
}
|
||||
return (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ (new java.text.DecimalFormat("##").format(stack.getOrCreateTag().getDouble("maxammo"))) + " " + firemode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
public class AmmobarXianShiYouXiNeiDieJiaCengProcedure {
|
||||
public static boolean execute(Entity entity) {
|
||||
if (entity == null)
|
||||
return false;
|
||||
return (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).is(ItemTags.create(new ResourceLocation("target:gun")));
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.TargetMod;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
|
||||
public class AmmoboxFangZhiFangKuaiShiProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z) {
|
||||
TargetMod.queueServerWork(1200, () -> {
|
||||
world.destroyBlock(BlockPos.containing(x, y, z), false);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
package net.mcreator.target.procedures;
|
||||
|
||||
import net.mcreator.target.init.TargetModItems;
|
||||
import net.mcreator.target.network.TargetModVariables;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class AmmocountProcedure {
|
||||
@SubscribeEvent
|
||||
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
execute(event, event.player);
|
||||
}
|
||||
}
|
||||
|
||||
public static String execute(Entity entity) {
|
||||
return execute(null, entity);
|
||||
}
|
||||
|
||||
private static String execute(@Nullable Event event, Entity entity) {
|
||||
if (entity == null)
|
||||
return "";
|
||||
String firemode = "";
|
||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("firemode") == 2) {
|
||||
firemode = "Auto";
|
||||
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("firemode") == 1) {
|
||||
firemode = "Burst";
|
||||
} else if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("firemode") == 0) {
|
||||
firemode = "Semi";
|
||||
}
|
||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.BOCEK.get()) {
|
||||
return (new java.text.DecimalFormat("##").format((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("maxammo"))) + " " + firemode;
|
||||
}
|
||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getItem() == TargetModItems.MINIGUN.get()) {
|
||||
return new java.text.DecimalFormat("##").format((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo) + " " + firemode;
|
||||
}
|
||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("rifle") == 1) {
|
||||
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("maxammo",
|
||||
((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo));
|
||||
return (new java.text.DecimalFormat("##").format((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ new java.text.DecimalFormat("##").format((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleammo) + " " + firemode;
|
||||
}
|
||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("handgun") == 1
|
||||
|| (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("smg") == 1) {
|
||||
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("maxammo",
|
||||
((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo));
|
||||
return (new java.text.DecimalFormat("##").format((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ new java.text.DecimalFormat("##").format((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunammo) + " " + firemode;
|
||||
}
|
||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("shotgun") == 1) {
|
||||
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("maxammo",
|
||||
((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo));
|
||||
return (new java.text.DecimalFormat("##").format((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ new java.text.DecimalFormat("##").format((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunammo) + " " + firemode;
|
||||
}
|
||||
if ((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("sniperguns") == 1) {
|
||||
(entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().putDouble("maxammo",
|
||||
((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo));
|
||||
return (new java.text.DecimalFormat("##").format((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ new java.text.DecimalFormat("##").format((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperammo) + " " + firemode;
|
||||
}
|
||||
return (new java.text.DecimalFormat("##").format((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("ammo"))) + "/"
|
||||
+ (new java.text.DecimalFormat("##").format((entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("maxammo"))) + " " + firemode;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue