diff --git a/gradle.properties b/gradle.properties index 8c7ff15..f1e4b38 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,7 +32,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.0.0 +mod_version=1.1.0 # 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 diff --git a/src/main/java/com/lzxnone/terraria/ModSounds.java b/src/main/java/com/lzxnone/terraria/ModSounds.java index 1222591..d607edd 100644 --- a/src/main/java/com/lzxnone/terraria/ModSounds.java +++ b/src/main/java/com/lzxnone/terraria/ModSounds.java @@ -27,6 +27,10 @@ public class ModSounds { SOUND_EVENTS.register("wave2", () -> SoundEvent.createVariableRangeEvent( ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "wave2"))); + public static final Supplier WAVE3 = + SOUND_EVENTS.register("wave3", + () -> SoundEvent.createVariableRangeEvent( + ResourceLocation.fromNamespaceAndPath(LzxnoneTerraria.MODID, "wave3"))); public static final Supplier STAR_FALL = SOUND_EVENTS.register("star_fall", () -> SoundEvent.createVariableRangeEvent( diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java index ea70d2c..e3de417 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/TerraBlade.java @@ -539,6 +539,7 @@ public class TerraBlade extends SwordItem { if(item instanceof TerraBlade && !player.getCooldowns().isOnCooldown(item)) { PacketDistributor.sendToServer(new SwordBeamPayload("terra_blade", BEAM_DATA)); SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + SoundUtil.playClientSound(player, ModSounds.WAVE3.get()); } } public void onAttackEntity(AttackEntityEvent event) { @@ -551,6 +552,7 @@ public class TerraBlade extends SwordItem { SwordBeamBehaviors.getBehavior("terra_blade").generate(player, BEAM_DATA); }else { SoundUtil.playClientSound(player, ModSounds.WAVE.get()); + SoundUtil.playClientSound(player, ModSounds.WAVE3.get()); } } event.setCanceled(true); diff --git a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java index 7cbeef4..2c58bb8 100644 --- a/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java +++ b/src/main/java/com/lzxnone/terraria/item/weapon/melee/Zenith.java @@ -1,14 +1,30 @@ package com.lzxnone.terraria.item.weapon.melee; 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.item.ModItems; +import com.lzxnone.terraria.particle.ModParticles; +import com.lzxnone.terraria.utils.MathUtil; +import com.lzxnone.terraria.utils.ParticleUtil; +import com.lzxnone.terraria.utils.SoundUtil; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.EquipmentSlotGroup; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tiers; import net.minecraft.world.item.component.ItemAttributeModifiers; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3f; public class Zenith extends SwordItem { public Zenith() { @@ -22,4 +38,45 @@ public class Zenith extends SwordItem { .build() )); } + + @Override + public InteractionResultHolder use(Level level, Player player, InteractionHand hand) { + ItemStack stack = player.getItemInHand(hand); + + if(!level.isClientSide()) { + Vector3f[] dirs = MathUtil.computeCoordinateSystem(player); + StaticProjectile projectile = new StaticProjectile(ModEntities.STATIC_PROJECTILE.get(), level); + projectile.setOwner(player); + Vec3 pos = new Vec3(player.getX(), player.getEyeY() - 0.1, player.getZ()); + projectile.setPos(pos); + projectile.getEntityData().set(StaticProjectile.BEHAVIOR, StaticProjectileBehaviors.ENCHANTED_SWORD_BEAM); + projectile.getEntityData().set(StaticProjectile.RENDER_MODE, "item"); + projectile.getEntityData().set(StaticProjectile.ORIGIN, MathUtil.toVector3f(pos)); + projectile.getEntityData().set(StaticProjectile.DIRECTION, dirs[0]); + projectile.getEntityData().set(StaticProjectile.UP, dirs[1]); + projectile.getEntityData().set(StaticProjectile.RIGHT, dirs[2]); + projectile.getEntityData().set(StaticProjectile.ITEM, new ItemStack(ModItems.ENCHANTED_SWORD_BEAM.get())); + projectile.getEntityData().set(StaticProjectile.SCALE_X, 0.5f); + projectile.getEntityData().set(StaticProjectile.SCALE_Y, 0.5f); + projectile.getEntityData().set(StaticProjectile.RXP, 90); + projectile.getEntityData().set(StaticProjectile.RZP, 45); + projectile.getEntityData().set(StaticProjectile.RYPS, 10); + projectile.getEntityData().set(StaticProjectile.GLOW, true); + projectile.getEntityData().set(StaticProjectile.EXPRESSION_Z, "t"); + + projectile.setDeltaMovement(MathUtil.toVec3(dirs[0])); + level.addFreshEntity(projectile); + }else { + ParticleUtil.addParticles( + player.level(), ModParticles.COLORFUL_PARTICLE, + new Vec3(player.getX(), player.getY() + 0.5, player.getZ()), 0.2, + new Vec3(0, 0, 0), 0.2, + 25 + ); + SoundUtil.playClientSound(player, ModSounds.BEAM.get()); + } + + player.getCooldowns().addCooldown(stack.getItem(), 15); + return InteractionResultHolder.sidedSuccess(stack, level.isClientSide()); + } } diff --git a/src/main/resources/assets/lzxnoneterraria/sounds.json b/src/main/resources/assets/lzxnoneterraria/sounds.json index fe4f996..ba0fd0c 100644 --- a/src/main/resources/assets/lzxnoneterraria/sounds.json +++ b/src/main/resources/assets/lzxnoneterraria/sounds.json @@ -5,6 +5,9 @@ "wave2": { "sounds": ["lzxnoneterraria:wave2"] }, + "wave3": { + "sounds": ["lzxnoneterraria:wave3"] + }, "max_mana": { "sounds": ["lzxnoneterraria:max_mana"] }, diff --git a/src/main/resources/assets/lzxnoneterraria/sounds/wave3.ogg b/src/main/resources/assets/lzxnoneterraria/sounds/wave3.ogg new file mode 100644 index 0000000..2c6cdb4 Binary files /dev/null and b/src/main/resources/assets/lzxnoneterraria/sounds/wave3.ogg differ