TNT Blox 0 Posted August 2 Posted August 2 I'm using the newest version of forge for Minecraft 1.21, so this might be a bug, but I'm not sure if I'm just doing something wrong, because I'm kind of a noob. I'm trying to make a mod that (among other things) hurts entities when a minecart hits them. It works fine at first, but as soon as the entity dies the game crashes with a ticking entity error, but it's only for specific entities like pigs, but not villagers. I'm using a mixin to inject code into the canCollideWith function to do two things, 1. hurt the entity it collides with and 2. return false so the minecart doesn't stop. This is my code in AbstractMinecartMixin.java. package net.tnt_blox_0.improvements_overhaul.mixin; import net.minecraft.core.registries.Registries; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageTypes; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.vehicle.AbstractMinecart; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(AbstractMinecart.class) public class AbstractMinecartMixin { @Inject(method = "canCollideWith", at = @At("RETURN"), cancellable = true) public void canCollideWithInject(Entity p_38168_, CallbackInfoReturnable<Boolean> cir) { if (p_38168_ instanceof LivingEntity) { DamageSource damageSource = new DamageSource(((AbstractMinecart)(Object)this).level().registryAccess().registryOrThrow(Registries.DAMAGE_TYPE).getHolderOrThrow(DamageTypes.CRAMMING)); p_38168_.hurt(damageSource, 5F); } cir.setReturnValue(false); } } I know I should create a custom damage type, but I want this function to work first so I know the damage type isn't the problem. I've tried making one, but I get the same crash. Here's the log: https://pastebin.com/jDLvcMNC Here's the crash report: https://pastebin.com/EHLx47ZK Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.