Started by
Scootied
on
Topic category: Help with Minecraft modding (Java Edition)
Says it all in the title. No matter what I do, the same 2 hearts of damage stays the same for me. It seems to have to real fix and is extremely aggravating. There seems to be no work around for this and it makes the mod unplayable at times. Please, if there is anyway to make these projectiles not affect players. Please tell me.
Add these up top
Make sure the code is locked
Alright, only 2 errors left: https://imgur.com/a/fbvjAq5
I just pasted it and added the imports.
package net.mcreator.scootys_pvz;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
@ScootysPvzModElements.ModElement.Tag
public class PeapodNoDamageProper extends ScootysPvzModElements.ModElement {
/**
* Do not remove this constructor
*/
public PeapodNoDamageProper(ScootysPvzModElements instance) {
super(instance, 531);
MinecraftForge.EVENT_BUS.register(this);
}
@Override
public void initElements() {
}
@Override
public void init(FMLCommonSetupEvent event) {
}
@Override
public void serverLoad(FMLServerStartingEvent event) {
}
@SubscribeEvent
public void onDamageEvent(LivingDamageEvent event)
{
DamageSource source = event.getSource();
if (source.getImmediateSource() instanceof AbstractArrowEntity)
{
event.setCanceled(true);
//DO WHATEVER YOU WANT HERE. I.e. GIVE PLAYER MAGIC. idk
}
}
}
You need to import these
Alright, now its coming up with this instead: https://imgur.com/a/uMKtocv
Code:
package net.mcreator.scootys_pvz;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.event.entity.living.LivingDamageEvent;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
@ScootysPvzModElements.ModElement.Tag
public class PeapodNoDamageProper extends ScootysPvzModElements.ModElement {
/**
* Do not remove this constructor
*/
public PeapodNoDamageProper(ScootysPvzModElements instance) {
super(instance, 531);
MinecraftForge.EVENT_BUS.register(this);
}
@Override
public void initElements() {
}
@Override
public void init(FMLCommonSetupEvent event) {
}
@Override
public void serverLoad(FMLServerStartingEvent event) {
}
@SubscribeEvent
public void onDamageEvent(LivingDamageEvent event)
{
DamageSource source = event.getSource();
if (source.getImmediateSource() instanceof AbstractArrowEntity)
{
event.setCanceled(true);
//DO WHATEVER YOU WANT HERE. I.e. GIVE PLAYER MAGIC. idk
}
}
}
Well then add these imports...
HOLY! IT WORKS! Thank you so much dude you have no idea how big this is for me. The mod will improve tenfold with this. But I do have 1 more request, do you think its possible to also disable the knockback you get?
Thanks...
Yeah, I thought that would happen. But to answer, maybe, I am a little fried right now? I'll get back to you.
Of course. Im already really happy with just this. Anytime if your able to get back to me. Thanks again
You can use Ctrl + W in code editors to autoimport too ;)
👍
I know this is old as hell but I was looking this up and I solved this in a much easier way if anyone comes across this. The entity is still hit, but all damage is negated. Add this procedure then add an EntityHit procedure to your projectile and add damage from the the player that way, or effects if you want the projectile to have no damage. The tag can be whatever you want, just add whatever projectile you want to have no damage to it. You just have to edit the tag code and enter the projectile entity to it manually as mcreator won't let you add to it.