重制创造弹药盒机制,修复加特林开火bug
This commit is contained in:
parent
f59588877b
commit
460f2de5a9
23 changed files with 439 additions and 254 deletions
|
@ -0,0 +1,60 @@
|
||||||
|
package net.mcreator.superbwarfare.client.particle;
|
||||||
|
|
||||||
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
|
import net.minecraft.client.particle.*;
|
||||||
|
import net.minecraft.core.particles.SimpleParticleType;
|
||||||
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
public class CustomCloudParticle extends TextureSheetParticle {
|
||||||
|
public static FireStarParticleProvider provider(SpriteSet spriteSet) {
|
||||||
|
return new FireStarParticleProvider(spriteSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class FireStarParticleProvider implements ParticleProvider<SimpleParticleType> {
|
||||||
|
private final SpriteSet spriteSet;
|
||||||
|
|
||||||
|
public FireStarParticleProvider(SpriteSet spriteSet) {
|
||||||
|
this.spriteSet = spriteSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Particle createParticle(SimpleParticleType typeIn, ClientLevel worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||||
|
return new CustomCloudParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final SpriteSet spriteSet;
|
||||||
|
|
||||||
|
protected CustomCloudParticle(ClientLevel world, double x, double y, double z, double vx, double vy, double vz, SpriteSet spriteSet) {
|
||||||
|
super(world, x, y, z);
|
||||||
|
this.spriteSet = spriteSet;
|
||||||
|
this.setSize(0.2f, 0.2f);
|
||||||
|
this.quadSize *= 0.5f;
|
||||||
|
this.lifetime = Math.max(1, 40 + (this.random.nextInt(40) - 20));
|
||||||
|
this.gravity = -0.1f;
|
||||||
|
this.hasPhysics = false;
|
||||||
|
this.xd = vx * 1;
|
||||||
|
this.yd = vy * 1;
|
||||||
|
this.zd = vz * 1;
|
||||||
|
this.setSpriteFromAge(spriteSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLightColor(float partialTick) {
|
||||||
|
return 15728880;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ParticleRenderType getRenderType() {
|
||||||
|
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tick() {
|
||||||
|
super.tick();
|
||||||
|
if (!this.removed) {
|
||||||
|
this.setSprite(this.spriteSet.get((this.age / 2) % 4 + 1, 4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,19 @@ public class AmmoBarOverlay {
|
||||||
private static final ResourceLocation TOP = new ResourceLocation(ModUtils.MODID, "textures/gun_icon/fire_mode/top.png");
|
private static final ResourceLocation TOP = new ResourceLocation(ModUtils.MODID, "textures/gun_icon/fire_mode/top.png");
|
||||||
private static final ResourceLocation DIR = new ResourceLocation(ModUtils.MODID, "textures/gun_icon/fire_mode/dir.png");
|
private static final ResourceLocation DIR = new ResourceLocation(ModUtils.MODID, "textures/gun_icon/fire_mode/dir.png");
|
||||||
|
|
||||||
|
private static boolean creativeAmmo() {
|
||||||
|
Player player = Minecraft.getInstance().player;
|
||||||
|
int count = 0;
|
||||||
|
if (player != null) {
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
@SubscribeEvent(priority = EventPriority.NORMAL)
|
@SubscribeEvent(priority = EventPriority.NORMAL)
|
||||||
public static void eventHandler(RenderGuiEvent.Pre event) {
|
public static void eventHandler(RenderGuiEvent.Pre event) {
|
||||||
int w = event.getWindow().getGuiScaledWidth();
|
int w = event.getWindow().getGuiScaledWidth();
|
||||||
|
@ -96,6 +109,16 @@ public class AmmoBarOverlay {
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
poseStack.scale(1.5f, 1.5f, 1f);
|
poseStack.scale(1.5f, 1.5f, 1f);
|
||||||
|
|
||||||
|
if ((stack.getItem() == ModItems.MINIGUN.get() || stack.getItem() == ModItems.BOCEK.get()) && creativeAmmo()) {
|
||||||
|
event.getGuiGraphics().drawString(
|
||||||
|
Minecraft.getInstance().font,
|
||||||
|
"∞",
|
||||||
|
w / 1.5f - 64 / 1.5f,
|
||||||
|
h / 1.5f - 48 / 1.5f,
|
||||||
|
0xFFFFFF,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
} else {
|
||||||
event.getGuiGraphics().drawString(
|
event.getGuiGraphics().drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
getGunAmmoCount(player) + "",
|
getGunAmmoCount(player) + "",
|
||||||
|
@ -104,6 +127,8 @@ public class AmmoBarOverlay {
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
poseStack.popPose();
|
poseStack.popPose();
|
||||||
|
|
||||||
// 渲染备弹量
|
// 渲染备弹量
|
||||||
|
@ -172,6 +197,7 @@ public class AmmoBarOverlay {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!creativeAmmo()) {
|
||||||
if (stack.getItem() == ModItems.M_79.get() || stack.getItem() == ModItems.RPG.get() || stack.getItem() == ModItems.TASER.get() || stack.getItem() == ModItems.JAVELIN.get() ) {
|
if (stack.getItem() == ModItems.M_79.get() || stack.getItem() == ModItems.RPG.get() || stack.getItem() == ModItems.TASER.get() || stack.getItem() == ModItems.JAVELIN.get() ) {
|
||||||
return "" + stack.getOrCreateTag().getInt("max_ammo");
|
return "" + stack.getOrCreateTag().getInt("max_ammo");
|
||||||
}
|
}
|
||||||
|
@ -191,6 +217,9 @@ public class AmmoBarOverlay {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "∞";
|
||||||
|
}
|
||||||
|
|
||||||
private static String getGunAmmoType(ItemStack stack) {
|
private static String getGunAmmoType(ItemStack stack) {
|
||||||
if (stack.getItem() == ModItems.BOCEK.get()) {
|
if (stack.getItem() == ModItems.BOCEK.get()) {
|
||||||
return " Arrow";
|
return " Arrow";
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class ClientEventHandler {
|
||||||
|
|
||||||
// 开火部分
|
// 开火部分
|
||||||
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS
|
if (GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS
|
||||||
&& (player.getMainHandItem().is(ModTags.Items.NORMAL_GUN) || stack.is(ModItems.MINIGUN.get()))) {
|
&& (player.getMainHandItem().is(ModTags.Items.NORMAL_GUN) || (stack.is(ModItems.MINIGUN.get()) && !player.isSprinting()))) {
|
||||||
|
|
||||||
double customRpm = 0;
|
double customRpm = 0;
|
||||||
|
|
||||||
|
@ -164,6 +164,16 @@ public class ClientEventHandler {
|
||||||
customRpm = stack.getOrCreateTag().getInt("customRpm");
|
customRpm = stack.getOrCreateTag().getInt("customRpm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stack.getItem() == ModItems.MINIGUN.get()) {
|
||||||
|
if (player.isInWater()) {
|
||||||
|
customRpm = - 0.25 * stack.getOrCreateTag().getDouble("rpm");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stack.getOrCreateTag().getDouble("overheat") != 0 || player.getCooldowns().isOnCooldown(stack.getItem()) || stack.getOrCreateTag().getDouble("minigun_rotation") < 10) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double rpm = stack.getOrCreateTag().getDouble("rpm") + customRpm;
|
double rpm = stack.getOrCreateTag().getDouble("rpm") + customRpm;
|
||||||
if (rpm == 0) {
|
if (rpm == 0) {
|
||||||
rpm = 600;
|
rpm = 600;
|
||||||
|
@ -173,11 +183,6 @@ public class ClientEventHandler {
|
||||||
// cooldown in ms
|
// cooldown in ms
|
||||||
double cooldown = 1000 / rps;
|
double cooldown = 1000 / rps;
|
||||||
|
|
||||||
if (stack.getItem() == ModItems.MINIGUN.get()) {
|
|
||||||
if (stack.getOrCreateTag().getDouble("overheat") != 0 || player.getCooldowns().isOnCooldown(stack.getItem()) || stack.getOrCreateTag().getDouble("minigun_rotation") < 10) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!clientTimer.started()) {
|
if (!clientTimer.started()) {
|
||||||
clientTimer.start();
|
clientTimer.start();
|
||||||
|
|
|
@ -336,6 +336,14 @@ public class GunEventHandler {
|
||||||
public static void playGunNormalReload(Player player) {
|
public static void playGunNormalReload(Player player) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
||||||
if (stack.getItem() == ModItems.ABEKIRI.get()) {
|
if (stack.getItem() == ModItems.ABEKIRI.get()) {
|
||||||
GunsTool.reload(player, GunInfo.Type.SHOTGUN);
|
GunsTool.reload(player, GunInfo.Type.SHOTGUN);
|
||||||
|
@ -353,6 +361,27 @@ public class GunEventHandler {
|
||||||
GunsTool.reload(player, GunInfo.Type.RIFLE, true);
|
GunsTool.reload(player, GunInfo.Type.RIFLE, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
||||||
|
if (stack.getItem() == ModItems.ABEKIRI.get()) {
|
||||||
|
stack.getOrCreateTag().putInt("ammo", stack.getOrCreateTag().getInt("mag"));
|
||||||
|
} else {
|
||||||
|
stack.getOrCreateTag().putInt("ammo", stack.getOrCreateTag().getInt("mag") + 1);
|
||||||
|
}
|
||||||
|
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
|
||||||
|
stack.getOrCreateTag().putInt("ammo", stack.getOrCreateTag().getInt("mag") + 1);
|
||||||
|
} else if (stack.is(ModTags.Items.USE_HANDGUN_AMMO)) {
|
||||||
|
stack.getOrCreateTag().putInt("ammo", stack.getOrCreateTag().getInt("mag") + 1);
|
||||||
|
} else if (stack.is(ModTags.Items.USE_RIFLE_AMMO)) {
|
||||||
|
if (stack.getItem() == ModItems.M_60.get()) {
|
||||||
|
stack.getOrCreateTag().putInt("ammo", stack.getOrCreateTag().getInt("mag"));
|
||||||
|
} else {
|
||||||
|
stack.getOrCreateTag().putInt("ammo", stack.getOrCreateTag().getInt("mag") + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
stack.getOrCreateTag().putBoolean("is_normal_reloading", false);
|
stack.getOrCreateTag().putBoolean("is_normal_reloading", false);
|
||||||
stack.getOrCreateTag().putBoolean("is_empty_reloading", false);
|
stack.getOrCreateTag().putBoolean("is_empty_reloading", false);
|
||||||
|
|
||||||
|
@ -362,6 +391,14 @@ public class GunEventHandler {
|
||||||
public static void playGunEmptyReload(Player player) {
|
public static void playGunEmptyReload(Player player) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
||||||
GunsTool.reload(player, GunInfo.Type.SHOTGUN);
|
GunsTool.reload(player, GunInfo.Type.SHOTGUN);
|
||||||
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
|
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
|
||||||
|
@ -383,6 +420,11 @@ public class GunEventHandler {
|
||||||
stack.getOrCreateTag().putInt("ammo", 1);
|
stack.getOrCreateTag().putInt("ammo", 1);
|
||||||
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.JAVELIN_MISSILE.get(), 1, player.inventoryMenu.getCraftSlots());
|
player.getInventory().clearOrCountMatchingItems(p -> p.getItem() == ModItems.JAVELIN_MISSILE.get(), 1, player.inventoryMenu.getCraftSlots());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
stack.getOrCreateTag().putInt("ammo", stack.getOrCreateTag().getInt("mag"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
stack.getOrCreateTag().putBoolean("is_normal_reloading", false);
|
stack.getOrCreateTag().putBoolean("is_normal_reloading", false);
|
||||||
stack.getOrCreateTag().putBoolean("is_empty_reloading", false);
|
stack.getOrCreateTag().putBoolean("is_empty_reloading", false);
|
||||||
|
@ -586,6 +628,14 @@ public class GunEventHandler {
|
||||||
|
|
||||||
tag.putInt("ammo", tag.getInt("ammo") + 1);
|
tag.putInt("ammo", tag.getInt("ammo") + 1);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
capability.shotgunAmmo -= 1;
|
capability.shotgunAmmo -= 1;
|
||||||
|
@ -609,6 +659,8 @@ public class GunEventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void playGunPrepareReloadSounds(Player player) {
|
public static void playGunPrepareReloadSounds(Player player) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.is(ModTags.Items.GUN)) {
|
if (!stack.is(ModTags.Items.GUN)) {
|
||||||
|
|
|
@ -131,6 +131,15 @@ public class PlayerEventHandler {
|
||||||
CompoundTag tag = stack.getOrCreateTag();
|
CompoundTag tag = stack.getOrCreateTag();
|
||||||
|
|
||||||
// 检查备弹
|
// 检查备弹
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
|
||||||
return;
|
return;
|
||||||
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
|
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
|
||||||
|
@ -148,6 +157,8 @@ public class PlayerEventHandler {
|
||||||
} else if (stack.getItem() == ModItems.JAVELIN.get() && tag.getInt("max_ammo") == 0) {
|
} else if (stack.getItem() == ModItems.JAVELIN.get() && tag.getInt("max_ammo") == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ModUtils.PACKET_HANDLER.sendToServer(new ReloadMessage(0));
|
ModUtils.PACKET_HANDLER.sendToServer(new ReloadMessage(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@ import net.mcreator.superbwarfare.item.gun.sniper.*;
|
||||||
import net.mcreator.superbwarfare.item.gun.special.BocekItem;
|
import net.mcreator.superbwarfare.item.gun.special.BocekItem;
|
||||||
import net.mcreator.superbwarfare.item.gun.special.TaserItem;
|
import net.mcreator.superbwarfare.item.gun.special.TaserItem;
|
||||||
import net.mcreator.superbwarfare.tools.RarityTool;
|
import net.mcreator.superbwarfare.tools.RarityTool;
|
||||||
import net.minecraft.world.item.ArmorItem;
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
|
@ -92,7 +91,7 @@ public class ModItems {
|
||||||
public static final RegistryObject<Item> RIFLE_AMMO_BOX = AMMO.register("rifle_ammo_box", RifleAmmoBox::new);
|
public static final RegistryObject<Item> RIFLE_AMMO_BOX = AMMO.register("rifle_ammo_box", RifleAmmoBox::new);
|
||||||
public static final RegistryObject<Item> SNIPER_AMMO_BOX = AMMO.register("sniper_ammo_box", SniperAmmoBox::new);
|
public static final RegistryObject<Item> SNIPER_AMMO_BOX = AMMO.register("sniper_ammo_box", SniperAmmoBox::new);
|
||||||
public static final RegistryObject<Item> SHOTGUN_AMMO_BOX = AMMO.register("shotgun_ammo_box", ShotgunAmmoBox::new);
|
public static final RegistryObject<Item> SHOTGUN_AMMO_BOX = AMMO.register("shotgun_ammo_box", ShotgunAmmoBox::new);
|
||||||
public static final RegistryObject<Item> CREATIVE_AMMO_BOX = AMMO.register("creative_ammo_box", CreativeAmmoBox::new);
|
public static final RegistryObject<Item> CREATIVE_AMMO_BOX = AMMO.register("creative_ammo_box", () -> new Item(new Item.Properties().rarity(Rarity.EPIC)));
|
||||||
public static final RegistryObject<Item> TASER_ELECTRODE = AMMO.register("taser_electrode", () -> new Item(new Item.Properties()));
|
public static final RegistryObject<Item> TASER_ELECTRODE = AMMO.register("taser_electrode", () -> new Item(new Item.Properties()));
|
||||||
public static final RegistryObject<Item> GRENADE_40MM = AMMO.register("grenade_40mm", () -> new Item(new Item.Properties()));
|
public static final RegistryObject<Item> GRENADE_40MM = AMMO.register("grenade_40mm", () -> new Item(new Item.Properties()));
|
||||||
public static final RegistryObject<Item> JAVELIN_MISSILE = AMMO.register("javelin_missile", () -> new Item(new Item.Properties()));
|
public static final RegistryObject<Item> JAVELIN_MISSILE = AMMO.register("javelin_missile", () -> new Item(new Item.Properties()));
|
||||||
|
|
|
@ -12,5 +12,6 @@ public class ModParticleTypes {
|
||||||
|
|
||||||
public static final RegistryObject<SimpleParticleType> FIRE_STAR = REGISTRY.register("fire_star", () -> new SimpleParticleType(false));
|
public static final RegistryObject<SimpleParticleType> FIRE_STAR = REGISTRY.register("fire_star", () -> new SimpleParticleType(false));
|
||||||
public static final RegistryObject<SimpleParticleType> BULLET_HOLE = REGISTRY.register("bullet_hole", () -> new SimpleParticleType(false));
|
public static final RegistryObject<SimpleParticleType> BULLET_HOLE = REGISTRY.register("bullet_hole", () -> new SimpleParticleType(false));
|
||||||
|
public static final RegistryObject<SimpleParticleType> CUSTOM_CLOUD = REGISTRY.register("custom_cloud", () -> new SimpleParticleType(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.mcreator.superbwarfare.init;
|
package net.mcreator.superbwarfare.init;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.client.particle.BulletHoleParticle;
|
import net.mcreator.superbwarfare.client.particle.BulletHoleParticle;
|
||||||
|
import net.mcreator.superbwarfare.client.particle.CustomCloudParticle;
|
||||||
import net.mcreator.superbwarfare.client.particle.FireStarParticle;
|
import net.mcreator.superbwarfare.client.particle.FireStarParticle;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
|
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
|
||||||
|
@ -13,6 +14,7 @@ public class ModParticles {
|
||||||
public static void registerParticles(RegisterParticleProvidersEvent event) {
|
public static void registerParticles(RegisterParticleProvidersEvent event) {
|
||||||
event.registerSpriteSet(ModParticleTypes.FIRE_STAR.get(), FireStarParticle::provider);
|
event.registerSpriteSet(ModParticleTypes.FIRE_STAR.get(), FireStarParticle::provider);
|
||||||
event.registerSpriteSet(ModParticleTypes.BULLET_HOLE.get(), BulletHoleParticle::provider);
|
event.registerSpriteSet(ModParticleTypes.BULLET_HOLE.get(), BulletHoleParticle::provider);
|
||||||
|
event.registerSpriteSet(ModParticleTypes.CUSTOM_CLOUD.get(), CustomCloudParticle::provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,6 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
public class RuHelmet6b47 extends ArmorItem implements GeoItem {
|
public class RuHelmet6b47 extends ArmorItem implements GeoItem {
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
public String animationprocedure = "empty";
|
|
||||||
|
|
||||||
public RuHelmet6b47() {
|
public RuHelmet6b47() {
|
||||||
super(ModArmorMaterial.CEMENTED_CARBIDE, Type.HELMET, new Properties());
|
super(ModArmorMaterial.CEMENTED_CARBIDE, Type.HELMET, new Properties());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
package net.mcreator.superbwarfare.item.common.ammo;
|
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.init.ModSounds;
|
|
||||||
import net.mcreator.superbwarfare.network.ModVariables;
|
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.sounds.SoundSource;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
import net.minecraft.world.InteractionResultHolder;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.*;
|
|
||||||
import net.minecraft.world.level.Level;
|
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CreativeAmmoBox extends Item {
|
|
||||||
public CreativeAmmoBox() {
|
|
||||||
super(new Item.Properties().rarity(Rarity.EPIC));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UseAnim getUseAnimation(ItemStack itemstack) {
|
|
||||||
return UseAnim.EAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getUseDuration(ItemStack itemstack) {
|
|
||||||
return 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public boolean isFoil(ItemStack itemstack) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
|
|
||||||
list.add(Component.translatable("des.superbwarfare.creative_ammo_box").withStyle(ChatFormatting.GRAY));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
|
|
||||||
ItemStack stack = player.getItemInHand(hand);
|
|
||||||
player.getCooldowns().addCooldown(this, 20);
|
|
||||||
stack.shrink(1);
|
|
||||||
|
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
|
||||||
capability.handgunAmmo = 2147483647;
|
|
||||||
capability.rifleAmmo = 2147483647;
|
|
||||||
capability.shotgunAmmo = 2147483647;
|
|
||||||
capability.sniperAmmo = 2147483647;
|
|
||||||
capability.syncPlayerVariables(player);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!level.isClientSide()) {
|
|
||||||
player.displayClientMessage(Component.translatable("item.superbwarfare.ammo_supplier.creative"), false);
|
|
||||||
level.playSound(null, player.blockPosition(), ModSounds.BULLET_SUPPLY.get(), SoundSource.VOICE, 1, 1);
|
|
||||||
}
|
|
||||||
return InteractionResultHolder.consume(stack);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -154,6 +154,14 @@ public class JavelinItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getAmmoCount(Player player) {
|
public static int getAmmoCount(Player player) {
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
||||||
ItemStack itemstack = player.getInventory().getItem(i);
|
ItemStack itemstack = player.getInventory().getItem(i);
|
||||||
|
@ -163,6 +171,8 @@ public class JavelinItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
return (int) Double.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<SoundEvent> getReloadSound() {
|
public Set<SoundEvent> getReloadSound() {
|
||||||
|
|
|
@ -154,6 +154,14 @@ public class M79Item extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getAmmoCount(Player player) {
|
public static int getAmmoCount(Player player) {
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
||||||
ItemStack itemstack = player.getInventory().getItem(i);
|
ItemStack itemstack = player.getInventory().getItem(i);
|
||||||
|
@ -163,6 +171,8 @@ public class M79Item extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
return (int) Double.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack itemStack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack itemStack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
|
|
|
@ -152,6 +152,14 @@ public class RpgItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getAmmoCount(Player player) {
|
public static int getAmmoCount(Player player) {
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
||||||
ItemStack itemstack = player.getInventory().getItem(i);
|
ItemStack itemstack = player.getInventory().getItem(i);
|
||||||
|
@ -161,6 +169,8 @@ public class RpgItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
return (int) Double.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<SoundEvent> getReloadSound() {
|
public Set<SoundEvent> getReloadSound() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.google.common.collect.Multimap;
|
||||||
import net.mcreator.superbwarfare.ModUtils;
|
import net.mcreator.superbwarfare.ModUtils;
|
||||||
import net.mcreator.superbwarfare.client.renderer.item.MinigunItemRenderer;
|
import net.mcreator.superbwarfare.client.renderer.item.MinigunItemRenderer;
|
||||||
import net.mcreator.superbwarfare.init.ModItems;
|
import net.mcreator.superbwarfare.init.ModItems;
|
||||||
|
import net.mcreator.superbwarfare.init.ModParticleTypes;
|
||||||
import net.mcreator.superbwarfare.init.ModPerks;
|
import net.mcreator.superbwarfare.init.ModPerks;
|
||||||
import net.mcreator.superbwarfare.init.ModTags;
|
import net.mcreator.superbwarfare.init.ModTags;
|
||||||
import net.mcreator.superbwarfare.item.AnimatedItem;
|
import net.mcreator.superbwarfare.item.AnimatedItem;
|
||||||
|
@ -12,12 +13,16 @@ import net.mcreator.superbwarfare.item.gun.GunItem;
|
||||||
import net.mcreator.superbwarfare.perk.Perk;
|
import net.mcreator.superbwarfare.perk.Perk;
|
||||||
import net.mcreator.superbwarfare.tools.GunsTool;
|
import net.mcreator.superbwarfare.tools.GunsTool;
|
||||||
import net.mcreator.superbwarfare.tools.ItemNBTTool;
|
import net.mcreator.superbwarfare.tools.ItemNBTTool;
|
||||||
|
import net.mcreator.superbwarfare.tools.ParticleTool;
|
||||||
import net.mcreator.superbwarfare.tools.RarityTool;
|
import net.mcreator.superbwarfare.tools.RarityTool;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.model.HumanoidModel;
|
import net.minecraft.client.model.HumanoidModel;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
|
||||||
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.effect.MobEffects;
|
import net.minecraft.world.effect.MobEffects;
|
||||||
|
@ -33,6 +38,7 @@ import net.minecraft.world.item.ItemDisplayContext;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
|
||||||
|
import org.joml.Vector3d;
|
||||||
import software.bernie.geckolib.animatable.GeoItem;
|
import software.bernie.geckolib.animatable.GeoItem;
|
||||||
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
|
||||||
import software.bernie.geckolib.core.animation.AnimatableManager;
|
import software.bernie.geckolib.core.animation.AnimatableManager;
|
||||||
|
@ -131,25 +137,8 @@ public class MinigunItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
return PlayState.STOP;
|
return PlayState.STOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayState procedurePredicate(AnimationState<MinigunItem> event) {
|
|
||||||
if (transformType != null && transformType.firstPerson()) {
|
|
||||||
if (!this.animationProcedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
|
||||||
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationProcedure));
|
|
||||||
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) {
|
|
||||||
this.animationProcedure = "empty";
|
|
||||||
event.getController().forceAnimationReset();
|
|
||||||
}
|
|
||||||
} else if (this.animationProcedure.equals("empty")) {
|
|
||||||
return PlayState.STOP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PlayState.CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
|
||||||
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
|
|
||||||
data.add(procedureController);
|
|
||||||
var idleController = new AnimationController<>(this, "idleController", 6, this::idlePredicate);
|
var idleController = new AnimationController<>(this, "idleController", 6, this::idlePredicate);
|
||||||
data.add(idleController);
|
data.add(idleController);
|
||||||
}
|
}
|
||||||
|
@ -175,6 +164,16 @@ public class MinigunItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
super.inventoryTick(itemstack, world, entity, slot, selected);
|
super.inventoryTick(itemstack, world, entity, slot, selected);
|
||||||
|
|
||||||
|
float yRot = entity.getYRot();
|
||||||
|
if (yRot < 0) {
|
||||||
|
yRot += 360;
|
||||||
|
}
|
||||||
|
yRot = yRot + 90 % 360;
|
||||||
|
|
||||||
|
var leftPos = new Vector3d(1.2, -0.3, 0.3);
|
||||||
|
leftPos.rotateZ(-entity.getXRot() * Mth.DEG_TO_RAD);
|
||||||
|
leftPos.rotateY(-yRot * Mth.DEG_TO_RAD);
|
||||||
|
|
||||||
double cooldown = 0;
|
double cooldown = 0;
|
||||||
if (entity.wasInPowderSnow) {
|
if (entity.wasInPowderSnow) {
|
||||||
cooldown = 0.75;
|
cooldown = 0.75;
|
||||||
|
@ -184,6 +183,22 @@ public class MinigunItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
cooldown = -0.5;
|
cooldown = -0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entity instanceof ServerPlayer serverPlayer && entity.level() instanceof ServerLevel serverLevel && itemstack.getOrCreateTag().getDouble("heat") > 4) {
|
||||||
|
if (entity.isInWater()) {
|
||||||
|
ParticleTool.sendParticle(serverLevel, ParticleTypes.BUBBLE_COLUMN_UP,
|
||||||
|
entity.getX() + leftPos.x,
|
||||||
|
entity.getEyeY() + leftPos.y,
|
||||||
|
entity.getZ() + leftPos.z,
|
||||||
|
1, 0.1, 0.1, 0.1, 0.002, true, serverPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
ParticleTool.sendParticle(serverLevel, ModParticleTypes.CUSTOM_CLOUD.get(),
|
||||||
|
entity.getX() + leftPos.x,
|
||||||
|
entity.getEyeY() + leftPos.y,
|
||||||
|
entity.getZ() + leftPos.z,
|
||||||
|
1, 0.1, 0.1, 0.1, 0.002, true, serverPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
itemstack.getOrCreateTag().putDouble("heat", Mth.clamp(itemstack.getOrCreateTag().getDouble("heat") - 0.25 - cooldown, 0, 55));
|
itemstack.getOrCreateTag().putDouble("heat", Mth.clamp(itemstack.getOrCreateTag().getDouble("heat") - 0.25 - cooldown, 0, 55));
|
||||||
|
|
||||||
if (itemstack.getOrCreateTag().getDouble("overheat") > 0) {
|
if (itemstack.getOrCreateTag().getDouble("overheat") > 0) {
|
||||||
|
|
|
@ -145,6 +145,14 @@ public class BocekItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getAmmoCount(Player player) {
|
public static int getAmmoCount(Player player) {
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
||||||
ItemStack itemstack = player.getInventory().getItem(i);
|
ItemStack itemstack = player.getInventory().getItem(i);
|
||||||
|
@ -154,6 +162,8 @@ public class BocekItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
return (int) Double.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack itemstack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
|
|
|
@ -196,6 +196,14 @@ public class TaserItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getAmmoCount(Player player) {
|
public static int getAmmoCount(Player player) {
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
for (int i = 0; i < player.getInventory().getContainerSize(); ++i) {
|
||||||
ItemStack itemstack = player.getInventory().getItem(i);
|
ItemStack itemstack = player.getInventory().getItem(i);
|
||||||
|
@ -205,6 +213,8 @@ public class TaserItem extends GunItem implements GeoItem, AnimatedItem {
|
||||||
}
|
}
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
return (int) Double.POSITIVE_INFINITY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
||||||
|
|
|
@ -152,14 +152,6 @@ public class FireMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handItem.getItem() == ModItems.MINIGUN.get()) {
|
|
||||||
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).rifleAmmo == 0) {
|
|
||||||
if (!player.level().isClientSide()) {
|
|
||||||
SoundTool.playLocalSound(player, ModSounds.TRIGGER_CLICK.get(), 10, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
capability.bowPullHold = true;
|
capability.bowPullHold = true;
|
||||||
capability.syncPlayerVariables(player);
|
capability.syncPlayerVariables(player);
|
||||||
|
@ -290,7 +282,14 @@ public class FireMessage {
|
||||||
player.getMainHandItem().getOrCreateTag().putDouble("power", 0);
|
player.getMainHandItem().getOrCreateTag().putDouble("power", 0);
|
||||||
stack.getOrCreateTag().putInt("fire_animation", 2);
|
stack.getOrCreateTag().putInt("fire_animation", 2);
|
||||||
|
|
||||||
if (!player.isCreative()) {
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0 && !player.isCreative()) {
|
||||||
player.getInventory().clearOrCountMatchingItems(p -> Items.ARROW == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
|
player.getInventory().clearOrCountMatchingItems(p -> Items.ARROW == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,15 @@ public class ReloadMessage {
|
||||||
boolean clipLoad = tag.getInt("ammo") == 0 && tag.getDouble("clipLoad") == 1;
|
boolean clipLoad = tag.getInt("ammo") == 0 && tag.getDouble("clipLoad") == 1;
|
||||||
|
|
||||||
// 检查备弹
|
// 检查备弹
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
|
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO) && capability.shotgunAmmo == 0) {
|
||||||
return;
|
return;
|
||||||
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
|
} else if (stack.is(ModTags.Items.USE_SNIPER_AMMO) && capability.sniperAmmo == 0) {
|
||||||
|
@ -78,6 +87,7 @@ public class ReloadMessage {
|
||||||
} else if (stack.getItem() == ModItems.JAVELIN.get() && tag.getInt("max_ammo") == 0) {
|
} else if (stack.getItem() == ModItems.JAVELIN.get() && tag.getInt("max_ammo") == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (canReload || clipLoad) {
|
if (canReload || clipLoad) {
|
||||||
if (stack.is(ModTags.Items.OPEN_BOLT)) {
|
if (stack.is(ModTags.Items.OPEN_BOLT)) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ShootMessage {
|
||||||
|
|
||||||
double rpm = stack.getOrCreateTag().getDouble("rpm") + stack.getOrCreateTag().getInt("customRpm");;
|
double rpm = stack.getOrCreateTag().getDouble("rpm") + stack.getOrCreateTag().getInt("customRpm");;
|
||||||
|
|
||||||
int coolDownownTick = (int) Math.ceil(20 / (rpm / 60));
|
int coolDownTick = (int) Math.ceil(20 / (rpm / 60));
|
||||||
double mode = stack.getOrCreateTag().getInt("fire_mode");
|
double mode = stack.getOrCreateTag().getInt("fire_mode");
|
||||||
|
|
||||||
if ((player.getPersistentData().getBoolean("holdFire") || stack.getOrCreateTag().getInt("burst_fire") > 0)
|
if ((player.getPersistentData().getBoolean("holdFire") || stack.getOrCreateTag().getInt("burst_fire") > 0)
|
||||||
|
@ -77,14 +77,14 @@ public class ShootMessage {
|
||||||
int singleInterval = 0;
|
int singleInterval = 0;
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
player.getPersistentData().putBoolean("holdFire", false);
|
player.getPersistentData().putBoolean("holdFire", false);
|
||||||
singleInterval = coolDownownTick;
|
singleInterval = coolDownTick;
|
||||||
}
|
}
|
||||||
|
|
||||||
int burstCooldown = 0;
|
int burstCooldown = 0;
|
||||||
if (mode == 1) {
|
if (mode == 1) {
|
||||||
player.getPersistentData().putBoolean("holdFire", false);
|
player.getPersistentData().putBoolean("holdFire", false);
|
||||||
stack.getOrCreateTag().putInt("burst_fire", (stack.getOrCreateTag().getInt("burst_fire") - 1));
|
stack.getOrCreateTag().putInt("burst_fire", (stack.getOrCreateTag().getInt("burst_fire") - 1));
|
||||||
burstCooldown = stack.getOrCreateTag().getInt("burst_fire") == 0 ? coolDownownTick + 4 : 0;
|
burstCooldown = stack.getOrCreateTag().getInt("burst_fire") == 0 ? coolDownTick + 4 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getOrCreateTag().getDouble("animindex") == 1) {
|
if (stack.getOrCreateTag().getDouble("animindex") == 1) {
|
||||||
|
@ -107,8 +107,8 @@ public class ShootMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1));
|
stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1));
|
||||||
stack.getOrCreateTag().putInt("fire_animation", coolDownownTick);
|
stack.getOrCreateTag().putInt("fire_animation", coolDownTick);
|
||||||
player.getPersistentData().putInt("noRun_time", coolDownownTick + 2);
|
player.getPersistentData().putInt("noRun_time", coolDownTick + 2);
|
||||||
stack.getOrCreateTag().putDouble("flash_time", 2);
|
stack.getOrCreateTag().putDouble("flash_time", 2);
|
||||||
|
|
||||||
stack.getOrCreateTag().putDouble("empty", 1);
|
stack.getOrCreateTag().putDouble("empty", 1);
|
||||||
|
@ -161,7 +161,15 @@ public class ShootMessage {
|
||||||
}
|
}
|
||||||
} else if (stack.is(ModItems.MINIGUN.get())) {
|
} else if (stack.is(ModItems.MINIGUN.get())) {
|
||||||
var tag = stack.getOrCreateTag();
|
var tag = stack.getOrCreateTag();
|
||||||
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).rifleAmmo > 0) {
|
|
||||||
|
int count = 0;
|
||||||
|
for (var inv : player.getInventory().items) {
|
||||||
|
if (inv.is(ModItems.CREATIVE_AMMO_BOX.get())) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).rifleAmmo > 0 || count > 0) {
|
||||||
tag.putDouble("heat", (tag.getDouble("heat") + 0.5));
|
tag.putDouble("heat", (tag.getDouble("heat") + 0.5));
|
||||||
if (tag.getDouble("heat") >= 50.5) {
|
if (tag.getDouble("heat") >= 50.5) {
|
||||||
tag.putDouble("overheat", 40);
|
tag.putDouble("overheat", 40);
|
||||||
|
@ -191,10 +199,12 @@ public class ShootMessage {
|
||||||
gunShoot(player, spared);
|
gunShoot(player, spared);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
|
||||||
capability.rifleAmmo = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).rifleAmmo - 1;
|
capability.rifleAmmo = player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).rifleAmmo - 1;
|
||||||
capability.syncPlayerVariables(player);
|
capability.syncPlayerVariables(player);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
tag.putInt("fire_animation", 2);
|
tag.putInt("fire_animation", 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,9 +125,7 @@
|
||||||
"item.superbwarfare.handgun_ammo_box": "Handgun Ammo Box",
|
"item.superbwarfare.handgun_ammo_box": "Handgun Ammo Box",
|
||||||
"des.superbwarfare.handgun_ammo_box": "Handgun Ammo *30",
|
"des.superbwarfare.handgun_ammo_box": "Handgun Ammo *30",
|
||||||
"item.superbwarfare.creative_ammo_box": "Creative Ammo Box",
|
"item.superbwarfare.creative_ammo_box": "Creative Ammo Box",
|
||||||
"des.superbwarfare.creative_ammo_box": "Creative Ammo *2147483647",
|
|
||||||
"item.superbwarfare.ammo_supplier.supply": "%s Ammo +%s",
|
"item.superbwarfare.ammo_supplier.supply": "%s Ammo +%s",
|
||||||
"item.superbwarfare.ammo_supplier.creative": "All Ammo +2147483647",
|
|
||||||
"item.superbwarfare.he_5_inches": "HE Shell",
|
"item.superbwarfare.he_5_inches": "HE Shell",
|
||||||
"item.superbwarfare.ap_5_inches": "AP Shell",
|
"item.superbwarfare.ap_5_inches": "AP Shell",
|
||||||
"item.superbwarfare.javelin_missile": "Javelin Missile",
|
"item.superbwarfare.javelin_missile": "Javelin Missile",
|
||||||
|
|
|
@ -125,9 +125,7 @@
|
||||||
"item.superbwarfare.handgun_ammo_box": "手枪弹药盒",
|
"item.superbwarfare.handgun_ammo_box": "手枪弹药盒",
|
||||||
"des.superbwarfare.handgun_ammo_box": "手枪弹药 *30",
|
"des.superbwarfare.handgun_ammo_box": "手枪弹药 *30",
|
||||||
"item.superbwarfare.creative_ammo_box": "创造弹药盒",
|
"item.superbwarfare.creative_ammo_box": "创造弹药盒",
|
||||||
"des.superbwarfare.creative_ammo_box": "创造弹药 *2147483647",
|
|
||||||
"item.superbwarfare.ammo_supplier.supply": "%s弹药 +%s",
|
"item.superbwarfare.ammo_supplier.supply": "%s弹药 +%s",
|
||||||
"item.superbwarfare.ammo_supplier.creative": "所有弹药 +2147483647",
|
|
||||||
"item.superbwarfare.he_5_inches": "高爆弹",
|
"item.superbwarfare.he_5_inches": "高爆弹",
|
||||||
"item.superbwarfare.ap_5_inches": "穿甲弹",
|
"item.superbwarfare.ap_5_inches": "穿甲弹",
|
||||||
"item.superbwarfare.javelin_missile": "标枪导弹",
|
"item.superbwarfare.javelin_missile": "标枪导弹",
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"textures": [
|
||||||
|
"minecraft:generic_7",
|
||||||
|
"minecraft:generic_6",
|
||||||
|
"minecraft:generic_5",
|
||||||
|
"minecraft:generic_4",
|
||||||
|
"minecraft:generic_3",
|
||||||
|
"minecraft:generic_2",
|
||||||
|
"minecraft:generic_1",
|
||||||
|
"minecraft:generic_0"
|
||||||
|
]
|
||||||
|
}
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Loading…
Add table
Reference in a new issue