Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Grqndfish

Members
  • Joined

  • Last visited

  1. Grqndfish changed their profile photo
  2. huh, i didn't think of doing that. ill give it a try, and in the meantime, does anyone have any ideas about the particles?
  3. hello, i'm trying to make a sword that when used, fires a sonic boom (the one the warden makes) in the direction the player is facing, dealing damage in the process. my current code is able to create particles, but it only creates one, at the location of the player. also, i'm not sure how to damage the enemies caught in the boom. previously, i used AABB to find the targets, but as far as i know, it only works with cubes, not lines. if you could give me a hand on either, i would really appreciate it. my code: package net.grandfish.mod.item.custom; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.protocol.game.ClientboundLevelParticlesPacket; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; 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.level.Level; import net.minecraft.world.phys.Vec3; public class WardenSwordItem extends LightningSwordItem { public WardenSwordItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties properties) { super(pTier, pAttackDamageModifier, pAttackSpeedModifier, properties); } private void locateTargetExecute(LivingEntity player, Level level, InteractionHand hand) { if (!level.isClientSide()) { Vec3 pos = player.getEyePosition(1.0f); Vec3 dir = player.getLookAngle(); for (int i = 0; i < 40; i++) { Vec3 particlePos = pos.add(dir.scale(i)); level.addParticle(ParticleTypes.SONIC_BOOM, particlePos.x(), particlePos.y(), particlePos.z(), 0.0, 0.0, 0.0); } ClientboundLevelParticlesPacket particlePacket = new ClientboundLevelParticlesPacket( ParticleTypes.SONIC_BOOM, true, (float) pos.x(), (float) pos.y(), (float) pos.z(), 0.0f, 0.0f, 0.0f, 0.0f, 8 ); ((ServerPlayer) player).connection.send(particlePacket); } } public InteractionResultHolder<ItemStack> use (Level level, Player player, InteractionHand hand){ if (!level.isClientSide() && hand == InteractionHand.MAIN_HAND) { locateTargetExecute(player, level, hand); player.getCooldowns().addCooldown(this, 40); } return (super.use(level, player, hand)); } } thank you for taking a look at my post ❤️
  4. hi so basically, i'm trying to make a sword that when used, creates an explosion that deals damage at the block/entity that the player is targeting. however, when i tried to right-click with it, it caused the game to crash with "exit value -1"; i have a decent knowledge of java, but i'm new to modding. there are no errors btw. have a nice day! package net.sac.rpgmod.item.custom; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SwordItem; import net.minecraft.world.item.Tier; import net.minecraft.world.level.Level; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import java.util.List; public class ExplosionSwordItem extends SwordItem { public ExplosionSwordItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties properties) { super(pTier, pAttackDamageModifier, pAttackSpeedModifier, properties); } private void locateTargetExecute(LivingEntity user, Level world) { Vec3 eyePos = user.getEyePosition(); Vec3 lookVec = user.getLookAngle(); Vec3 targetPos = eyePos.add(lookVec.scale(25)).add(0, -1 * user.getEyeHeight(), 0); ((ServerLevel) world).sendParticles(ParticleTypes.EXPLOSION_EMITTER, targetPos.x, targetPos.y, targetPos.z, 3, 5, 5, 5, 0.0); AABB minMax = new AABB(targetPos.x, targetPos.y, targetPos.z, 10, 10, 10); List<Entity> ent = world.getEntities(user, minMax); for (Entity target : ent) { target.hurt(DamageSource.MAGIC, 20); } } public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) { if(!world.isClientSide() && hand == InteractionHand.MAIN_HAND) { locateTargetExecute(player, world); player.getCooldowns().addCooldown(this, 20); } return(null); } }

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.