This commit is contained in:
LZX committed 2026-09-03 22:23:30 +08:00
1 parent 15e24158e5
commit 8773e8d4a1
10 files changed
+193 -3

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. # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=All Rights Reserved mod_license=All Rights Reserved
# The mod version. See https://semver.org/ # The mod version. See https://semver.org/
mod_version=1.8.3 mod_version=1.9.0
## The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. ## 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. # This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html # See https://maven.apache.org/guides/mini/guide-naming-conventions.html
@@ -68,6 +68,7 @@ public class ModCreativeModeTabs {
output.accept(ModItems.RUBY_STAFF.get()); output.accept(ModItems.RUBY_STAFF.get());
output.accept(ModItems.AMBER_STAFF.get()); output.accept(ModItems.AMBER_STAFF.get());
output.accept(ModItems.DIAMOND_STAFF.get()); output.accept(ModItems.DIAMOND_STAFF.get());
output.accept(ModItems.BEJEWELED_STAFF.get());
output.accept(ModItems.ROBE.get()); output.accept(ModItems.ROBE.get());
output.accept(ModItems.AMETHYST_ROBE.get()); output.accept(ModItems.AMETHYST_ROBE.get());
output.accept(ModItems.TOPAZ_ROBE.get()); output.accept(ModItems.TOPAZ_ROBE.get());
@@ -72,6 +72,7 @@ public class ModItems {
public static final DeferredItem<Item> RUBY_STAFF = ITEMS.register("ruby_staff", RubyStaff::new); public static final DeferredItem<Item> RUBY_STAFF = ITEMS.register("ruby_staff", RubyStaff::new);
public static final DeferredItem<Item> AMBER_STAFF = ITEMS.register("amber_staff", AmberStaff::new); public static final DeferredItem<Item> AMBER_STAFF = ITEMS.register("amber_staff", AmberStaff::new);
public static final DeferredItem<Item> DIAMOND_STAFF = ITEMS.register("diamond_staff", DiamondStaff::new); public static final DeferredItem<Item> DIAMOND_STAFF = ITEMS.register("diamond_staff", DiamondStaff::new);
public static final DeferredItem<Item> BEJEWELED_STAFF = ITEMS.register("bejeweled_staff", BejeweledStaff::new);
//远程武器 //远程武器
public static final DeferredItem<Item> MUSKET = ITEMS.register("musket", Musket::new); public static final DeferredItem<Item> MUSKET = ITEMS.register("musket", Musket::new);
@@ -0,0 +1,164 @@
package com.lzxnone.terraria.item.weapon.magic.gem_staff;
import com.lzxnone.terraria.LzxnoneTerraria;
import com.lzxnone.terraria.ModSounds;
import com.lzxnone.terraria.entity.ModEntities;
import com.lzxnone.terraria.entity.projectile.StaticProjectile;
import com.lzxnone.terraria.entity.projectile.StaticProjectileBehaviors;
import com.lzxnone.terraria.entity.summon.StaticSummon;
import com.lzxnone.terraria.entity.summon.StaticSummonBehaviors;
import com.lzxnone.terraria.item.weapon.MagicWeapon;
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.ConfigInt;
import com.lzxnone.terraria.ui.config.struct.ConfigStruct;
import com.lzxnone.terraria.utils.DamageUtil;
import com.lzxnone.terraria.utils.MathUtil;
import com.lzxnone.terraria.utils.SoundUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
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.*;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.joml.Quaternionf;
import org.joml.Vector3f;
public class BejeweledStaff extends MagicWeapon {
public static final ConfigFloat DAMAGE = new ConfigFloat("weapon.bejeweled_staff.damage", "bejeweled_staff_damage", 8.0F, 0.0F, 8388600.0F);
public static final ConfigDouble SPEED = new ConfigDouble("weapon.bejeweled_staff.speed", "bejeweled_staff_speed", 2.0D, 0.1D, 100.0D);
public static final ConfigInt LIFETIME = new ConfigInt("weapon.bejeweled_staff.lifetime", "bejeweled_staff_lifetime", 50, 1, 100000);
public static final ConfigDouble MANA_CONSUME = new ConfigDouble("weapon.bejeweled_staff.mana_consume", "bejeweled_staff_mana_consume", 15.0D, 0.0D, 10000.0D);
public static final int ANGLE = 15;
public static final IConfigData CONFIG_DATA = new IConfigData() {
@Override
public void onConfigLoad() {
ConfigStruct.loadAll(
DAMAGE,
SPEED,
LIFETIME,
MANA_CONSUME
);
}
};
public static final ConfigListItem CONFIG_LIST_ITEM = new ConfigListItem(
"bejeweled_staff",
ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "textures/item/bejeweled_staff.png"),
Component.translatable("item.lzxnoneterraria.bejeweled_staff"),
CONFIG_DATA
);
public BejeweledStaff() {
super(Tiers.DIAMOND, new Item.Properties().stacksTo(1).rarity(Rarity.COMMON));
}
public static final Vector3f[] COLORS = new Vector3f[] {
AmethystStaff.COLOR,
TopazStaff.COLOR,
SapphireStaff.COLOR,
EmeraldStaff.COLOR,
AmberStaff.COLOR,
RubyStaff.COLOR,
DiamondStaff.COLOR
};
public Vector3f getColor() {
return COLORS[java.util.concurrent.ThreadLocalRandom.current().nextInt(COLORS.length)];
}
@Override
public float getTooltipDamage(ItemStack weaponStack, LivingEntity entity) {
float damage = entity instanceof Player player ? DamageUtil.applyPlayerDamageEffects(player, DAMAGE.get()) : DAMAGE.get();
return applyMagicDamageBonus(weaponStack, entity, damage);
}
@Override
protected double getManaConsumeRate(ItemStack stack, LivingEntity entity) {
return MANA_CONSUME.get();
}
@Override
public int getUseTime(ItemStack weaponStack, LivingEntity entity) {
return computeUseTime(22, weaponStack, entity);
}
@Override
public void shoot(Level level, Player player, InteractionHand hand, ItemStack weaponStack) {
if (level.isClientSide()) return;
SoundUtil.playServerSound(player, ModSounds.BEAM3.get(), 1.0F, 1.0F);
Vector3f[] dirs = MathUtil.computeCoordinateSystem(player);
Quaternionf rot = new Quaternionf().rotateAxis((float) Math.toRadians(ANGLE), dirs[1].x(), dirs[1].y(), dirs[1].z());
Quaternionf rot2 = new Quaternionf().rotateAxis((float) Math.toRadians(-ANGLE), dirs[1].x(), dirs[1].y(), dirs[1].z());
Vector3f[] shootDirs = {
new Vector3f(dirs[0]),
new Vector3f(dirs[0]).rotate(rot),
new Vector3f(dirs[0]).rotate(rot2),
};
int skill = GemStaff.SKILL_AMETHYST | GemStaff.SKILL_TOPAZ | GemStaff.SKILL_EMERALD | GemStaff.SKILL_AMBER | GemStaff.SKILL_DIAMOND;
Vector3f color = getColor();
Vec3 basePos = player.getBoundingBox().getCenter();
for(int i = 0;i < 3;i++) {
StaticSummon core = new StaticSummon(ModEntities.STATIC_SUMMON.get(), level);
core.setOwner(player);
core.setPos(basePos);
core.setDeltaMovement(MathUtil.toVec3(shootDirs[i]).normalize().scale(SPEED.get()));
core.getEntityData().set(StaticSummon.STACK_SOURCE, weaponStack.copy());
core.getEntityData().set(StaticSummon.BEHAVIOR, StaticSummonBehaviors.GEM_STAFF_PROJECTILE);
core.getEntityData().set(StaticSummon.LIFETIME, LIFETIME.get());
core.getEntityData().set(StaticSummon.RENDER_MODE, "custom");
core.getEntityData().set(StaticSummon.GLOW, false);
core.setNoGravity(true);
core.noPhysics = true;
float[] xyRot = MathUtil.computeXYRot(shootDirs[i], dirs[1]);
core.setXRot(xyRot[0]);
core.setYRot(xyRot[1]);
core.xRotO = xyRot[0];
core.yRotO = xyRot[1];
StaticProjectile projectile = new StaticProjectile(ModEntities.STATIC_PROJECTILE.get(), level);
projectile.setOwner(core);
CompoundTag coreData = new CompoundTag();
coreData.putInt("skill", skill);
coreData.putUUID("projectileUUID", projectile.getUUID());
core.getEntityData().set(StaticSummon.CUSTOM_DATA, coreData);
level.addFreshEntity(core);
projectile.setPos(basePos);
projectile.getEntityData().set(StaticProjectile.STACK_SOURCE, weaponStack.copy());
projectile.getEntityData().set(StaticProjectile.BEHAVIOR, StaticProjectileBehaviors.GEM_STAFF_PROJECTILE);
projectile.getEntityData().set(StaticProjectile.RENDER_MODE, "custom");
projectile.getEntityData().set(StaticProjectile.GLOW, true);
projectile.getEntityData().set(StaticProjectile.LIFETIME, LIFETIME.get());
projectile.getEntityData().set(StaticProjectile.ORIGIN, basePos.toVector3f());
projectile.getEntityData().set(StaticProjectile.COLOR_R, color.x);
projectile.getEntityData().set(StaticProjectile.COLOR_G, color.y);
projectile.getEntityData().set(StaticProjectile.COLOR_B, color.z);
CompoundTag projData = new CompoundTag();
projData.putInt("skill", skill);
projData.putUUID("playerUUID", player.getUUID());
projData.putFloat("damage", DAMAGE.get());
projData.putFloat("knockback", 0.5F);
projData.putFloat("colorR", color.x);
projData.putFloat("colorG", color.y);
projData.putFloat("colorB", color.z);
projectile.getEntityData().set(StaticProjectile.CUSTOM_DATA, projData);
level.addFreshEntity(projectile);
}
}
}
@@ -74,7 +74,6 @@ public abstract class GemStaff extends MagicWeapon {
boolean amethyst = (skill & SKILL_AMETHYST) != 0; boolean amethyst = (skill & SKILL_AMETHYST) != 0;
boolean emerald = (skill & SKILL_EMERALD) != 0; boolean emerald = (skill & SKILL_EMERALD) != 0;
boolean amber = (skill & SKILL_AMBER) != 0; boolean amber = (skill & SKILL_AMBER) != 0;
boolean sapphire = (skill & SKILL_SAPPHIRE) != 0;
Vec3 currentDir = summon.getLookAngle().normalize(); Vec3 currentDir = summon.getLookAngle().normalize();
Vec3 nextDir = currentDir; Vec3 nextDir = currentDir;
@@ -540,7 +539,7 @@ public abstract class GemStaff extends MagicWeapon {
CompoundTag projData = new CompoundTag(); CompoundTag projData = new CompoundTag();
projData.putInt("skill", skill); projData.putInt("skill", skill);
projData.putUUID("playerUUID", player.getUUID()); projData.putUUID("playerUUID", player.getUUID());
projData.putFloat("damage", ruby ? getDamage(weaponStack, player) / 2 : getDamage(weaponStack, player)); projData.putFloat("damage", (ruby || sapphire) ? getDamage(weaponStack, player) / 2 : getDamage(weaponStack, player));
projData.putFloat("knockback", getKnockback(weaponStack, player)); projData.putFloat("knockback", getKnockback(weaponStack, player));
projData.putFloat("colorR", color.x); projData.putFloat("colorR", color.x);
projData.putFloat("colorG", color.y); projData.putFloat("colorG", color.y);
@@ -198,6 +198,7 @@ public class ConfigList {
RubyStaff.CONFIG_LIST_ITEM, RubyStaff.CONFIG_LIST_ITEM,
AmberStaff.CONFIG_LIST_ITEM, AmberStaff.CONFIG_LIST_ITEM,
DiamondStaff.CONFIG_LIST_ITEM, DiamondStaff.CONFIG_LIST_ITEM,
BejeweledStaff.CONFIG_LIST_ITEM,
Minishark.CONFIG_LIST_ITEM, Minishark.CONFIG_LIST_ITEM,
FlintlockPistol.CONFIG_LIST_ITEM, FlintlockPistol.CONFIG_LIST_ITEM,
Boomstick.CONFIG_LIST_ITEM, Boomstick.CONFIG_LIST_ITEM,
@@ -1222,6 +1222,15 @@
"lzxnoneterraria.configuration.diamond_staff_damage.tooltip": "Damage per hit", "lzxnoneterraria.configuration.diamond_staff_damage.tooltip": "Damage per hit",
"lzxnoneterraria.configuration.diamond_staff_mana_consume": "Mana Consume", "lzxnoneterraria.configuration.diamond_staff_mana_consume": "Mana Consume",
"lzxnoneterraria.configuration.diamond_staff_mana_consume.tooltip": "Mana consumed per use", "lzxnoneterraria.configuration.diamond_staff_mana_consume.tooltip": "Mana consumed per use",
"item.lzxnoneterraria.bejeweled_staff": "Bejeweled Staff",
"lzxnoneterraria.configuration.bejeweled_staff_damage": "Damage",
"lzxnoneterraria.configuration.bejeweled_staff_damage.tooltip": "Damage per hit",
"lzxnoneterraria.configuration.bejeweled_staff_speed": "Speed",
"lzxnoneterraria.configuration.bejeweled_staff_speed.tooltip": "Flight speed of the fired projectile",
"lzxnoneterraria.configuration.bejeweled_staff_lifetime": "Lifetime",
"lzxnoneterraria.configuration.bejeweled_staff_lifetime.tooltip": "Maximum ticks the projectile can survive",
"lzxnoneterraria.configuration.bejeweled_staff_mana_consume": "Mana Consume",
"lzxnoneterraria.configuration.bejeweled_staff_mana_consume.tooltip": "Mana consumed per use",
"lzxnoneterraria.configuration.amethyst_staff_extra_damage": "Synergy Extra Damage", "lzxnoneterraria.configuration.amethyst_staff_extra_damage": "Synergy Extra Damage",
"lzxnoneterraria.configuration.amethyst_staff_extra_damage.tooltip": "Bonus damage when equipped with matching Gem Robe", "lzxnoneterraria.configuration.amethyst_staff_extra_damage.tooltip": "Bonus damage when equipped with matching Gem Robe",
"lzxnoneterraria.configuration.topaz_staff_extra_damage": "Synergy Extra Damage", "lzxnoneterraria.configuration.topaz_staff_extra_damage": "Synergy Extra Damage",
@@ -1222,6 +1222,15 @@
"lzxnoneterraria.configuration.diamond_staff_damage.tooltip": "每次命中伤害", "lzxnoneterraria.configuration.diamond_staff_damage.tooltip": "每次命中伤害",
"lzxnoneterraria.configuration.diamond_staff_mana_consume": "魔力消耗", "lzxnoneterraria.configuration.diamond_staff_mana_consume": "魔力消耗",
"lzxnoneterraria.configuration.diamond_staff_mana_consume.tooltip": "每次使用消耗的魔力值", "lzxnoneterraria.configuration.diamond_staff_mana_consume.tooltip": "每次使用消耗的魔力值",
"item.lzxnoneterraria.bejeweled_staff": "宝石镶嵌法杖",
"lzxnoneterraria.configuration.bejeweled_staff_damage": "伤害",
"lzxnoneterraria.configuration.bejeweled_staff_damage.tooltip": "每次命中伤害",
"lzxnoneterraria.configuration.bejeweled_staff_speed": "速度",
"lzxnoneterraria.configuration.bejeweled_staff_speed.tooltip": "法杖发射弹射的飞行速度",
"lzxnoneterraria.configuration.bejeweled_staff_lifetime": "生命周期",
"lzxnoneterraria.configuration.bejeweled_staff_lifetime.tooltip": "弹射存活的最大刻数",
"lzxnoneterraria.configuration.bejeweled_staff_mana_consume": "魔力消耗",
"lzxnoneterraria.configuration.bejeweled_staff_mana_consume.tooltip": "每次使用消耗的魔力值",
"lzxnoneterraria.configuration.amethyst_staff_extra_damage": "同系额外伤害", "lzxnoneterraria.configuration.amethyst_staff_extra_damage": "同系额外伤害",
"lzxnoneterraria.configuration.amethyst_staff_extra_damage.tooltip": "装备对应宝石长袍时获得的共鸣额外伤害", "lzxnoneterraria.configuration.amethyst_staff_extra_damage.tooltip": "装备对应宝石长袍时获得的共鸣额外伤害",
"lzxnoneterraria.configuration.topaz_staff_extra_damage": "同系额外伤害", "lzxnoneterraria.configuration.topaz_staff_extra_damage": "同系额外伤害",
@@ -0,0 +1,6 @@
{
"parent": "lzxnoneterraria:item/sword2",
"textures": {
"layer0": "lzxnoneterraria:item/bejeweled_staff"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B