#Minecraft crashes when damaging an entity :(

13 messages · Page 1 of 1 (latest)

calm comet
#

I am trying to make a sword that shoots a warden blast (yes many cool), but the beam does not damage entities :(

ModDamageTypes.java

package net.magmabits.echoing_depths.util;

import net.magmabits.echoing_depths.EchoingDepths;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageType;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;

public class ModDamageTypes {

    /*
     * Store the RegistryKey of our DamageType into a new constant called CUSTOM_DAMAGE_TYPE
     * The Identifier in use here points to our JSON file we created earlier.
     */
    public static final RegistryKey<DamageType> FALCHION_BLAST = RegistryKey.of(RegistryKeys.DAMAGE_TYPE, new Identifier(EchoingDepths.MOD_ID, "falchion_blast"));

    public static DamageSource of(World world, RegistryKey<DamageType> key) {
        return new DamageSource(world.getRegistryManager().get(RegistryKeys.DAMAGE_TYPE).entryOf(key));
    }
}


The part of my weapon code that should damage entities.

        for (Entity entity : world.getOtherEntities(null, new Box(startX, startY, startZ, endX, endY, endZ))) {
            if (entity instanceof LivingEntity && intersectsBeam(entity, beamStart, beamEnd)) {
                ((LivingEntity) entity).damage(ModDamageTypes.of(world, ModDamageTypes.FALCHION_BLAST), 8.0f);
            }
        }

All it does is crash :(

grizzled grotto
#

show the damage type json too

calm comet
#

wait, i think i have it

#

in my file, i accidentally displayed a number as a string 💀

#

like magic, i don't get this error anymore

grizzled grotto
#

yes, if you read the error once again, it says it can't read the json file

calm comet
#

okay, so i fixed that error, but my beam still does not damage entities

#

so it does log, but not damage

sly osprey
#

overrides

calm comet
#

i got it working (pretty much
it works sometimes, but not everytime an entity is hit

calm comet