This commit is contained in:
LZX committed 2026-08-13 02:38:33 +08:00
1 parent 7072b7a64c
commit 609b69b460
80 files changed
+1645 -521

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ mod_name=Lzxnone Terraria
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved
# The mod version. See https://semver.org/
mod_version=1.7.2
mod_version=1.7.3
## The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
@@ -71,6 +71,10 @@ public class ModSounds {
SOUND_EVENTS.register("whip",
() -> SoundEvent.createVariableRangeEvent(
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "whip")));
public static final Supplier<SoundEvent> BOW_SHOOT =
SOUND_EVENTS.register("bow_shoot",
() -> SoundEvent.createVariableRangeEvent(
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "bow_shoot")));
public static final Supplier<SoundEvent> SHOT =
SOUND_EVENTS.register("shot",
() -> SoundEvent.createVariableRangeEvent(
@@ -2,6 +2,7 @@ package com.lzxnone.terraria.client.entity.summon;
import com.lzxnone.terraria.client.item.normal.ClientDropFallenStar;
import com.lzxnone.terraria.client.item.normal.ClientManaStar;
import com.lzxnone.terraria.client.item.ranged.ClientArrowAmmo;
import com.lzxnone.terraria.client.item.ranged.ClientBulletAmmo;
import com.lzxnone.terraria.client.item.magic.ClientLastPrism;
import com.lzxnone.terraria.client.item.melee.ClientDevilsDevastation;
@@ -72,6 +73,7 @@ public class ClientStaticSummonRenderBehaviors {
BEHAVIORS.put(StaticSummonBehaviors.GOLDEN_BULLET, ClientBulletAmmo.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.LUMINITE_BULLET, ClientBulletAmmo.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.TUNGSTEN_BULLET, ClientBulletAmmo.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.WOODEN_ARROW, ClientArrowAmmo.SUMMON_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.SNOWBALL, DEFAULT_BEHAVIOR);
BEHAVIORS.put(StaticSummonBehaviors.FALLEN_STAR, ClientStarCannon.SUMMON_BEHAVIOR);
@@ -0,0 +1,56 @@
package com.lzxnone.terraria.client.item.ranged;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.client.entity.summon.IStaticSummonRenderBehavior;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
public class ClientArrowAmmo {
public static final IStaticSummonRenderBehavior SUMMON_BEHAVIOR = new IStaticSummonRenderBehavior() {
@Override
public void render(Entity entity, float entityYaw, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight) {
if(!(entity instanceof StaticSummon summon)) return;
ItemStack itemStack = summon.getEntityData().get(StaticSummon.ITEM);
if(itemStack == ItemStack.EMPTY) return;
renderArrowPlane(entity, summon, poseStack, bufferSource, packedLight, 0.0F);
renderArrowPlane(entity, summon, poseStack, bufferSource, packedLight, 90.0F);
}
private void renderArrowPlane(Entity entity, StaticSummon summon, PoseStack poseStack,
MultiBufferSource bufferSource, int packedLight, float roll) {
poseStack.pushPose();
poseStack.mulPose(Axis.YP.rotationDegrees(-summon.getYRot()));
poseStack.mulPose(Axis.XP.rotationDegrees(summon.getXRot()));
poseStack.mulPose(Axis.ZP.rotationDegrees(roll));
poseStack.mulPose(Axis.XP.rotationDegrees(-90));
poseStack.scale(
summon.getEntityData().get(StaticSummon.SCALE_X),
summon.getEntityData().get(StaticSummon.SCALE_Y),
summon.getEntityData().get(StaticSummon.SCALE_Z)
);
Minecraft.getInstance().getItemRenderer().renderStatic(
summon.getEntityData().get(StaticSummon.ITEM),
ItemDisplayContext.NONE,
summon.getEntityData().get(StaticSummon.GLOW) ? LightTexture.FULL_BRIGHT : packedLight,
OverlayTexture.NO_OVERLAY,
poseStack,
bufferSource,
entity.level(),
0
);
poseStack.popPose();
}
};
}
@@ -201,6 +201,7 @@ public class ModCreativeModeTabs {
output.accept(ModItems.SUPER_STAR_SHOOTER.get());
output.accept(ModItems.FLAMETHROWER.get());
output.accept(ModItems.ELF_MELTER.get());
output.accept(ModItems.DAEDALUS_STORMBOW.get());
output.accept(ModItems.MUSKET_BALL.get());
output.accept(ModItems.METEOR_SHOT.get());
output.accept(ModItems.SILVER_BULLET.get());
@@ -217,6 +218,7 @@ public class ModCreativeModeTabs {
output.accept(ModItems.ENDLESS_MUSKET_POUCH.get());
output.accept(ModItems.LUMINITE_BULLET.get());
output.accept(ModItems.TUNGSTEN_BULLET.get());
output.accept(ModItems.WOODEN_ARROW.get());
output.accept(ModItems.FALLEN_STAR.get());
}).build());
@@ -9,20 +9,50 @@ import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;
public class IchorEffect extends MobEffect {
public static final ConfigFloat DAMAGE_BONUS_PER_LEVEL = new ConfigFloat("effect.ichor.damage_bonus_per_level", "ichor_damage_bonus_per_level", 0.15f, 0.0f, 10.0f);
public static final ConfigFloat ARMOR_REDUCTION_PER_LEVEL = new ConfigFloat("effect.ichor.armor_reduction_per_level", "ichor_armor_reduction_per_level", 6.0f, 0.0f, 1024.0f);
private static final ResourceLocation ARMOR_REDUCTION_ID = ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "ichor_armor_reduction");
public static final IConfigData CONFIG_DATA = new IConfigData() {
@Override
public void onConfigLoad() {
ConfigStruct.loadAll(DAMAGE_BONUS_PER_LEVEL);
ConfigStruct.loadAll(ARMOR_REDUCTION_PER_LEVEL);
}
};
public static float getDamageBonusPerLevel() {
return DAMAGE_BONUS_PER_LEVEL.get();
public static float getArmorReductionPerLevel() {
return ARMOR_REDUCTION_PER_LEVEL.get();
}
public static void applyArmorReduction(LivingEntity entity) {
removeArmorReduction(entity);
MobEffectInstance instance = entity.getEffect(ModEffects.ICHOR);
if(instance == null) return;
double reduction = getArmorReductionPerLevel() * (instance.getAmplifier() + 1);
if(reduction <= 0.0D) return;
AttributeInstance armor = entity.getAttribute(Attributes.ARMOR);
if(armor != null) {
armor.addTransientModifier(new AttributeModifier(
ARMOR_REDUCTION_ID,
-reduction,
AttributeModifier.Operation.ADD_VALUE
));
}
}
public static void removeArmorReduction(LivingEntity entity) {
AttributeInstance armor = entity.getAttribute(Attributes.ARMOR);
if(armor != null) armor.removeModifier(ARMOR_REDUCTION_ID);
}
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
@@ -32,7 +32,6 @@ public class ModEntities {
.sized(1.0f, 1.0f)
.clientTrackingRange(1024)
.updateInterval(1)
.fireImmune()
.build("static_summon")
);
@@ -22,6 +22,7 @@ import java.util.*;
public class StaticSummon extends Entity {
public static final int INFINITE_LIFETIME = -114514;
public static final String HIT_TARGET_IGNITE_TICKS_KEY = "hitTargetIgniteTicks";
public static final EntityDataAccessor<String> BEHAVIOR =
SynchedEntityData.defineId(StaticSummon.class, EntityDataSerializers.STRING);
@@ -148,6 +149,21 @@ public class StaticSummon extends Entity {
this.move(MoverType.SELF, this.getDeltaMovement());
}
@Override
public boolean fireImmune() {
return !this.entityData.get(CUSTOM_DATA).contains(HIT_TARGET_IGNITE_TICKS_KEY);
}
@Override
public boolean isOnFire() {
return super.isOnFire() || this.entityData.get(CUSTOM_DATA).contains(HIT_TARGET_IGNITE_TICKS_KEY);
}
@Override
public boolean displayFireAnimation() {
return super.displayFireAnimation() || this.entityData.get(CUSTOM_DATA).contains(HIT_TARGET_IGNITE_TICKS_KEY);
}
@Override
public void addAdditionalSaveData(CompoundTag tag) {
tag.putString("behavior", this.entityData.get(BEHAVIOR));
@@ -67,6 +67,7 @@ public class StaticSummonBehaviors {
public static final String GOLDEN_BULLET = "golden_bullet";
public static final String LUMINITE_BULLET = "luminite_bullet";
public static final String TUNGSTEN_BULLET = "tungsten_bullet";
public static final String WOODEN_ARROW = "wooden_arrow";
//特殊子弹实体
public static final String SNOWBALL = "snowball";
@@ -119,6 +120,7 @@ public class StaticSummonBehaviors {
BEHAVIORS.put(GOLDEN_BULLET, GoldenBullet.SUMMON_BEHAVIOR);
BEHAVIORS.put(LUMINITE_BULLET, LuminiteBullet.SUMMON_BEHAVIOR);
BEHAVIORS.put(TUNGSTEN_BULLET, TungstenBullet.SUMMON_BEHAVIOR);
BEHAVIORS.put(WOODEN_ARROW, WoodenArrow.SUMMON_BEHAVIOR);
BEHAVIORS.put(SNOWBALL, SnowballCannon.SUMMON_BEHAVIOR);
BEHAVIORS.put(FALLEN_STAR, StarCannon.SUMMON_BEHAVIOR);
@@ -7,6 +7,7 @@ import com.lzxnone.terraria.attachment.PlayerMana;
import com.lzxnone.terraria.entity.ModEntities;
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
import com.lzxnone.terraria.effect.IchorEffect;
import com.lzxnone.terraria.effect.MidasEffect;
import com.lzxnone.terraria.effect.ModEffects;
import com.lzxnone.terraria.effect.PaladinsShieldEffect;
@@ -15,6 +16,8 @@ import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.item.accessory.PanicNecklace;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.item.accessory.AccessoryUtil;
import com.lzxnone.terraria.item.weapon.RangedWeapon;
import com.lzxnone.terraria.item.weapon.Weapon;
import com.lzxnone.terraria.item.weapon.melee.DevilsDevastation;
import com.lzxnone.terraria.item.weapon.summon.whip.Possession;
import net.minecraft.nbt.CompoundTag;
@@ -83,6 +86,7 @@ public class EntityEventHandler {
//进行护甲穿透
if(!source.is(DamageTypeTags.BYPASSES_ARMOR)) {
if(attacker instanceof LivingEntity livingEntity) AccessoryUtil.applyTargetArmorModifiers(livingEntity, entity);
IchorEffect.applyArmorReduction(entity);
}
//近战攻击命中时点燃目标
if(attacker instanceof LivingEntity livingAttacker && livingAttacker != entity) {
@@ -112,8 +116,18 @@ public class EntityEventHandler {
if(!(target.level() instanceof ServerLevel serverLevel)) return;
DamageSource source = event.getSource();
Entity attacker = source.getEntity();
//原版的箭伤害
if(source.is(DamageTypes.ARROW) && attacker instanceof LivingEntity livingAttacker) {
ItemStack weaponStack = source.getWeaponItem();
if(weaponStack != null && !weaponStack.isEmpty()) {
float finalDamage = Weapon.applyDamageBonus(weaponStack, livingAttacker, event.getNewDamage());
finalDamage = RangedWeapon.applyRangedDamageBonus(weaponStack, livingAttacker, finalDamage);
event.setNewDamage(finalDamage);
}
}
//移除饰品加成护甲穿透
AccessoryUtil.removeTargetArmorModifiers(event.getEntity());
IchorEffect.removeArmorReduction(event.getEntity());
//暴击
if(attacker instanceof LivingEntity livingEntity && attacker != target) {
double critChance = AccessoryUtil.getCritChance(livingEntity);
@@ -252,5 +252,9 @@ public class LzxnoneTerrariaJeiPlugin implements IModPlugin {
new ItemStack(ModItems.SORCERER_EMBLEM.get()),
Component.translatable("jei.lzxnoneterraria.info.sorcerer_emblem")
);
registration.addItemStackInfo(
new ItemStack(ModItems.DAEDALUS_STORMBOW.get()),
Component.translatable("jei.lzxnoneterraria.info.daedalus_stormbow")
);
}
}
@@ -9,6 +9,9 @@ import net.minecraft.world.item.Item;
public class ModItemTags {
public static final TagKey<Item> AMMO = create("ammo");
public static final TagKey<Item> BULLET_AMMO = create("bullet_ammo");
public static final TagKey<Item> ARROW_AMMO = create("arrow_ammo");
public static final TagKey<Item> GUNPOWDER_WEAPONS = create("gunpowder_weapons");
public static final TagKey<Item> SPREAD_RANGED_WEAPONS = create("spread_ranged_weapons");
private static TagKey<Item> create(String name) {
return TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, name));
@@ -14,6 +14,7 @@ import com.lzxnone.terraria.item.weapon.ranged.Flamethrower;
import com.lzxnone.terraria.item.weapon.ranged.SnowballCannon;
import com.lzxnone.terraria.item.weapon.ranged.StarCannon;
import com.lzxnone.terraria.item.weapon.ranged.SuperStarShooter;
import com.lzxnone.terraria.item.weapon.ranged.bow.DaedalusStormbow;
import com.lzxnone.terraria.item.weapon.ranged.gun.*;
import com.lzxnone.terraria.item.weapon.summon.minion.StardustDragonStaff;
import com.lzxnone.terraria.item.weapon.summon.minion.Terraprisma;
@@ -81,6 +82,7 @@ public class ModItems {
public static final DeferredItem<Item> SUPER_STAR_SHOOTER = ITEMS.register("super_star_shooter", SuperStarShooter::new);
public static final DeferredItem<Item> FLAMETHROWER = ITEMS.register("flamethrower", Flamethrower::new);
public static final DeferredItem<Item> ELF_MELTER = ITEMS.register("elf_melter", ElfMelter::new);
public static final DeferredItem<Item> DAEDALUS_STORMBOW = ITEMS.register("daedalus_stormbow", DaedalusStormbow::new);
//召唤武器
public static final DeferredItem<Item> TERRAPRISMA = ITEMS.register("terraprisma", Terraprisma::new);
@@ -107,6 +109,7 @@ public class ModItems {
public static final DeferredItem<Item> ENDLESS_MUSKET_POUCH = ITEMS.register("endless_musket_pouch", EndlessMusketPouch::new);
public static final DeferredItem<Item> LUMINITE_BULLET = ITEMS.register("luminite_bullet", LuminiteBullet::new);
public static final DeferredItem<Item> TUNGSTEN_BULLET = ITEMS.register("tungsten_bullet", TungstenBullet::new);
public static final DeferredItem<Item> WOODEN_ARROW = ITEMS.register("wooden_arrow", WoodenArrow::new);
public static final DeferredItem<Item> FALLEN_STAR = ITEMS.register("fallen_star", FallenStar::new);
//饰品
@@ -0,0 +1,33 @@
package com.lzxnone.terraria.item.ammo;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.utils.ParticleUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.core.particles.BlockParticleOption;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
public class Ammo extends Item {
public static final int MAX_STACK_SIZE = 99;
public Ammo() {
super(new Item.Properties().stacksTo(MAX_STACK_SIZE));
}
public static void playBlockHitEffects(ServerLevel level, BlockHitResult blockHitResult) {
BlockState hitState = level.getBlockState(blockHitResult.getBlockPos());
ParticleUtil.addParticles(
level,
new BlockParticleOption(ParticleTypes.BLOCK, hitState),
blockHitResult.getLocation(),
Vec3.ZERO,
0.2,
25
);
SoundUtil.playServerSound(level, ModSounds.DIG.get(), blockHitResult.getLocation(), 1.0f, 1.0f);
}
}
@@ -0,0 +1,7 @@
package com.lzxnone.terraria.item.ammo;
public class ArrowAmmo extends Ammo {
public ArrowAmmo() {
super();
}
}
@@ -1,11 +1,7 @@
package com.lzxnone.terraria.item.ammo;
import net.minecraft.world.item.Item;
public class BulletAmmo extends Item {
public static final int MAX_STACK_SIZE = 99;
public class BulletAmmo extends Ammo {
public BulletAmmo() {
super(new Item.Properties().stacksTo(MAX_STACK_SIZE));
super();
}
}
@@ -14,6 +14,7 @@ import com.lzxnone.terraria.utils.*;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ClipContext;
@@ -152,6 +153,7 @@ public class ChlorophyteBullet extends BulletAmmo {
}
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, summon.position().add(oldMotion));
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
@@ -102,6 +102,7 @@ public class CrystalBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
summon.setPos(blockHitResult.getLocation());
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
float damage = customData.contains("damage") ? customData.getFloat("damage") : 0;
@@ -17,6 +17,7 @@ import com.lzxnone.terraria.utils.FilterUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
@@ -91,6 +92,7 @@ public class CursedBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
@@ -115,6 +115,7 @@ public class ExplodingBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
summon.setPos(blockHitResult.getLocation());
SoundUtil.playServerSound(summon.level(), ModSounds.BOOM.get(), summon.position());
ParticleUtil.addParticles(
@@ -17,6 +17,7 @@ import com.lzxnone.terraria.utils.FilterUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
@@ -91,6 +92,7 @@ public class GoldenBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
@@ -16,6 +16,7 @@ import com.lzxnone.terraria.utils.FilterUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.AABB;
@@ -90,6 +91,7 @@ public class HighVelocityBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
@@ -17,6 +17,7 @@ import com.lzxnone.terraria.utils.FilterUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
@@ -91,6 +92,7 @@ public class IchorBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
@@ -104,6 +104,7 @@ public class LuminiteBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
summon.setPos(blockHitResult.getLocation());
ParticleUtil.addParticles(
(ServerLevel) summon.level(), PARTICLE,
@@ -18,6 +18,7 @@ import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.AABB;
@@ -92,6 +93,7 @@ public class MeteorShot extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
if(MeteorShot.incrementHit(summon) >= MAX_HIT.get()) {
this.onDied(summon);
return;
@@ -15,6 +15,7 @@ import com.lzxnone.terraria.utils.FilterUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.AABB;
@@ -81,6 +82,7 @@ public class MusketBall extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
@@ -19,6 +19,7 @@ import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
@@ -99,6 +100,7 @@ public class NanoBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
if(incrementHit(summon) >= MAX_HIT.get()) {
this.onDied(summon);
return;
@@ -91,6 +91,7 @@ public class PartyBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
summon.setPos(blockHitResult.getLocation());
ParticleUtil.addParticles(
(ServerLevel) summon.level(), ModParticles.PARTY_PARTICLE.get(),
@@ -15,6 +15,7 @@ import com.lzxnone.terraria.utils.FilterUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.monster.ZombifiedPiglin;
import net.minecraft.world.entity.monster.piglin.Piglin;
@@ -90,6 +91,7 @@ public class SilverBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
@@ -15,6 +15,7 @@ import com.lzxnone.terraria.utils.FilterUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.AABB;
@@ -81,6 +82,7 @@ public class TungstenBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
@@ -17,6 +17,7 @@ import com.lzxnone.terraria.utils.FilterUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
@@ -91,6 +92,7 @@ public class VenomBullet extends BulletAmmo {
//方块检测
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
@@ -0,0 +1,112 @@
package com.lzxnone.terraria.item.ammo;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.entity.summon.IStaticSummonBehavior;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.item.weapon.ranged.bow.Bow;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
import com.lzxnone.terraria.utils.CollisionUtil;
import com.lzxnone.terraria.utils.DamageUtil;
import com.lzxnone.terraria.utils.FilterUtil;
import com.lzxnone.terraria.utils.MathUtil;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import java.util.List;
public class WoodenArrow extends ArrowAmmo {
public static final ConfigFloat BASE_DAMAGE = new ConfigFloat("ammo.wooden_arrow.base_damage", "wooden_arrow_base_damage", 2.0f, 0.0f, 8388600.0f);
public static final ConfigDouble SPEED = new ConfigDouble("ammo.wooden_arrow.speed", "wooden_arrow_speed", 3.0D, 0.0D, 24.0D);
public static final ConfigDouble GRAVITY = new ConfigDouble("ammo.wooden_arrow.gravity", "wooden_arrow_gravity", 0.05D, 0.0D, 10.0D);
public static final IConfigData CONFIG_DATA = new IConfigData() {
@Override
public void onConfigLoad() {
ConfigStruct.loadAll(BASE_DAMAGE, SPEED, GRAVITY);
}
};
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
"wooden_arrow",
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/wooden_arrow.png"),
Component.translatable("item.lzxnoneterraria.wooden_arrow"),
CONFIG_DATA
);
public static final IStaticSummonBehavior SUMMON_BEHAVIOR = new IStaticSummonBehavior() {
@Override
public void tick(StaticSummon summon) {
this.checkBeforeTick(summon);
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
Vec3 motion = summon.getDeltaMovement();
if(motion.lengthSqr() < 1.0E-7D) {
motion = summon.getLookAngle().normalize().scale(SPEED.get());
}
motion = motion.add(0.0D, -GRAVITY.get(), 0.0D);
Vec3 start = summon.position();
Vec3 end = start.add(motion);
updateRotation(summon, motion);
if(summon.level().isClientSide()) {
summon.setDeltaMovement(motion);
return;
}
AABB hitBox = new AABB(start, end).inflate(0.25D);
Level level = summon.level();
List<Entity> targets = level.getEntitiesOfClass(
Entity.class,
hitBox,
FilterUtil.createTargetFilter(summon, summon.getOwner())
);
if(!targets.isEmpty()) {
float damage = customData.contains("damage") ? customData.getFloat("damage") : 0.0f;
float knockbackScale = customData.contains("knockbackScale") ? customData.getFloat("knockbackScale") : 1.0f;
int invulnerableTime = customData.contains("invulnerableTime") ? customData.getInt("invulnerableTime") : 20;
ItemStack sourceStack = summon.getEntityData().get(StaticSummon.STACK_SOURCE);
Entity target = targets.getFirst();
if(DamageUtil.rangedAttack(summon, target, sourceStack, BASE_DAMAGE.get() + damage, knockbackScale)) {
if(customData.contains(StaticSummon.HIT_TARGET_IGNITE_TICKS_KEY)) {
target.igniteForTicks(customData.getInt(StaticSummon.HIT_TARGET_IGNITE_TICKS_KEY));
}
target.invulnerableTime = invulnerableTime;
this.onDied(summon);
return;
}
}
BlockHitResult blockHitResult = CollisionUtil.checkBlockHit(summon, end);
if(blockHitResult.getType() != HitResult.Type.MISS) {
if(summon.level() instanceof ServerLevel serverLevel) Ammo.playBlockHitEffects(serverLevel, blockHitResult);
this.onDied(summon);
return;
}
summon.setDeltaMovement(motion);
}
};
public static void updateRotation(StaticSummon summon, Vec3 direction) {
if(direction.lengthSqr() < 1.0E-7D) return;
float[] xyRot = MathUtil.computeXYRot(direction.toVector3f());
summon.setXRot(xyRot[0]);
summon.setYRot(xyRot[1]);
}
}
@@ -2,6 +2,7 @@ package com.lzxnone.terraria.item.weapon;
import com.lzxnone.terraria.enchantment.ModEnchantmentConfigs;
import com.lzxnone.terraria.enchantment.ModEnchantments;
import com.lzxnone.terraria.item.ModItemTags;
import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.item.accessory.AccessoryUtil;
import com.lzxnone.terraria.item.effect.RangedDamageModifier;
@@ -26,6 +27,7 @@ import net.minecraft.world.item.Tier;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.component.CustomData;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import java.util.List;
@@ -55,9 +57,16 @@ public class RangedWeapon extends Weapon {
public static float applyRangedDamageBonus(ItemStack stack, LivingEntity entity, float damage) {
double finalDamage = damage;
//力量
int powerLevel = getEnchantmentLevel(entity, stack, Enchantments.POWER);
if(powerLevel > 0) {
finalDamage *= 1.0D + 0.2D * powerLevel;
}
//火药
int gunpowderLevel = getEnchantmentLevel(entity, stack, ModEnchantments.GUNPOWDER);
finalDamage *= Math.pow(ModEnchantmentConfigs.getGunpowderDamageMultiplier(), gunpowderLevel);
if(stack.is(ModItemTags.GUNPOWDER_WEAPONS)) {
int gunpowderLevel = getEnchantmentLevel(entity, stack, ModEnchantments.GUNPOWDER);
finalDamage *= Math.pow(ModEnchantmentConfigs.getGunpowderDamageMultiplier(), gunpowderLevel);
}
//饰品
double[] multiplier = {1.0D};
AccessoryUtil.forEachAccessory(entity, (accessory, accessoryStack) -> {
@@ -95,25 +104,19 @@ public class RangedWeapon extends Weapon {
}
public boolean canShoot(ItemStack weaponStack, Player player) {
ItemStack ammoStack = getAmmoStack(weaponStack);
if(ammoStack.isEmpty() || !canUseAmmo(weaponStack, ammoStack)) return false;
if(player.hasInfiniteMaterials()) return true;
Item ammoItem = ammoStack.getItem();
for(ItemStack inventoryStack : player.getInventory().items) {
if(inventoryStack.is(ammoItem)) return true;
}
return false;
return !findAmmo(weaponStack, player).isEmpty();
}
public int getAmmoCount(ItemStack weaponStack, Player player) {
ItemStack ammoStack = getAmmoStack(weaponStack);
if(ammoStack.isEmpty() || !canUseAmmo(weaponStack, ammoStack)) return 0;
Item ammoItem = ammoStack.getItem();
int count = 0;
ItemStack offhandStack = player.getItemInHand(InteractionHand.OFF_HAND);
if(isAmmoStack(ammoStack, offhandStack)) count += offhandStack.getCount();
for(ItemStack inventoryStack : player.getInventory().items) {
if(inventoryStack.is(ammoItem)) count += inventoryStack.getCount();
if(isAmmoStack(ammoStack, inventoryStack)) count += inventoryStack.getCount();
}
return count;
}
@@ -129,10 +132,12 @@ public class RangedWeapon extends Weapon {
if(ammoStack.isEmpty() || !canUseAmmo(weaponStack, ammoStack)) return false;
if(ammoStack.is(ModItems.ENDLESS_MUSKET_POUCH.get())) return true;
Item ammoItem = ammoStack.getItem();
int available = 0;
ItemStack offhandStack = player.getItemInHand(InteractionHand.OFF_HAND);
if(isAmmoStack(ammoStack, offhandStack)) available += offhandStack.getCount();
for(ItemStack inventoryStack : player.getInventory().items) {
if(inventoryStack.is(ammoItem)) {
if(isAmmoStack(ammoStack, inventoryStack)) {
available += inventoryStack.getCount();
if(available >= amount) break;
}
@@ -140,8 +145,15 @@ public class RangedWeapon extends Weapon {
if(available < amount) return false;
int remaining = amount;
if(isAmmoStack(ammoStack, offhandStack)) {
int consumed = Math.min(remaining, offhandStack.getCount());
offhandStack.shrink(consumed);
remaining -= consumed;
if(remaining <= 0) return true;
}
for(ItemStack inventoryStack : player.getInventory().items) {
if(!inventoryStack.is(ammoItem)) continue;
if(!isAmmoStack(ammoStack, inventoryStack)) continue;
int consumed = Math.min(remaining, inventoryStack.getCount());
inventoryStack.shrink(consumed);
@@ -152,6 +164,38 @@ public class RangedWeapon extends Weapon {
return false;
}
public ItemStack findAmmo(ItemStack weaponStack, Player player) {
ItemStack ammoStack = getAmmoStack(weaponStack);
ItemStack inventoryAmmo = findAmmoItem(player, ammoStack);
if(!inventoryAmmo.isEmpty()) return inventoryAmmo;
if(player.hasInfiniteMaterials() && canUseAmmo(weaponStack, ammoStack)) return ammoStack.copy();
return ItemStack.EMPTY;
}
public boolean isSelectedAmmo(ItemStack weaponStack, ItemStack ammoStack) {
ItemStack selectedAmmo = getAmmoStack(weaponStack);
return isAmmoStack(selectedAmmo, ammoStack);
}
protected ItemStack findAmmoItem(Player player, ItemStack ammoStack) {
if(ammoStack.isEmpty()) return ItemStack.EMPTY;
ItemStack offhandStack = player.getItemInHand(InteractionHand.OFF_HAND);
if(isAmmoStack(ammoStack, offhandStack)) return offhandStack;
ItemStack mainhandStack = player.getItemInHand(InteractionHand.MAIN_HAND);
if(isAmmoStack(ammoStack, mainhandStack)) return mainhandStack;
for(ItemStack inventoryStack : player.getInventory().items) {
if(isAmmoStack(ammoStack, inventoryStack)) return inventoryStack;
}
return ItemStack.EMPTY;
}
protected boolean isAmmoStack(ItemStack selectedAmmo, ItemStack ammoStack) {
return !selectedAmmo.isEmpty() && !ammoStack.isEmpty() && ammoStack.is(selectedAmmo.getItem());
}
public boolean tryShoot(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {
if(!canShoot(weaponStack, player)) return false;
if(!level.isClientSide() && !consumeAmmo(weaponStack, player, getAmmoConsumeAmount(weaponStack, player))) return false;
@@ -0,0 +1,91 @@
package com.lzxnone.terraria.item.weapon.ranged.bow;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.item.ModItemTags;
import com.lzxnone.terraria.item.weapon.RangedWeapon;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
import org.joml.Vector3f;
public class Bow extends RangedWeapon {
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.15f, 1.5f);
public static final int USE_TIME = 20;
public static final int FLAME_ARROW_FIRE_TICKS = 20 * 60 * 60;
public static final int FLAME_TARGET_IGNITE_TICKS = 100;
public Bow(Tier tier, Properties properties) {
super(tier, properties);
}
@Override
public boolean canUseAmmo(ItemStack weaponStack, ItemStack ammoStack) {
return ammoStack.is(ModItemTags.ARROW_AMMO);
}
@Override
protected ResourceLocation getDefaultAmmo(ItemStack weaponStack) {
return ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "wooden_arrow");
}
@Override
public int getUseTime(ItemStack weaponStack, LivingEntity entity) {
return USE_TIME;
}
@Override
public boolean consumeAmmo(ItemStack weaponStack, Player player, int amount) {
if(hasInfinity(weaponStack, player) && getAmmoCount(weaponStack, player) > 0) return true;
return super.consumeAmmo(weaponStack, player, amount);
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {
SoundUtil.playClientSound(player, ModSounds.BOW_SHOOT.get());
if(level.isClientSide()) return;
StaticSummon summon = createArrowSummon(level, player, hand, weaponStack);
level.addFreshEntity(summon);
}
protected float getDamage(ItemStack weaponStack, LivingEntity entity, ItemStack ammoStack) {
return 0;
}
protected float getKnockbackScale(ItemStack weaponStack, LivingEntity entity, ItemStack ammoStack) {
return 1.0f;
}
protected int getInvulnerableTime(ItemStack weaponStack, LivingEntity entity, ItemStack ammoStack) {
return 20;
}
protected boolean hasInfinity(ItemStack weaponStack, LivingEntity entity) {
return getEnchantmentLevel(entity, weaponStack, Enchantments.INFINITY) > 0;
}
protected StaticSummon createArrowSummon(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, weaponStack, OFFSET);
ItemStack ammoStack = getAmmoStack(weaponStack);
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA).copy();
customData.putFloat("damage", getDamage(weaponStack, player, ammoStack));
customData.putFloat("knockbackScale", getKnockbackScale(weaponStack, player, ammoStack));
customData.putInt("invulnerableTime", getInvulnerableTime(weaponStack, player, ammoStack));
if(getEnchantmentLevel(player, weaponStack, Enchantments.FLAME) > 0) {
customData.putInt(StaticSummon.HIT_TARGET_IGNITE_TICKS_KEY, FLAME_TARGET_IGNITE_TICKS);
summon.igniteForTicks(FLAME_ARROW_FIRE_TICKS);
}
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
return summon;
}
}
@@ -0,0 +1,102 @@
package com.lzxnone.terraria.item.weapon.ranged.bow;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
public class DaedalusStormbow extends Bow {
public static final String ID = "daedalus_stormbow";
public static final int USE_TIME = 19;
public static final int ARROW_COUNT = 3;
public static final double RANGE = 64.0D;
public static final double SPAWN_HEIGHT = 20.0D;
public static final double SPAWN_OFFSET = 6.0D;
public static final double HIT_OFFSET = 2D;
public static final ConfigFloat DAMAGE = new ConfigFloat("weapon.daedalus_stormbow.damage", "daedalus_stormbow_damage", 4.0F, 0.0F, 8388600.0F);
public static final IConfigData CONFIG_DATA = new IConfigData() {
@Override
public void onConfigLoad() {
ConfigStruct.loadAll(DAMAGE);
}
};
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
ID,
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/" + ID + ".png"),
Component.translatable("item.lzxnoneterraria." + ID),
CONFIG_DATA
);
public DaedalusStormbow() {
super(Tiers.IRON, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON));
}
@Override
public int getUseTime(ItemStack weaponStack, LivingEntity entity) {
return USE_TIME;
}
@Override
protected float getDamage(ItemStack weaponStack, LivingEntity entity, ItemStack ammoStack) {
return DAMAGE.get();
}
@Override
protected float getKnockbackScale(ItemStack weaponStack, LivingEntity entity, ItemStack ammoStack) {
return 1.0f;
}
@Override
protected int getInvulnerableTime(ItemStack weaponStack, LivingEntity entity, ItemStack ammoStack) {
return 10;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {
SoundUtil.playClientSound(player, ModSounds.BOW_SHOOT.get());
if(level.isClientSide()) return;
for(int i = 0; i < ARROW_COUNT; i++) {
StaticSummon summon = createArrowSummon(level, player, hand, weaponStack);
Vec3 targetPos = MathUtil.getCrosshairPos(player, level, RANGE);
Vec3 spawnPos = targetPos.add(
(level.random.nextDouble() * 2.0D - 1.0D) * SPAWN_OFFSET,
SPAWN_HEIGHT + i * 1.5D,
(level.random.nextDouble() * 2.0D - 1.0D) * SPAWN_OFFSET
);
Vec3 hitPos = targetPos.add(
(level.random.nextDouble() * 2.0D - 1.0D) * HIT_OFFSET,
0.0D,
(level.random.nextDouble() * 2.0D - 1.0D) * HIT_OFFSET
);
Vec3 direction = hitPos.subtract(spawnPos).normalize();
summon.setPos(spawnPos);
float[] xyRot = MathUtil.computeXYRot(direction.toVector3f());
summon.setXRot(xyRot[0]);
summon.setYRot(xyRot[1]);
summon.xRotO = summon.getXRot();
summon.yRotO = summon.getYRot();
level.addFreshEntity(summon);
}
}
}
@@ -1,71 +1,61 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
public class Boomstick extends Gun {
public static final String ID = "boomstick";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.05f, 1.5f);
public static final float DAMAGE_DEFAULT = 2.0f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final int PROJECTILE_COUNT = 3;
public static final float MAX_SPREAD_DEGREES = 8.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public Boomstick() {
super(Tiers.IRON, new Item.Properties().stacksTo(1), ID, OFFSET, DAMAGE_DEFAULT, 40, ModSounds.SHOT5, 1.0f, 10);
super(Tiers.IRON, new Item.Properties().stacksTo(1));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 40;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT5.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 1.25f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT5.get());
if(level.isClientSide()) return;
float spreadDegrees = getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
for(int i = 0; i < PROJECTILE_COUNT; i++) {
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
applySpread(player, summon, spreadDegrees);
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 1.25f);
customData.putInt("invulnerableTime", 10);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
level.addFreshEntity(summon);
}
protected int getProjectileCount(ItemStack stack, Player player) {
return PROJECTILE_COUNT;
}
private static void applySpread(Player player, StaticSummon summon, float spreadDegrees) {
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Vec3 forward = MathUtil.toVec3(dirs[0]).normalize();
Vec3 up = MathUtil.toVec3(dirs[1]).normalize();
Vec3 right = MathUtil.toVec3(dirs[2]).normalize();
double yaw = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
double pitch = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
Vec3 spreadDir = forward
.add(right.scale(Math.tan(yaw)))
.add(up.scale(Math.tan(pitch)))
.normalize();
float[] xyRot = MathUtil.computeXYRot(spreadDir.toVector3f());
summon.setXRot(xyRot[0]);
summon.xRotO = xyRot[0];
summon.setYRot(xyRot[1]);
summon.yRotO = xyRot[1];
@Override
protected float getSpreadDegrees(ItemStack stack, Player player, int index) {
return getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
}
}
@@ -1,67 +1,62 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.Item;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
public class ChainGun extends Gun {
public static final String ID = "chain_gun";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.1f, 1.5f);
public static final float DAMAGE_DEFAULT = 6.0f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final float AMMO_NOT_CONSUME_CHANCE = 0.67f;
public static final float MAX_SPREAD_DEGREES = 15.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public ChainGun() {
super(Tiers.NETHERITE, new Item.Properties().stacksTo(1).rarity(Rarity.RARE), ID, OFFSET, DAMAGE_DEFAULT, 4, ModSounds.SHOT6, 0.1f, 4);
super(Tiers.NETHERITE, new Item.Properties().stacksTo(1).rarity(Rarity.RARE));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 4;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT6.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.1f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 4;
}
@Override
public int getAmmoConsumeAmount(ItemStack weaponStack, LivingEntity entity) {
return entity.getRandom().nextFloat() < AMMO_NOT_CONSUME_CHANCE ? 0 : 1;
protected float getAmmoNotConsumeChance(ItemStack stack, LivingEntity entity) {
return AMMO_NOT_CONSUME_CHANCE;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT6.get());
if(level.isClientSide()) return;
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Vec3 forward = MathUtil.toVec3(dirs[0]).normalize();
Vec3 up = MathUtil.toVec3(dirs[1]).normalize();
Vec3 right = MathUtil.toVec3(dirs[2]).normalize();
float spreadDegrees = getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
double yaw = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
double pitch = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
Vec3 spreadDir = forward.add(right.scale(Math.tan(yaw))).add(up.scale(Math.tan(pitch))).normalize();
float[] xyRot = MathUtil.computeXYRot(spreadDir.toVector3f());
summon.setXRot(xyRot[0]);
summon.xRotO = xyRot[0];
summon.setYRot(xyRot[1]);
summon.yRotO = xyRot[1];
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 0.1f);
customData.putInt("invulnerableTime", 4);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
level.addFreshEntity(summon);
protected float getSpreadDegrees(ItemStack stack, Player player, int index) {
return getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
}
}
@@ -4,52 +4,70 @@ import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
public class ClockworkAssaultRifle extends Gun {
public static final String ID = "clockwork_assault_rifle";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.15f, 1.5f);
public static final float DAMAGE_DEFAULT = 2.4f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final int PROJECTILE_COUNT = 3;
public static final double PROJECTILE_OFFSET = -1.0;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public ClockworkAssaultRifle() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.COMMON), ID, OFFSET, DAMAGE_DEFAULT, 24, ModSounds.SHOT7, 0.2f, 5);
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.COMMON));
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT7.get());
if(level.isClientSide()) return;
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Vec3 dir = MathUtil.toVec3(dirs[0]);
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
for(int i = 0;i < PROJECTILE_COUNT;i++) {
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 0.2f);
customData.putInt("invulnerableTime", 5);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 24;
}
Vec3 pos = summon.position();
summon.setPos(pos.add(dir.scale(PROJECTILE_OFFSET * i)));
level.addFreshEntity(summon);
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT7.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.2f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 5;
}
@Override
protected int getProjectileCount(ItemStack stack, Player player) {
return PROJECTILE_COUNT;
}
@Override
protected void postprocessBulletSummon(Level level, Player player, InteractionHand hand, ItemStack weaponStack,
StaticSummon summon, int index) {
summon.setPos(summon.position().add(player.getLookAngle().normalize().scale(PROJECTILE_OFFSET * index)));
}
}
@@ -1,20 +1,48 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class FlintlockPistol extends Gun {
public static final String ID = "flintlock_pistol";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.05f, 1.5f);
public static final float DAMAGE_DEFAULT = 2.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public FlintlockPistol() {
super(Tiers.IRON, new Item.Properties().stacksTo(1), ID, OFFSET, DAMAGE_DEFAULT, 16, ModSounds.SHOT4, 0.25f, 10);
super(Tiers.IRON, new Item.Properties().stacksTo(1));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 16;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT4.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.25f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
}
@@ -1,67 +1,69 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.InteractionHand;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
public class Gatligator extends Gun {
public static final String ID = "gatligator";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.1f, 1.5f);
public static final float DAMAGE_DEFAULT = 2.4f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final float AMMO_NOT_CONSUME_CHANCE = 0.5f;
public static final float MAX_SPREAD_DEGREES = 10.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public Gatligator() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON), ID, OFFSET, DAMAGE_DEFAULT, 7, ModSounds.SHOT6, 0.1f, 5);
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON));
}
@Override
public int getAmmoConsumeAmount(ItemStack weaponStack, LivingEntity entity) {
return entity.getRandom().nextFloat() < AMMO_NOT_CONSUME_CHANCE ? 0 : 1;
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT6.get());
if(level.isClientSide()) return;
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Vec3 forward = MathUtil.toVec3(dirs[0]).normalize();
Vec3 up = MathUtil.toVec3(dirs[1]).normalize();
Vec3 right = MathUtil.toVec3(dirs[2]).normalize();
float spreadDegrees = getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
double yaw = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
double pitch = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
Vec3 spreadDir = forward.add(right.scale(Math.tan(yaw))).add(up.scale(Math.tan(pitch))).normalize();
float[] xyRot = MathUtil.computeXYRot(spreadDir.toVector3f());
summon.setXRot(xyRot[0]);
summon.xRotO = xyRot[0];
summon.setYRot(xyRot[1]);
summon.yRotO = xyRot[1];
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 7;
}
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 0.1f);
customData.putInt("invulnerableTime", 5);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
level.addFreshEntity(summon);
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT6.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.1f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 5;
}
@Override
protected float getAmmoNotConsumeChance(ItemStack stack, LivingEntity entity) {
return AMMO_NOT_CONSUME_CHANCE;
}
@Override
protected float getSpreadDegrees(ItemStack stack, Player player, int index) {
return getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
}
}
@@ -1,6 +1,7 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.enchantment.ModEnchantmentConfigs;
import com.lzxnone.terraria.enchantment.ModEnchantments;
import com.lzxnone.terraria.entity.summon.StaticSummon;
@@ -11,7 +12,9 @@ import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
@@ -19,12 +22,15 @@ import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tier;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
import java.util.function.Supplier;
import java.util.List;
public class Gun extends RangedWeapon {
private static final float DAMAGE_MIN = 0.0f;
@@ -34,61 +40,30 @@ public class Gun extends RangedWeapon {
public static final double SPRINT_SPREAD_MULTIPLIER = 2.0D;
public static final double WALK_SPREAD_MULTIPLIER = 1.5D;
public static final double CROUCH_SPREAD_MULTIPLIER = 0.5D;
public static final Vector3f DEFAULT_OFFSET = new Vector3f(-0.3f, -0.15f, 1.5f);
private final String id;
private final Vector3f offset;
private final ConfigFloat damage;
private final boolean hasAmmoNotConsumeChance;
private final ConfigFloat ammoNotConsumeChance;
private final int useTime;
private final Supplier<SoundEvent> sound;
private final float knockbackScale;
private final int invulnerableTime;
public Gun(Tier tier, Properties properties, String id, Vector3f offset, float damageDefault, int useTime,
Supplier<SoundEvent> sound, float knockbackScale, int invulnerableTime) {
this(tier, properties, id, offset, damageDefault, false, 0.0f, useTime, sound, knockbackScale, invulnerableTime);
}
public Gun(Tier tier, Properties properties, String id, Vector3f offset, float damageDefault, float ammoNotConsumeChanceDefault,
int useTime, Supplier<SoundEvent> sound, float knockbackScale, int invulnerableTime) {
this(tier, properties, id, offset, damageDefault, true, ammoNotConsumeChanceDefault, useTime, sound, knockbackScale, invulnerableTime);
}
private Gun(Tier tier, Properties properties, String id, Vector3f offset, float damageDefault, boolean hasAmmoNotConsumeChance,
float ammoNotConsumeChanceDefault, int useTime, Supplier<SoundEvent> sound,
float knockbackScale, int invulnerableTime) {
public Gun(Tier tier, Properties properties) {
super(tier, properties);
this.id = id;
this.offset = offset;
this.damage = createDamageConfig(id, damageDefault);
this.hasAmmoNotConsumeChance = hasAmmoNotConsumeChance;
this.ammoNotConsumeChance = createAmmoNotConsumeChanceConfig(id, ammoNotConsumeChanceDefault);
this.useTime = useTime;
this.sound = sound;
this.knockbackScale = knockbackScale;
this.invulnerableTime = invulnerableTime;
}
public static IConfigData createConfigData(ConfigStruct... configs) {
return new IConfigData() {
@Override
public void onConfigLoad() {
ConfigStruct.loadAll(configs);
}
};
}
public static IConfigData createConfigData(String id, float damageDefault) {
return new IConfigData() {
@Override
public void onConfigLoad() {
createDamageConfig(id, damageDefault).load();
}
};
return createConfigData(createDamageConfig(id, damageDefault));
}
public static IConfigData createConfigData(String id, float damageDefault, float ammoNotConsumeChanceDefault) {
return new IConfigData() {
@Override
public void onConfigLoad() {
ConfigStruct.loadAll(
createAmmoNotConsumeChanceConfig(id, ammoNotConsumeChanceDefault),
createDamageConfig(id, damageDefault)
);
}
};
return createConfigData(
createDamageConfig(id, damageDefault),
createAmmoNotConsumeChanceConfig(id, ammoNotConsumeChanceDefault)
);
}
public static ConfigFloat createDamageConfig(String id, float damageDefault) {
@@ -116,15 +91,6 @@ public class Gun extends RangedWeapon {
return "weapon." + id + ".ammo_not_consume_chance";
}
public float getDamage() {
return damage.get();
}
public float getAmmoNotConsumeChance() {
if(!hasAmmoNotConsumeChance) return 0.0f;
return ammoNotConsumeChance.get();
}
@Override
public boolean canUseAmmo(ItemStack weaponStack, ItemStack ammoStack) {
return ammoStack.is(ModItemTags.BULLET_AMMO);
@@ -137,13 +103,54 @@ public class Gun extends RangedWeapon {
@Override
public int getUseTime(ItemStack weaponStack, LivingEntity entity) {
return useTime;
return 20;
}
@Override
public int getAmmoConsumeAmount(ItemStack weaponStack, LivingEntity entity) {
if(!hasAmmoNotConsumeChance) return super.getAmmoConsumeAmount(weaponStack, entity);
return entity.getRandom().nextFloat() < getAmmoNotConsumeChance() ? 0 : 1;
float chance = getAmmoNotConsumeChance(weaponStack, entity);
if(chance <= 0.0f) return super.getAmmoConsumeAmount(weaponStack, entity);
return entity.getRandom().nextFloat() < chance ? 0 : 1;
}
protected float getDamage(ItemStack stack, Player player) {
return 0.0f;
}
protected float getAmmoNotConsumeChance(ItemStack stack, LivingEntity entity) {
return 0.0f;
}
protected Vector3f getOffset(ItemStack stack, Player player) {
return DEFAULT_OFFSET;
}
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT.get();
}
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.1f;
}
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
protected int getProjectileCount(ItemStack stack, Player player) {
return 1;
}
protected float getSpreadDegrees(ItemStack stack, Player player, int index) {
return 0.0f;
}
protected ItemStack getBulletAmmoStack(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {
return getAmmoStack(weaponStack);
}
protected void postprocessBulletSummon(Level level, Player player, InteractionHand hand, ItemStack weaponStack,
StaticSummon summon, int index) {
}
protected float getFinalSpreadDegrees(float baseSpread, ItemStack weaponStack, Player player) {
@@ -164,17 +171,64 @@ public class Gun extends RangedWeapon {
return (float) spread;
}
protected void applySpread(Player player, StaticSummon summon, float spreadDegrees) {
if(spreadDegrees <= 0.0f) return;
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Vec3 forward = MathUtil.toVec3(dirs[0]).normalize();
Vec3 up = MathUtil.toVec3(dirs[1]).normalize();
Vec3 right = MathUtil.toVec3(dirs[2]).normalize();
double yaw = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
double pitch = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
Vec3 spreadDir = forward
.add(right.scale(Math.tan(yaw)))
.add(up.scale(Math.tan(pitch)))
.normalize();
float[] xyRot = MathUtil.computeXYRot(spreadDir.toVector3f());
summon.setXRot(xyRot[0]);
summon.xRotO = xyRot[0];
summon.setYRot(xyRot[1]);
summon.yRotO = xyRot[1];
}
protected StaticSummon createBulletSummon(Level level, Player player, InteractionHand hand, ItemStack stack, int index) {
ItemStack ammoStack = getBulletAmmoStack(level, player, hand, stack);
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, ammoStack, getOffset(stack, player));
applySpread(player, summon, getSpreadDegrees(stack, player, index));
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage(stack, player));
customData.putFloat("knockbackScale", getKnockbackScale(stack, player));
customData.putInt("invulnerableTime", getInvulnerableTime(stack, player));
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
postprocessBulletSummon(level, player, hand, stack, summon, index);
return summon;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, sound.get());
if(!level.isClientSide()) {
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, offset);
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", knockbackScale);
customData.putInt("invulnerableTime", invulnerableTime);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
SoundUtil.playClientSound(player, getShootSound(stack, player));
if(level.isClientSide()) return;
int projectileCount = getProjectileCount(stack, player);
for(int i = 0; i < projectileCount; i++) {
StaticSummon summon = createBulletSummon(level, player, hand, stack, i);
level.addFreshEntity(summon);
}
}
@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context,
List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
if(stack.is(ModItemTags.SPREAD_RANGED_WEAPONS)) {
tooltipComponents.add(Component.translatable(
"tooltip.lzxnoneterraria.spread_ranged_weapon"
).withStyle(ChatFormatting.GRAY));
}
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
}
}
@@ -1,20 +1,48 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class Handgun extends Gun {
public static final String ID = "handgun";
public static final Vector3f OFFSET = new Vector3f(-0.3f, 0, 1.5f);
public static final float DAMAGE_DEFAULT = 4.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public Handgun() {
super(Tiers.IRON, new Item.Properties().stacksTo(1), ID, OFFSET, DAMAGE_DEFAULT, 15, ModSounds.SHOT6, 0.25f, 10);
super(Tiers.IRON, new Item.Properties().stacksTo(1));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 15;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT6.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.25f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
}
@@ -1,22 +1,56 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class Megashark extends Gun {
public static final String ID = "megashark";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.15f, 1.5f);
public static final float DAMAGE_DEFAULT = 3.0f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final float AMMO_NOT_CONSUME_CHANCE_DEFAULT = 0.5f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT, AMMO_NOT_CONSUME_CHANCE_DEFAULT);
public static final ConfigFloat AMMO_NOT_CONSUME_CHANCE = createAmmoNotConsumeChanceConfig(ID, AMMO_NOT_CONSUME_CHANCE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE, AMMO_NOT_CONSUME_CHANCE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public Megashark() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON), ID, OFFSET, DAMAGE_DEFAULT, AMMO_NOT_CONSUME_CHANCE_DEFAULT, 7, ModSounds.SHOT2, 0.1f, 5);
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 7;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT2.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.1f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 5;
}
@Override
protected float getAmmoNotConsumeChance(ItemStack stack, LivingEntity entity) {
return AMMO_NOT_CONSUME_CHANCE.get();
}
}
@@ -1,22 +1,56 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class Minishark extends Gun {
public static final String ID = "minishark";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.15f, 1.5f);
public static final float DAMAGE_DEFAULT = 1.0f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final float AMMO_NOT_CONSUME_CHANCE_DEFAULT = 0.33f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT, AMMO_NOT_CONSUME_CHANCE_DEFAULT);
public static final ConfigFloat AMMO_NOT_CONSUME_CHANCE = createAmmoNotConsumeChanceConfig(ID, AMMO_NOT_CONSUME_CHANCE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE, AMMO_NOT_CONSUME_CHANCE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public Minishark() {
super(Tiers.IRON, new Item.Properties().stacksTo(1).rarity(Rarity.COMMON), ID, OFFSET, DAMAGE_DEFAULT, AMMO_NOT_CONSUME_CHANCE_DEFAULT, 8, ModSounds.SHOT2, 0.1f, 5);
super(Tiers.IRON, new Item.Properties().stacksTo(1).rarity(Rarity.COMMON));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 8;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT2.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.1f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 5;
}
@Override
protected float getAmmoNotConsumeChance(ItemStack stack, LivingEntity entity) {
return AMMO_NOT_CONSUME_CHANCE.get();
}
}
@@ -1,20 +1,48 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class Musket extends Gun {
public static final String ID = "musket";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.1f, 1.5f);
public static final float DAMAGE_DEFAULT = 3.5f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public Musket() {
super(Tiers.IRON, new Item.Properties().stacksTo(1), ID, OFFSET, DAMAGE_DEFAULT, 32, ModSounds.SHOT3, 1.0f, 10);
super(Tiers.IRON, new Item.Properties().stacksTo(1));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 32;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT3.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 1.0f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
}
@@ -1,20 +1,48 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class PhoenixBlaster extends Gun {
public static final String ID = "phoenix_blaster";
public static final Vector3f OFFSET = new Vector3f(-0.3f, 0, 1.5f);
public static final float DAMAGE_DEFAULT = 5.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public PhoenixBlaster() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1), ID, OFFSET, DAMAGE_DEFAULT, 14, ModSounds.SHOT6, 0.25f, 10);
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 14;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT6.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.25f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
}
@@ -1,71 +1,61 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
public class QuadBarrelShotgun extends Gun {
public static final String ID = "quad_barrel_shotgun";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.1f, 1.5f);
public static final float DAMAGE_DEFAULT = 2.5f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final int PROJECTILE_COUNT = 4;
public static final float MAX_SPREAD_DEGREES = 12.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public QuadBarrelShotgun() {
super(Tiers.IRON, new Item.Properties().stacksTo(1), ID, OFFSET, DAMAGE_DEFAULT, 55, ModSounds.SHOT5, 1.5f, 10);
super(Tiers.IRON, new Item.Properties().stacksTo(1));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 55;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT5.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 1.4f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT5.get());
if(level.isClientSide()) return;
float spreadDegrees = getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
for(int i = 0; i < PROJECTILE_COUNT; i++) {
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
applySpread(player, summon, spreadDegrees);
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 1.4f);
customData.putInt("invulnerableTime", 10);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
level.addFreshEntity(summon);
}
protected int getProjectileCount(ItemStack stack, Player player) {
return PROJECTILE_COUNT;
}
private static void applySpread(Player player, StaticSummon summon, float spreadDegrees) {
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Vec3 forward = MathUtil.toVec3(dirs[0]).normalize();
Vec3 up = MathUtil.toVec3(dirs[1]).normalize();
Vec3 right = MathUtil.toVec3(dirs[2]).normalize();
double yaw = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
double pitch = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
Vec3 spreadDir = forward
.add(right.scale(Math.tan(yaw)))
.add(up.scale(Math.tan(pitch)))
.normalize();
float[] xyRot = MathUtil.computeXYRot(spreadDir.toVector3f());
summon.setXRot(xyRot[0]);
summon.xRotO = xyRot[0];
summon.setYRot(xyRot[1]);
summon.yRotO = xyRot[1];
@Override
protected float getSpreadDegrees(ItemStack stack, Player player, int index) {
return getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
}
}
@@ -1,20 +1,48 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class RedRyder extends Gun {
public static final String ID = "red_ryder";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.1f, 1.5f);
public static final float DAMAGE_DEFAULT = 3.5f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.15f, 1.5f);
public static final float DAMAGE_DEFAULT = 1.5f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public RedRyder() {
super(Tiers.IRON, new Item.Properties().stacksTo(1), ID, OFFSET, DAMAGE_DEFAULT, 38, ModSounds.SHOT2, 1.0f, 10);
super(Tiers.IRON, new Item.Properties().stacksTo(1));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 38;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT2.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 1.0f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
}
@@ -1,20 +1,48 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class Revolver extends Gun {
public static final String ID = "revolver";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.05f, 1.5f);
public static final float DAMAGE_DEFAULT = 2.5f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final Vector3f OFFSET = new Vector3f(-0.3f, 0, 1.5f);
public static final float DAMAGE_DEFAULT = 4.0f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public Revolver() {
super(Tiers.IRON, new Item.Properties().stacksTo(1), ID, OFFSET, DAMAGE_DEFAULT, 22, ModSounds.SHOT6, 0.8f, 10);
super(Tiers.IRON, new Item.Properties().stacksTo(1));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 22;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT6.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.8f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
}
@@ -1,22 +1,56 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class SDMG extends Gun {
public static final String ID = "sdmg";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.15f, 1.5f);
public static final float DAMAGE_DEFAULT = 10.0f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final float AMMO_NOT_CONSUME_CHANCE_DEFAULT = 0.66f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT, AMMO_NOT_CONSUME_CHANCE_DEFAULT);
public static final ConfigFloat AMMO_NOT_CONSUME_CHANCE = createAmmoNotConsumeChanceConfig(ID, AMMO_NOT_CONSUME_CHANCE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE, AMMO_NOT_CONSUME_CHANCE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public SDMG() {
super(Tiers.NETHERITE, new Item.Properties().stacksTo(1).fireResistant().rarity(Rarity.EPIC), ID, OFFSET, DAMAGE_DEFAULT, AMMO_NOT_CONSUME_CHANCE_DEFAULT, 5, ModSounds.SHOT, 0.1f, 5);
super(Tiers.NETHERITE, new Item.Properties().stacksTo(1).fireResistant().rarity(Rarity.EPIC));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 5;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.1f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 5;
}
@Override
protected float getAmmoNotConsumeChance(ItemStack stack, LivingEntity entity) {
return AMMO_NOT_CONSUME_CHANCE.get();
}
}
@@ -1,65 +1,63 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
public class Shotgun extends Gun {
public static final String ID = "shotgun";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.05f, 1.5f);
public static final float DAMAGE_DEFAULT = 4.0f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final int MIN_PROJECTILE_COUNT = 4;
public static final int MAX_PROJECTILE_COUNT = 5;
public static final float MAX_SPREAD_DEGREES = 10.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public Shotgun() {
super(Tiers.IRON, new Item.Properties().stacksTo(1).rarity(Rarity.COMMON), ID, OFFSET, DAMAGE_DEFAULT, 45, ModSounds.SHOT5, 1.25f, 10);
super(Tiers.IRON, new Item.Properties().stacksTo(1).rarity(Rarity.COMMON));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 45;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT5.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 1.25f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT5.get());
if(level.isClientSide()) return;
int projectileCount = MIN_PROJECTILE_COUNT + player.getRandom().nextInt(MAX_PROJECTILE_COUNT - MIN_PROJECTILE_COUNT + 1);
float spreadDegrees = getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
for(int i = 0;i < projectileCount;i++) {
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Vec3 forward = MathUtil.toVec3(dirs[0]).normalize();
Vec3 up = MathUtil.toVec3(dirs[1]).normalize();
Vec3 right = MathUtil.toVec3(dirs[2]).normalize();
double yaw = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
double pitch = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
Vec3 spreadDir = forward.add(right.scale(Math.tan(yaw))).add(up.scale(Math.tan(pitch))).normalize();
float[] xyRot = MathUtil.computeXYRot(spreadDir.toVector3f());
summon.setXRot(xyRot[0]);
summon.xRotO = xyRot[0];
summon.setYRot(xyRot[1]);
summon.yRotO = xyRot[1];
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 1.25f);
customData.putInt("invulnerableTime", 10);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
level.addFreshEntity(summon);
}
protected int getProjectileCount(ItemStack stack, Player player) {
return MIN_PROJECTILE_COUNT + player.getRandom().nextInt(MAX_PROJECTILE_COUNT - MIN_PROJECTILE_COUNT + 1);
}
@Override
protected float getSpreadDegrees(ItemStack stack, Player player, int index) {
return getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
}
}
@@ -1,17 +1,16 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.item.weapon.RangedWeapon;
import com.lzxnone.terraria.item.effect.ScopeZoomModifier;
import com.lzxnone.terraria.item.weapon.RangedWeapon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import com.lzxnone.terraria.ui.config.struct.ConfigDouble;
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
@@ -19,13 +18,17 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.joml.Vector3f;
import java.util.List;
public class SniperRifle extends Gun implements ScopeZoomModifier {
public static final String ID = "sniper_rifle";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.1f, 1.5f);
public static final float DAMAGE_DEFAULT = 35.0f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final double MAX_ZOOM = 10.0D;
public static final ConfigDouble ZOOM_SCROLL_SPEED = new ConfigDouble(
@@ -36,19 +39,11 @@ public class SniperRifle extends Gun implements ScopeZoomModifier {
10.0D
);
public static final IConfigData CONFIG_DATA = new IConfigData() {
@Override
public void onConfigLoad() {
ConfigStruct.loadAll(
createDamageConfig(ID, DAMAGE_DEFAULT),
ZOOM_SCROLL_SPEED
);
}
};
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE, ZOOM_SCROLL_SPEED);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public SniperRifle() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON), ID, OFFSET, DAMAGE_DEFAULT, 36, ModSounds.SHOT, 2.0f, 20);
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON));
}
public static double getZoomScrollSpeed() {
@@ -61,21 +56,51 @@ public class SniperRifle extends Gun implements ScopeZoomModifier {
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT.get());
if(level.isClientSide()) return;
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
ItemStack ammoStack = RangedWeapon.getAmmoStack(stack);
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 36;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 2.0f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 20;
}
@Override
protected ItemStack getBulletAmmoStack(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {
ItemStack ammoStack = RangedWeapon.getAmmoStack(weaponStack);
if(ammoStack.is(ModItems.MUSKET_BALL.get()) || ammoStack.is(ModItems.TUNGSTEN_BULLET.get()) || ammoStack.is(ModItems.ENDLESS_MUSKET_POUCH.get())) {
AmmoUtil.setHighVelocityBullet(summon);
return ModItems.HIGH_VELOCITY_BULLET.get().getDefaultInstance();
}
return ammoStack;
}
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 2.0f);
customData.putInt("invulnerableTime", 20);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
level.addFreshEntity(summon);
@Override
public void appendHoverText(ItemStack stack, Item.TooltipContext context,
List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
tooltipComponents.add(Component.translatable(
"tooltip.lzxnoneterraria.sniper_rifle"
).withStyle(ChatFormatting.GRAY));
}
}
@@ -1,63 +1,62 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
public class TacticalShotgun extends Gun {
public static final String ID = "tactical_shotgun";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.1f, 1.5f);
public static final float DAMAGE_DEFAULT = 6.0f;
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final int PROJECTILE_COUNT = 6;
public static final float MAX_SPREAD_DEGREES = 8.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public TacticalShotgun() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON), ID, OFFSET, DAMAGE_DEFAULT, 34, ModSounds.SHOT8, 1.5f, 10);
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 34;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT8.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 1.5f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT8.get());
if(level.isClientSide()) return;
float spreadDegrees = getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
for(int i = 0;i < PROJECTILE_COUNT;i++) {
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Vec3 forward = MathUtil.toVec3(dirs[0]).normalize();
Vec3 up = MathUtil.toVec3(dirs[1]).normalize();
Vec3 right = MathUtil.toVec3(dirs[2]).normalize();
double yaw = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
double pitch = Math.toRadians((player.getRandom().nextFloat() * 2.0f - 1.0f) * spreadDegrees);
Vec3 spreadDir = forward.add(right.scale(Math.tan(yaw))).add(up.scale(Math.tan(pitch))).normalize();
float[] xyRot = MathUtil.computeXYRot(spreadDir.toVector3f());
summon.setXRot(xyRot[0]);
summon.xRotO = xyRot[0];
summon.setYRot(xyRot[1]);
summon.yRotO = xyRot[1];
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 1.5f);
customData.putInt("invulnerableTime", 10);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
level.addFreshEntity(summon);
}
protected int getProjectileCount(ItemStack stack, Player player) {
return PROJECTILE_COUNT;
}
@Override
protected float getSpreadDegrees(ItemStack stack, Player player, int index) {
return getFinalSpreadDegrees(MAX_SPREAD_DEGREES, stack, player);
}
}
@@ -1,20 +1,48 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Tiers;
import org.joml.Vector3f;
public class TheUndertaker extends Gun {
public static final String ID = "the_undertaker";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.05f, 1.5f);
public static final float DAMAGE_DEFAULT = 3.5f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public TheUndertaker() {
super(Tiers.IRON, new Item.Properties().stacksTo(1), ID, OFFSET, DAMAGE_DEFAULT, 20, ModSounds.SHOT2, 0.5f, 10);
super(Tiers.IRON, new Item.Properties().stacksTo(1));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 20;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT2.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.5f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 10;
}
}
@@ -1,15 +1,14 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.item.weapon.RangedWeapon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@@ -17,34 +16,48 @@ import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import org.joml.Vector3f;
public class Uzi extends Gun {
public static final String ID = "uzi";
public static final Vector3f OFFSET = new Vector3f(-0.3f, 0, 1.5f);
public static final float DAMAGE_DEFAULT = 3.5f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public Uzi() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON), ID, OFFSET, DAMAGE_DEFAULT, 9, ModSounds.SHOT2, 0.1f, 5);
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.UNCOMMON));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 9;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT2.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.1f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 5;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT2.get());
if(level.isClientSide()) return;
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
ItemStack ammoStack = RangedWeapon.getAmmoStack(stack);
protected ItemStack getBulletAmmoStack(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {
ItemStack ammoStack = RangedWeapon.getAmmoStack(weaponStack);
if(ammoStack.is(ModItems.MUSKET_BALL.get()) || ammoStack.is(ModItems.TUNGSTEN_BULLET.get()) || ammoStack.is(ModItems.ENDLESS_MUSKET_POUCH.get())) {
AmmoUtil.setHighVelocityBullet(summon);
return ModItems.HIGH_VELOCITY_BULLET.get().getDefaultInstance();
}
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 0.1f);
customData.putInt("invulnerableTime", 5);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
level.addFreshEntity(summon);
return ammoStack;
}
}
@@ -1,15 +1,14 @@
package com.lzxnone.terraria.item.weapon.ranged.gun;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.item.weapon.RangedWeapon;
import com.lzxnone.terraria.ui.config.ConfigListItem;
import com.lzxnone.terraria.ui.config.IConfigData;
import com.lzxnone.terraria.utils.AmmoUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import com.lzxnone.terraria.ui.config.struct.ConfigFloat;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@@ -17,34 +16,48 @@ import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.Tiers;
import net.minecraft.world.level.Level;
import org.joml.Vector3f;
public class VenusMagnum extends Gun {
public static final String ID = "venus_magnum";
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.05f, 1.5f);
public static final float DAMAGE_DEFAULT = 5.0f;
public static final IConfigData CONFIG_DATA = createConfigData(ID, DAMAGE_DEFAULT);
public static final ConfigFloat DAMAGE = createDamageConfig(ID, DAMAGE_DEFAULT);
public static final IConfigData CONFIG_DATA = createConfigData(DAMAGE);
public static final ConfigListItem CONFIG_LIST_ITEM = createConfigListItem(ID, CONFIG_DATA);
public VenusMagnum() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.RARE), ID, OFFSET, DAMAGE_DEFAULT, 9, ModSounds.SHOT6, 0.1f, 5);
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.RARE));
}
@Override
protected Vector3f getOffset(ItemStack stack, Player player) {
return OFFSET;
}
@Override
protected float getDamage(ItemStack stack, Player player) {
return DAMAGE.get();
}
@Override
public int getUseTime(ItemStack stack, LivingEntity entity) {
return 9;
}
@Override
protected SoundEvent getShootSound(ItemStack stack, Player player) {
return ModSounds.SHOT6.get();
}
@Override
protected float getKnockbackScale(ItemStack stack, Player player) {
return 0.1f;
}
@Override
protected int getInvulnerableTime(ItemStack stack, Player player) {
return 5;
}
@Override
protected void shoot(Level level, Player player, InteractionHand hand, ItemStack stack) {
SoundUtil.playClientSound(player, ModSounds.SHOT6.get());
if(level.isClientSide()) return;
StaticSummon summon = AmmoUtil.createAmmoSummon(level, player, hand, stack, OFFSET);
ItemStack ammoStack = RangedWeapon.getAmmoStack(stack);
protected ItemStack getBulletAmmoStack(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {
ItemStack ammoStack = RangedWeapon.getAmmoStack(weaponStack);
if(ammoStack.is(ModItems.MUSKET_BALL.get()) || ammoStack.is(ModItems.TUNGSTEN_BULLET.get()) || ammoStack.is(ModItems.ENDLESS_MUSKET_POUCH.get())) {
AmmoUtil.setHighVelocityBullet(summon);
return ModItems.HIGH_VELOCITY_BULLET.get().getDefaultInstance();
}
CompoundTag customData = summon.getEntityData().get(StaticSummon.CUSTOM_DATA);
customData.putFloat("damage", getDamage());
customData.putFloat("knockbackScale", 0.1f);
customData.putInt("invulnerableTime", 5);
summon.getEntityData().set(StaticSummon.CUSTOM_DATA, customData);
level.addFreshEntity(summon);
return ammoStack;
}
}
@@ -2,6 +2,7 @@ package com.lzxnone.terraria.mixin;
import com.lzxnone.terraria.client.config.RenderConfigs;
import com.lzxnone.terraria.item.weapon.RangedWeapon;
import com.lzxnone.terraria.item.weapon.ranged.bow.Bow;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.world.InteractionHand;
@@ -32,10 +33,12 @@ public abstract class HumanoidModelMixin<T extends LivingEntity> {
: player.getMainArm().getOpposite();
if(player.getUseItem().getItem() instanceof RangedWeapon) {
if(usedArm == HumanoidArm.RIGHT) {
this.rightArm.xRot = (float) Math.toRadians(player.getXRot() - 90);
}else {
this.leftArm.xRot = (float) Math.toRadians(player.getXRot() - 90);
if(!(player.getUseItem().getItem() instanceof Bow)) {
if(usedArm == HumanoidArm.RIGHT) {
this.rightArm.xRot = (float) Math.toRadians(player.getXRot() - 90);
}else {
this.leftArm.xRot = (float) Math.toRadians(player.getXRot() - 90);
}
}
}
}
@@ -121,6 +121,7 @@ import com.lzxnone.terraria.item.weapon.ranged.Flamethrower;
import com.lzxnone.terraria.item.weapon.ranged.SnowballCannon;
import com.lzxnone.terraria.item.weapon.ranged.StarCannon;
import com.lzxnone.terraria.item.weapon.ranged.SuperStarShooter;
import com.lzxnone.terraria.item.weapon.ranged.bow.DaedalusStormbow;
import com.lzxnone.terraria.item.weapon.ranged.gun.*;
import com.lzxnone.terraria.item.weapon.summon.minion.StardustDragonStaff;
import com.lzxnone.terraria.item.weapon.summon.minion.Terraprisma;
@@ -192,7 +193,8 @@ public class ConfigList {
StarCannon.CONFIG_LIST_ITEM,
SuperStarShooter.CONFIG_LIST_ITEM,
Flamethrower.CONFIG_LIST_ITEM,
ElfMelter.CONFIG_LIST_ITEM
ElfMelter.CONFIG_LIST_ITEM,
DaedalusStormbow.CONFIG_LIST_ITEM
});
ITEMS.put(EFFECT, new ConfigListItem[]{
BloodButcheredEffect.CONFIG_LIST_ITEM,
@@ -222,7 +224,8 @@ public class ConfigList {
ExplodingBullet.CONFIG_LIST_ITEM,
GoldenBullet.CONFIG_LIST_ITEM,
LuminiteBullet.CONFIG_LIST_ITEM,
TungstenBullet.CONFIG_LIST_ITEM
TungstenBullet.CONFIG_LIST_ITEM,
WoodenArrow.CONFIG_LIST_ITEM
});
ITEMS.put(ACCESSORY, new ConfigListItem[]{
NaturesGift.CONFIG_LIST_ITEM,
@@ -5,6 +5,7 @@ import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
import com.lzxnone.terraria.item.ModItems;
import com.lzxnone.terraria.item.weapon.RangedWeapon;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
@@ -19,6 +20,11 @@ public class AmmoUtil {
public static final Vector3f OFFSET = new Vector3f(-0.3f, -0.15f, 1.5f);
public static StaticSummon createAmmoSummon(Level level, Player player, InteractionHand hand, ItemStack stack, Vector3f offset) {
return createAmmoSummon(level, player, hand, stack, RangedWeapon.getAmmoStack(stack), offset);
}
public static StaticSummon createAmmoSummon(Level level, Player player, InteractionHand hand, ItemStack stack,
ItemStack ammoStack, Vector3f offset) {
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Vec3 eyePos = player.getEyePosition();
offset = getOffset(hand, offset);
@@ -40,7 +46,7 @@ public class AmmoUtil {
summon.yRotO = xyRot[1];
summon.noPhysics = true;
ResourceLocation ammoId = RangedWeapon.getAmmo(stack);
ResourceLocation ammoId = BuiltInRegistries.ITEM.getKey(ammoStack.getItem());
String ammo = ammoId == null ? "" : ammoId.toString();
if(ammo.equals("lzxnoneterraria:musket_ball")) setMusketBall(summon);
else if(ammo.equals("lzxnoneterraria:silver_bullet")) setSilverBullet(summon);
@@ -58,6 +64,7 @@ public class AmmoUtil {
else if(ammo.equals("lzxnoneterraria:luminite_bullet")) setLuminiteBullet(summon);
else if(ammo.equals("lzxnoneterraria:tungsten_bullet")) setTungstenBullet(summon);
else if(ammo.equals("lzxnoneterraria:meteor_shot")) setMeteorShot(summon);
else if(ammo.equals("lzxnoneterraria:wooden_arrow")) setWoodenArrow(summon);
else if(ammo.equals("minecraft:snowball")) setSnowball(summon);
else if(ammo.equals("lzxnoneterraria:fallen_star")) setFallenStar(summon);
else if(ammo.equals("minecraft:slime_ball")) setSlimeBall(summon);
@@ -253,6 +260,17 @@ public class AmmoUtil {
summon.setNoGravity(true);
}
public static void setWoodenArrow(StaticSummon summon) {
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.WOODEN_ARROW);
summon.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
summon.getEntityData().set(StaticSummon.ITEM, new ItemStack(ModItems.WOODEN_ARROW.get()));
summon.getEntityData().set(StaticSummon.LIFETIME, 100);
summon.getEntityData().set(StaticSummon.SCALE_X, 0.5f);
summon.getEntityData().set(StaticSummon.SCALE_Y, 1.0f);
summon.getEntityData().set(StaticSummon.SCALE_Z, 1.0f);
summon.setNoGravity(true);
}
public static void setSnowball(StaticSummon summon) {
summon.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.SNOWBALL);
summon.getEntityData().set(StaticSummon.RENDER_MODE, "item");
@@ -1,8 +1,6 @@
package com.lzxnone.terraria.utils;
import com.lzxnone.terraria.damage.ModDamageTypes;
import com.lzxnone.terraria.effect.IchorEffect;
import com.lzxnone.terraria.effect.ModEffects;
import com.lzxnone.terraria.entity.beam.SwordBeam;
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
import com.lzxnone.terraria.entity.summon.BeeSummon;
@@ -21,6 +19,7 @@ import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.phys.Vec3;
import java.util.Objects;
@@ -102,15 +101,13 @@ public class DamageUtil {
finalDamage = MagicWeapon.applyMagicDamageBonus(itemSource, player, finalDamage);
}else if(category == DamageCategory.RANGED && !itemSource.isEmpty()) {
finalDamage = RangedWeapon.applyRangedDamageBonus(itemSource, player, finalDamage);
knockbackLevel += Weapon.getEnchantmentLevel(player, itemSource, Enchantments.PUNCH);
}else if(category == DamageCategory.MINION && !itemSource.isEmpty()) {
finalDamage = SummonWeapon.applySummonDamageBonus(itemSource, player, finalDamage);
knockbackLevel = MinionWeapon.applyMinionKnockback(player, knockbackLevel);
}else if(category == DamageCategory.SENTRY && !itemSource.isEmpty()) {
finalDamage = SummonWeapon.applySummonDamageBonus(itemSource, player, finalDamage);
}
if(category != DamageCategory.REAL) {
finalDamage = applyTargetDamageEffects(target, finalDamage);
}
finalDamage = Math.max(0.0F, finalDamage);
//近战暴击(月光护身符等饰品的近战暴击率,触发后伤害提升 1.5 倍)
@@ -169,17 +166,6 @@ public class DamageUtil {
return Math.max(0.0F, finalDamage);
}
private static float applyTargetDamageEffects(Entity target, float damage) {
if(!(target instanceof LivingEntity livingTarget)) return damage;
float finalDamage = damage;
if(livingTarget.hasEffect(ModEffects.ICHOR) && livingTarget.getEffect(ModEffects.ICHOR) != null) {
int amplifier = Objects.requireNonNull(livingTarget.getEffect(ModEffects.ICHOR)).getAmplifier();
finalDamage *= 1.0f + IchorEffect.getDamageBonusPerLevel() * (amplifier + 1);
}
return Math.max(0.0F, finalDamage);
}
private static Player getAttackOwner(Entity attackEntity) {
if(attackEntity instanceof Player player) return player;
if(attackEntity instanceof StaticProjectile projectile) return getAttackOwner(projectile.getOwner());
@@ -68,7 +68,9 @@
"item.lzxnoneterraria.super_star_shooter": "Super Star Shooter",
"item.lzxnoneterraria.flamethrower": "Flamethrower",
"item.lzxnoneterraria.elf_melter": "Elf Melter",
"item.lzxnoneterraria.daedalus_stormbow": "Daedalus Stormbow",
"item.lzxnoneterraria.musket_ball": "Musket Ball",
"item.lzxnoneterraria.wooden_arrow": "Wooden Arrow",
"item.lzxnoneterraria.meteor_shot": "Meteor Shot",
"item.lzxnoneterraria.silver_bullet": "Silver Bullet",
"item.lzxnoneterraria.crystal_bullet": "Crystal Bullet",
@@ -290,7 +292,6 @@
"tooltip.lzxnoneterraria.mining_speed_bonus": "Mining Speed +%s%%",
"tooltip.lzxnoneterraria.move_speed_bonus": "Movement Speed +%s%%",
"tooltip.lzxnoneterraria.water_breathing": "Breathe underwater",
"tooltip.lzxnoneterraria.rifle_scope": "Scroll wheel adjusts zoom while using firearms",
"tooltip.lzxnoneterraria.jump_boost": "Slightly increases jump height and speed",
"tooltip.lzxnoneterraria.knockback_resistance_bonus": "Knockback Resistance +%s%%",
"tooltip.lzxnoneterraria.defense_bonus": "Defense +%s",
@@ -356,6 +357,9 @@
"tooltip.lzxnoneterraria.ranged_damage_increase": "+%s%% ranged damage",
"tooltip.lzxnoneterraria.ranged_damage_decrease": "-%s%% ranged damage",
"tooltip.lzxnoneterraria.rifle_scope": "Scroll wheel adjusts zoom while using firearms",
"tooltip.lzxnoneterraria.spread_ranged_weapon": "Standing still or sneaking reduces spread",
"tooltip.lzxnoneterraria.sniper_rifle": "Scroll wheel adjusts zoom",
"lzxnoneterraria.configuration.ranged_damage_multiplier": "Ranged Damage Multiplier",
"lzxnoneterraria.configuration.ranged_damage_multiplier.tooltip": "Ranged damage is multiplied by this value while equipped",
@@ -438,6 +442,7 @@
"jei.lzxnoneterraria.info.summoner_emblem": "Obtained by defeating the Wither.",
"jei.lzxnoneterraria.info.ranger_emblem": "Obtained by defeating the Wither.",
"jei.lzxnoneterraria.info.sorcerer_emblem": "Obtained by defeating the Wither.",
"jei.lzxnoneterraria.info.daedalus_stormbow": "Can be obtained by defeating the Ender Dragon.",
"entity.lzxnoneterraria.static_projectile": "Projectile",
"entity.lzxnoneterraria.static_summon": "Summon",
@@ -516,8 +521,8 @@
"lzxnoneterraria.configuration.demonic_flames_damage_per_level.tooltip": "Damage dealt per effect level",
"lzxnoneterraria.configuration.cursed_inferno_damage_per_level": "Damage Per Level",
"lzxnoneterraria.configuration.cursed_inferno_damage_per_level.tooltip": "Cursed Inferno checks damage once per second; damage dealt per effect level",
"lzxnoneterraria.configuration.ichor_damage_bonus_per_level": "Damage Bonus Per Level",
"lzxnoneterraria.configuration.ichor_damage_bonus_per_level.tooltip": "Extra damage taken per Ichor level on the target; default 0.15 means 15%",
"lzxnoneterraria.configuration.ichor_armor_reduction_per_level": "Armor Reduction Per Level",
"lzxnoneterraria.configuration.ichor_armor_reduction_per_level.tooltip": "Armor reduced per Ichor level on the target",
"lzxnoneterraria.configuration.acid_venom_damage_per_level": "Damage Per Level",
"lzxnoneterraria.configuration.acid_venom_damage_per_level.tooltip": "Acid Venom checks damage once per second; damage dealt per effect level",
"lzxnoneterraria.configuration.midas_drop_chance": "Emerald Drop Chance",
@@ -914,6 +919,12 @@
"lzxnoneterraria.configuration.tungsten_bullet_base_damage.tooltip": "Base damage provided by the ammo",
"lzxnoneterraria.configuration.tungsten_bullet_speed": "Speed",
"lzxnoneterraria.configuration.tungsten_bullet_speed.tooltip": "Ammo movement speed per tick",
"lzxnoneterraria.configuration.wooden_arrow_base_damage": "Base Damage",
"lzxnoneterraria.configuration.wooden_arrow_base_damage.tooltip": "Base damage provided by the ammo",
"lzxnoneterraria.configuration.wooden_arrow_speed": "Speed",
"lzxnoneterraria.configuration.wooden_arrow_speed.tooltip": "Ammo movement speed per tick",
"lzxnoneterraria.configuration.wooden_arrow_gravity": "Gravity",
"lzxnoneterraria.configuration.wooden_arrow_gravity.tooltip": "Downward acceleration applied each tick",
"lzxnoneterraria.configuration.luminite_bullet_base_damage": "Base Damage",
"lzxnoneterraria.configuration.luminite_bullet_base_damage.tooltip": "Base damage provided by the ammo",
"lzxnoneterraria.configuration.luminite_bullet_speed": "Speed",
@@ -1002,6 +1013,8 @@
"lzxnoneterraria.configuration.elf_melter_range.tooltip": "Frost stream travel range",
"lzxnoneterraria.configuration.elf_melter_freeze_ticks": "Freeze Duration",
"lzxnoneterraria.configuration.elf_melter_freeze_ticks.tooltip": "Frozen time applied on hit, in ticks",
"lzxnoneterraria.configuration.daedalus_stormbow_damage": "Damage",
"lzxnoneterraria.configuration.daedalus_stormbow_damage.tooltip": "Damage per hit",
"lzxnoneterraria.configuration.devils_devastation_kill_mode_time": "Kill Mode Duration",
"lzxnoneterraria.configuration.devils_devastation_kill_mode_time.tooltip": "Kill Mode duration in ticks",
"lzxnoneterraria.configuration.devils_devastation_kill_mode_cooldown_time": "Kill Mode Cooldown",
@@ -68,7 +68,9 @@
"item.lzxnoneterraria.super_star_shooter": "超级星星炮",
"item.lzxnoneterraria.flamethrower": "火焰喷射器",
"item.lzxnoneterraria.elf_melter": "精灵熔枪",
"item.lzxnoneterraria.daedalus_stormbow": "代达罗斯风暴弓",
"item.lzxnoneterraria.musket_ball": "火枪子弹",
"item.lzxnoneterraria.wooden_arrow": "木箭",
"item.lzxnoneterraria.meteor_shot": "流星弹",
"item.lzxnoneterraria.silver_bullet": "银子弹",
"item.lzxnoneterraria.crystal_bullet": "水晶子弹",
@@ -290,7 +292,6 @@
"tooltip.lzxnoneterraria.mining_speed_bonus": "挖掘速度 +%s%%",
"tooltip.lzxnoneterraria.move_speed_bonus": "移动速度 +%s%%",
"tooltip.lzxnoneterraria.water_breathing": "水下呼吸",
"tooltip.lzxnoneterraria.rifle_scope": "使用枪械时,滚轮可以调节放大倍率",
"tooltip.lzxnoneterraria.jump_boost": "略微增加跳跃高度和跳跃速度",
"tooltip.lzxnoneterraria.knockback_resistance_bonus": "抗性击退 +%s%%",
"tooltip.lzxnoneterraria.defense_bonus": "护甲值 +%s",
@@ -356,6 +357,9 @@
"tooltip.lzxnoneterraria.ranged_damage_increase": "远程伤害 +%s%%",
"tooltip.lzxnoneterraria.ranged_damage_decrease": "远程伤害 -%s%%",
"tooltip.lzxnoneterraria.rifle_scope": "使用枪械时,滚轮可以调节放大倍率",
"tooltip.lzxnoneterraria.spread_ranged_weapon": "静止或者潜行可以减低散射幅度",
"tooltip.lzxnoneterraria.sniper_rifle": "滚轮可以调节放大倍率",
"lzxnoneterraria.configuration.ranged_damage_multiplier": "远程伤害倍率",
"lzxnoneterraria.configuration.ranged_damage_multiplier.tooltip": "佩戴后远程伤害乘以该倍率",
@@ -438,6 +442,7 @@
"jei.lzxnoneterraria.info.summoner_emblem": "通过击杀凋零获取。",
"jei.lzxnoneterraria.info.ranger_emblem": "通过击杀凋零获取。",
"jei.lzxnoneterraria.info.sorcerer_emblem": "通过击杀凋零获取。",
"jei.lzxnoneterraria.info.daedalus_stormbow": "可以通过击杀末影龙获得。",
"entity.lzxnoneterraria.static_projectile": "弹射物",
"entity.lzxnoneterraria.static_summon": "召唤物",
@@ -516,8 +521,8 @@
"lzxnoneterraria.configuration.demonic_flames_damage_per_level.tooltip": "每级造成的伤害",
"lzxnoneterraria.configuration.cursed_inferno_damage_per_level": "每级伤害",
"lzxnoneterraria.configuration.cursed_inferno_damage_per_level.tooltip": "诅咒狱火每秒进行一次伤害判定,每级造成的伤害",
"lzxnoneterraria.configuration.ichor_damage_bonus_per_level": "每级增伤",
"lzxnoneterraria.configuration.ichor_damage_bonus_per_level.tooltip": "目标拥有灵液效果时,每级额外受到的伤害比例,默认 0.15 表示 15%",
"lzxnoneterraria.configuration.ichor_armor_reduction_per_level": "每级护甲降低",
"lzxnoneterraria.configuration.ichor_armor_reduction_per_level.tooltip": "目标拥有灵液效果时,每级降低的护甲值",
"lzxnoneterraria.configuration.acid_venom_damage_per_level": "每级伤害",
"lzxnoneterraria.configuration.acid_venom_damage_per_level.tooltip": "酸性毒液每秒进行一次伤害判定,每级造成的伤害",
"lzxnoneterraria.configuration.midas_drop_chance": "绿宝石掉落概率",
@@ -914,6 +919,12 @@
"lzxnoneterraria.configuration.tungsten_bullet_base_damage.tooltip": "子弹自身提供的基础伤害",
"lzxnoneterraria.configuration.tungsten_bullet_speed": "速度",
"lzxnoneterraria.configuration.tungsten_bullet_speed.tooltip": "子弹每刻移动速度",
"lzxnoneterraria.configuration.wooden_arrow_base_damage": "基础伤害",
"lzxnoneterraria.configuration.wooden_arrow_base_damage.tooltip": "弹药自身提供的基础伤害",
"lzxnoneterraria.configuration.wooden_arrow_speed": "速度",
"lzxnoneterraria.configuration.wooden_arrow_speed.tooltip": "弹药每刻移动速度",
"lzxnoneterraria.configuration.wooden_arrow_gravity": "重力",
"lzxnoneterraria.configuration.wooden_arrow_gravity.tooltip": "每刻向下施加的加速度",
"lzxnoneterraria.configuration.luminite_bullet_base_damage": "基础伤害",
"lzxnoneterraria.configuration.luminite_bullet_base_damage.tooltip": "子弹自身提供的基础伤害",
"lzxnoneterraria.configuration.luminite_bullet_speed": "速度",
@@ -1002,6 +1013,8 @@
"lzxnoneterraria.configuration.elf_melter_range.tooltip": "冰霜流飞行距离",
"lzxnoneterraria.configuration.elf_melter_freeze_ticks": "冻结时间",
"lzxnoneterraria.configuration.elf_melter_freeze_ticks.tooltip": "命中后施加的冻结时间(刻)",
"lzxnoneterraria.configuration.daedalus_stormbow_damage": "伤害",
"lzxnoneterraria.configuration.daedalus_stormbow_damage.tooltip": "每次命中伤害",
"lzxnoneterraria.configuration.devils_devastation_kill_mode_time": "杀戮模式持续时间",
"lzxnoneterraria.configuration.devils_devastation_kill_mode_time.tooltip": "杀戮模式持续时间(刻)",
"lzxnoneterraria.configuration.devils_devastation_kill_mode_cooldown_time": "杀戮模式冷却时间",
@@ -0,0 +1,45 @@
{
"parent": "item/handheld",
"display": {
"gui": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.5, 1.0, 1.0 ]
},
"ground": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 2.0, 0 ],
"scale": [ 0.5, 1.0, 0.5 ]
},
"head": {
"rotation": [ 0, 180, 0 ],
"translation": [ 0, 13.0, 7.0 ],
"scale": [ 1, 2, 1 ]
},
"fixed": {
"rotation": [ 0, 180, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.5, 1, 1 ]
},
"thirdperson_righthand": {
"rotation": [0, 90, 0],
"translation": [0, 0, -1],
"scale": [0.85, 1.7, 0.85]
},
"thirdperson_lefthand": {
"rotation": [0, -90, 0],
"translation": [0, 0, -1],
"scale": [0.85, 1.7, 0.85]
},
"firstperson_righthand": {
"rotation": [0, 90, 0],
"translation": [1.13, 4.2, 0.0],
"scale": [0.68, 1.36, 0.68]
},
"firstperson_lefthand": {
"rotation": [0, -90, 0],
"translation": [1.13, 4.2, 0.0],
"scale": [0.68, 1.36, 0.68]
}
}
}
@@ -0,0 +1,6 @@
{
"parent": "lzxnoneterraria:item/bow",
"textures": {
"layer0": "lzxnoneterraria:item/daedalus_stormbow"
}
}
@@ -0,0 +1,6 @@
{
"parent": "lzxnoneterraria:item/item2",
"textures": {
"layer0": "lzxnoneterraria:item/wooden_arrow"
}
}
@@ -44,6 +44,9 @@
"whip": {
"sounds": ["lzxnoneterraria:whip"]
},
"bow_shoot": {
"sounds": ["lzxnoneterraria:bow_shoot"]
},
"shot": {
"sounds": ["lzxnoneterraria:shot"]
},
Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

@@ -12,10 +12,10 @@
"base": 1,
"per_level_above_first": 11
},
"primary_items": "#lzxnoneterraria:ranged_weapons",
"primary_items": "#lzxnoneterraria:gunpowder_weapons",
"slots": [
"mainhand"
],
"supported_items": "#lzxnoneterraria:ranged_weapons",
"supported_items": "#lzxnoneterraria:gunpowder_weapons",
"weight": 10
}
@@ -0,0 +1,10 @@
{
"type": "neoforge:add_table",
"conditions": [
{
"condition": "neoforge:loot_table_id",
"loot_table_id": "minecraft:entities/ender_dragon"
}
],
"table": "lzxnoneterraria:entities/ender_dragon"
}
@@ -0,0 +1,19 @@
{
"type": "minecraft:entity",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "lzxnoneterraria:daedalus_stormbow",
"weight": 33
},
{
"type": "minecraft:empty",
"weight": 67
}
]
}
]
}
@@ -0,0 +1,13 @@
{
"type": "minecraft:crafting_shapeless",
"category": "combat",
"ingredients": [
{
"item": "minecraft:arrow"
}
],
"result": {
"id": "lzxnoneterraria:wooden_arrow",
"count": 1
}
}
@@ -2,6 +2,7 @@
"replace": false,
"values": [
"#lzxnoneterraria:bullet_ammo",
"#lzxnoneterraria:arrow_ammo",
"lzxnoneterraria:fallen_star",
"minecraft:snowball",
"minecraft:slime_ball"
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"lzxnoneterraria:wooden_arrow"
]
}
@@ -0,0 +1,30 @@
{
"replace": false,
"values": [
"lzxnoneterraria:musket",
"lzxnoneterraria:minishark",
"lzxnoneterraria:flintlock_pistol",
"lzxnoneterraria:boomstick",
"lzxnoneterraria:revolver",
"lzxnoneterraria:red_ryder",
"lzxnoneterraria:the_undertaker",
"lzxnoneterraria:quad_barrel_shotgun",
"lzxnoneterraria:handgun",
"lzxnoneterraria:phoenix_blaster",
"lzxnoneterraria:megashark",
"lzxnoneterraria:clockwork_assault_rifle",
"lzxnoneterraria:gatligator",
"lzxnoneterraria:shotgun",
"lzxnoneterraria:uzi",
"lzxnoneterraria:venus_magnum",
"lzxnoneterraria:tactical_shotgun",
"lzxnoneterraria:sniper_rifle",
"lzxnoneterraria:chain_gun",
"lzxnoneterraria:sdmg",
"lzxnoneterraria:snowball_cannon",
"lzxnoneterraria:star_cannon",
"lzxnoneterraria:super_star_shooter",
"lzxnoneterraria:flamethrower",
"lzxnoneterraria:elf_melter"
]
}
@@ -25,6 +25,7 @@
"lzxnoneterraria:star_cannon",
"lzxnoneterraria:super_star_shooter",
"lzxnoneterraria:flamethrower",
"lzxnoneterraria:elf_melter"
"lzxnoneterraria:elf_melter",
"lzxnoneterraria:daedalus_stormbow"
]
}
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"lzxnoneterraria:daedalus_stormbow"
]
}
@@ -14,6 +14,7 @@
"lzxnoneterraria:chests/pillager_outpost",
"lzxnoneterraria:chests/trial_chambers",
"lzxnoneterraria:chests/trial_chambers_reward",
"lzxnoneterraria:entities/ender_dragon",
"lzxnoneterraria:entities/wither",
"lzxnoneterraria:entities/bee",
"lzxnoneterraria:entities/blaze",