重构换弹流程

This commit is contained in:
Light_Quanta 2024-05-12 15:31:42 +08:00
parent b730ae4b0b
commit bc123df16a
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
26 changed files with 108 additions and 289 deletions

View file

@ -5,7 +5,7 @@ import com.google.common.collect.Multimap;
import net.mcreator.target.client.renderer.item.BocekItemRenderer;
import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.procedures.BocekreloadProcedure;
import net.mcreator.target.procedures.BocekReloadProcedure;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.RarityTool;
import net.mcreator.target.tools.TooltipTool;
@ -147,7 +147,7 @@ public class BocekItem extends GunItem implements GeoItem, AnimatedItem {
if (entity instanceof Player player) {
itemstack.getOrCreateTag().putDouble("maxammo", getAmmoCount(player));
}
BocekreloadProcedure.execute(entity, itemstack);
BocekReloadProcedure.execute(entity, itemstack);
}
public static double getAmmoCount(Player player) {

View file

@ -8,9 +8,8 @@ import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.init.TargetModTags;
import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.procedures.HandgunReload1Procedure;
import net.mcreator.target.procedures.HandgunReload2Procedure;
import net.mcreator.target.procedures.WeaponDrawLightProcedure;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft;
@ -180,7 +179,7 @@ public class VectorItem extends GunItem implements GeoItem, AnimatedItem {
tag.putDouble("reloadtime", 0);
}
if (tag.getDouble("reloadtime") == 1 && mainHandItem.getOrCreateTag().getDouble("id") == id) {
HandgunReload1Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.HANDGUN);
}
} else if (tag.getDouble("reloading") == 1 && tag.getDouble("ammo") > 0) {
if (tag.getDouble("reloadtime") == 47) {
@ -197,7 +196,7 @@ public class VectorItem extends GunItem implements GeoItem, AnimatedItem {
tag.putDouble("reloadtime", 0);
}
if (tag.getDouble("reloadtime") == 1 && mainHandItem.getOrCreateTag().getDouble("id") == id) {
HandgunReload2Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.HANDGUN, true);
}
}

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -39,7 +40,7 @@ public class AK47WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.RIFLE);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
@ -62,7 +63,7 @@ public class AK47WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity, true);
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -36,9 +37,7 @@ public class Aa12WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
if (entity instanceof LivingEntity) {
ShotgunReloadProcedure.execute((LivingEntity) entity);
}
GunReload.reload(entity, GunReload.GunType.SHOTGUN);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
@ -61,9 +60,7 @@ public class Aa12WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
if (entity instanceof LivingEntity) {
ShotgunReloadProcedure.execute((LivingEntity) entity, true);
}
GunReload.reload(entity, GunReload.GunType.SHOTGUN, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -0,0 +1,18 @@
package net.mcreator.target.procedures;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
public class BocekReloadProcedure {
// TODO 合并至GunReload
public static void execute(Entity entity, ItemStack itemstack) {
if (entity == null) return;
CompoundTag tag = itemstack.getOrCreateTag();
if (tag.getDouble("arrowempty") > 0) {
tag.putDouble("arrowempty", tag.getDouble("arrowempty") - 1);
}
WeaponDrawProcedure.execute(entity, itemstack);
}
}

View file

@ -1,17 +0,0 @@
package net.mcreator.target.procedures;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
public class BocekreloadProcedure {
public static void execute(Entity entity, ItemStack itemstack) {
if (entity == null)
return;
double ammo1 = 0;
double id = 0;
if (itemstack.getOrCreateTag().getDouble("arrowempty") > 0) {
itemstack.getOrCreateTag().putDouble("arrowempty", (itemstack.getOrCreateTag().getDouble("arrowempty") - 1));
}
WeaponDrawProcedure.execute(entity, itemstack);
}
}

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -39,7 +40,7 @@ public class DevotionWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.RIFLE);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 51) {
@ -63,7 +64,7 @@ public class DevotionWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity, true);
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -1,40 +0,0 @@
package net.mcreator.target.procedures;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
public class HandgunReload1Procedure {
public static void execute(Entity entity) {
if (entity == null)
return;
double ammo1;
ItemStack stack;
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo >= ammo1) {
{
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo - ammo1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity);
});
}
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + ammo1));
stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0);
} else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo));
{
double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity);
});
}
stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0);
}
}
}

