Skip to content

Commit

Permalink
Bounce off sides of walls
Browse files Browse the repository at this point in the history
  • Loading branch information
baileyholl committed Sep 17, 2023
1 parent 7f4fbe0 commit 2c436de
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import com.hollingsworth.arsnouveau.ArsNouveau;
import com.hollingsworth.arsnouveau.api.event.BounceTimedEvent;
import com.hollingsworth.arsnouveau.api.event.EventQueue;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

Expand Down Expand Up @@ -52,4 +55,23 @@ public static void onFall(LivingFallEvent event) {
}
}

@SubscribeEvent
public static void onFlyWallDamage(LivingHurtEvent event) {
LivingEntity entity = event.getEntity();
if (entity == null || !entity.hasEffect(ModPotions.BOUNCE_EFFECT.get())) {
return;
}
boolean isPlayer = entity instanceof Player;
if (!isPlayer) {
return;
}
if(event.getSource() == DamageSource.FLY_INTO_WALL){
event.setAmount(0);
Vec3 lookAngle = entity.getLookAngle();

entity.setDeltaMovement(lookAngle.scale(-2));
entity.hurtMarked = true;
}
}

}

0 comments on commit 2c436de

Please sign in to comment.