View file

@ -1,40 +0,0 @@
package net.mcreator.target.procedures;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
public class HandgunReload2Procedure {
public static void execute(Entity entity) {
if (entity == null)
return;
double ammo2;
ItemStack stack;
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo >= ammo2) {
{
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo - ammo2;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity);
});
}
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + ammo2));
stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0);
} else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).handgunAmmo));
{
double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.handgunAmmo = _setval;
capability.syncPlayerVariables(entity);
});
}
stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0);
}
}
}

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -39,7 +40,7 @@ public class Hk416WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.RIFLE);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
@ -62,7 +63,7 @@ public class Hk416WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity, true);
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -41,7 +42,7 @@ public class HrrelodingProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
SniperReload1Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.SNIPER);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -39,7 +40,7 @@ public class KraberWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
SniperReload1Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.SNIPER);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 65) {
@ -62,7 +63,7 @@ public class KraberWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
SniperReload2Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.SNIPER, true);
}
}
WeapondrawhaveyProcedure.execute(entity, itemstack);

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -39,7 +40,7 @@ public class M4WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.RIFLE);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
@ -62,7 +63,7 @@ public class M4WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity, true);
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -42,7 +43,7 @@ public class M60WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.RIFLE);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 111) {
@ -65,7 +66,7 @@ public class M60WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.RIFLE);
}
}
WeapondrawhaveyProcedure.execute(entity, itemstack);

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -43,7 +44,7 @@ public class M98bWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
SniperReload1Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.SNIPER);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 57) {
@ -66,7 +67,7 @@ public class M98bWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
SniperReload2Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.SNIPER, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -42,7 +43,7 @@ public class Mk14WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("gj", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.RIFLE);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 45) {
@ -65,7 +66,7 @@ public class Mk14WuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity, true);
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -41,7 +42,7 @@ public class ReloadingProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
HandgunReload1Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.HANDGUN);
}
}
WeaponDrawLightProcedure.execute(entity, itemstack);

View file

@ -1,36 +0,0 @@
package net.mcreator.target.procedures;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
public class RifleReloadProcedure {
public static void execute(Entity entity) {
execute(entity, false);
}
public static void execute(Entity entity, boolean extraOne) {
if (entity == null) return;
ItemStack stack = (entity instanceof LivingEntity living ? living.getMainHandItem() : ItemStack.EMPTY);
CompoundTag tag = stack.getOrCreateTag();
double mag = tag.getDouble("mag");
double ammo = tag.getDouble("ammo");
double rifleAmmo = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.rifleAmmo).orElse(0d);
double ammo1 = mag - ammo + (extraOne ? 1 : 0);
tag.putDouble("ammo", ammo + Math.min(ammo1, rifleAmmo));
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleAmmo = Math.max(0, rifleAmmo - ammo1);
capability.syncPlayerVariables(entity);
});
tag.putDouble("reloading", 0);
tag.putDouble("emptyreload", 0);
}
}

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -35,7 +36,7 @@ public class RpkWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.RIFLE);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
@ -56,7 +57,7 @@ public class RpkWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity, true);
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -41,7 +42,7 @@ public class SentinelWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
SniperReload1Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.SNIPER);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 53) {
@ -65,7 +66,7 @@ public class SentinelWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
SniperReload2Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.SNIPER, true);
}
}
if (itemstack.getOrCreateTag().getDouble("firing") > 0) {

View file

@ -1,30 +0,0 @@
package net.mcreator.target.procedures;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.LivingEntity;
public class ShotgunReloadProcedure {
public static void execute(LivingEntity entity) {
execute(entity, false);
}
public static void execute(LivingEntity entity, boolean extraOne) {
CompoundTag tag = entity.getMainHandItem().getOrCreateTag();
double mag = tag.getDouble("mag");
double ammo = tag.getDouble("ammo");
double empty = mag - ammo + (extraOne ? 1 : 0);
double shotgunAmmo = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.shotgunAmmo).orElse(0d);
tag.putDouble("ammo", ammo + Math.min(empty, shotgunAmmo));
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunAmmo = Math.max(0, shotgunAmmo - empty);
capability.syncPlayerVariables(entity);
});
tag.putDouble("reloading", 0);
tag.putDouble("emptyreload", 0);
}
}

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -43,7 +44,7 @@ public class SksWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("gj", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.RIFLE);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
@ -67,7 +68,7 @@ public class SksWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
RifleReloadProcedure.execute(entity, true);
GunReload.reload(entity, GunReload.GunType.RIFLE, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -1,44 +0,0 @@
package net.mcreator.target.procedures;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
public class SniperReload1Procedure {
public static void execute(Entity entity) {
if (entity == null)
return;
double ammo1 = 0;
double id = 0;
double ammo2 = 0;
ItemStack stack = ItemStack.EMPTY;
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
id = stack.getOrCreateTag().getDouble("id");
ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo");
ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo >= ammo1) {
{
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo - ammo1;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity);
});
}
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + ammo1));
stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0);
} else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo));
{
double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity);
});
}
stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0);
}
}
}

View file

@ -1,44 +0,0 @@
package net.mcreator.target.procedures;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
public class SniperReload2Procedure {
public static void execute(Entity entity) {
if (entity == null)
return;
double ammo1 = 0;
double id = 0;
double ammo2 = 0;
ItemStack stack = ItemStack.EMPTY;
stack = (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY);
id = stack.getOrCreateTag().getDouble("id");
ammo1 = stack.getOrCreateTag().getDouble("mag") - stack.getOrCreateTag().getDouble("ammo");
ammo2 = (stack.getOrCreateTag().getDouble("mag") + 1) - stack.getOrCreateTag().getDouble("ammo");
if ((entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo >= ammo2) {
{
double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo - ammo2;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity);
});
}
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + ammo2));
stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0);
} else {
stack.getOrCreateTag().putDouble("ammo", (stack.getOrCreateTag().getDouble("ammo") + (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).sniperAmmo));
{
double _setval = 0;
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperAmmo = _setval;
capability.syncPlayerVariables(entity);
});
}
stack.getOrCreateTag().putDouble("reloading", 0);
stack.getOrCreateTag().putDouble("emptyreload", 0);
}
}
}

View file

@ -1,5 +1,6 @@
package net.mcreator.target.procedures;
import net.mcreator.target.tools.GunReload;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
@ -43,7 +44,7 @@ public class SvdWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("gj", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
SniperReload1Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.SNIPER);
}
} else if (itemstack.getOrCreateTag().getDouble("reloading") == 1 && itemstack.getOrCreateTag().getDouble("ammo") > 0) {
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 41) {
@ -67,7 +68,7 @@ public class SvdWuPinZaiBeiBaoZhongShiMeiKeFaShengProcedure {
itemstack.getOrCreateTag().putDouble("reloadtime", 0);
}
if (itemstack.getOrCreateTag().getDouble("reloadtime") == 1 && (entity instanceof LivingEntity _livEnt ? _livEnt.getMainHandItem() : ItemStack.EMPTY).getOrCreateTag().getDouble("id") == id) {
SniperReload2Procedure.execute(entity);
GunReload.reload(entity, GunReload.GunType.SNIPER, true);
}
}
WeaponDrawProcedure.execute(entity, itemstack);

View file

@ -0,0 +1,42 @@
package net.mcreator.target.tools;
import net.mcreator.target.network.TargetModVariables;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
public class GunReload {
public static void reload(Entity entity, GunType gunType) {
reload(entity, gunType, false);
}
public static void reload(Entity entity, GunType gunType, boolean extraOne) {
if (!(entity instanceof LivingEntity living)) return;
CompoundTag tag = living.getMainHandItem().getOrCreateTag();
double mag = tag.getDouble("mag");
double ammo = tag.getDouble("ammo");
double ammoToAdd = mag - ammo + (extraOne ? 1 : 0);
double playerAmmo = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> switch (gunType) {
case RIFLE -> c.rifleAmmo;
case HANDGUN -> c.handgunAmmo;
case SHOTGUN -> c.shotgunAmmo;
case SNIPER -> c.sniperAmmo;
}).orElse(0d);
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.sniperAmmo = Math.max(0, playerAmmo - ammoToAdd);
capability.syncPlayerVariables(entity);
});
tag.putDouble("ammo", ammo + Math.min(ammoToAdd, playerAmmo));
tag.putDouble("reloading", 0);
tag.putDouble("emptyreload", 0);
}
public enum GunType {
HANDGUN, RIFLE, SHOTGUN, SNIPER
}
}