Skip to content

Commit

Permalink
Update Neo, damage event refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
legobmw99 committed Jun 24, 2024
1 parent 169a1e6 commit f832619
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.145'
id 'net.neoforged.gradle.userdev' version '7.0.150'
}

tasks.named('wrapper', Wrapper).configure {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ minecraft_version=1.21
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.21,1.22)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=21.0.30-beta
neo_version=21.0.37-beta
# The Neo version range can use any version of Neo as bounds
neo_version_range=[21.0.30-beta,)
neo_version_range=[21.0.37-beta,)
# The loader version range can only use the major version of FML as bounds
loader_version_range=[2,)
loader_version_range=[4,)
# read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
neogradle.subsystems.parchment.minecraftVersion=1.21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
import net.neoforged.neoforge.event.entity.EntityInvulnerabilityCheckEvent;
import net.neoforged.neoforge.event.entity.living.LivingDeathEvent;
import net.neoforged.neoforge.event.entity.living.LivingHurtEvent;
import net.neoforged.neoforge.event.entity.living.LivingIncomingDamageEvent;
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
import net.neoforged.neoforge.event.entity.player.PlayerSetSpawnEvent;
import net.neoforged.neoforge.event.tick.LevelTickEvent;
Expand Down Expand Up @@ -171,7 +171,7 @@ public static void onLivingDeath(final LivingDeathEvent event) {
}

@SubscribeEvent
public static void onEntityHurt(final LivingHurtEvent event) {
public static void onEntityHurt(final LivingIncomingDamageEvent event) {
// Increase outgoing damage for pewter burners
if (event.getSource().getEntity() instanceof ServerPlayer source) {
var data = source.getData(AllomancerAttachment.ALLOMANCY_DATA);
Expand Down Expand Up @@ -216,16 +216,16 @@ public static void onEntityHurt(final LivingHurtEvent event) {
}

@SubscribeEvent
public static void onPlayerAttacked(final LivingAttackEvent event) {
public static void onInvulnerabilityCheck(final EntityInvulnerabilityCheckEvent event) {
if (event.getEntity() instanceof ServerPlayer player) {
var data = player.getData(AllomancerAttachment.ALLOMANCY_DATA);

if (data.isBurning(Metal.PEWTER) && data.isEnhanced()) { // Duralumin invulnerability
Allomancy.LOGGER.debug("Canceling Damage");
event.setCanceled(true);
event.setInvulnerable(true);
}

if (data.isBurning(Metal.STEEL)) {
if (data.isBurning(Metal.STEEL)) { // Prevent fall damage on metal blocks when steelpushing
if (event
.getSource()
.type()
Expand All @@ -238,7 +238,7 @@ public static void onPlayerAttacked(final LivingAttackEvent event) {
BlockPos on = player.getOnPos();
if (Physical.isBlockStateMetallic(player.level().getBlockState(on)) ||
Physical.isBlockStateMetallic(player.level().getBlockState(on.above()))) {
event.setCanceled(true);
event.setInvulnerable(true);
}
}
}
Expand All @@ -249,8 +249,8 @@ public static void onPlayerAttacked(final LivingAttackEvent event) {
public static void onWorldTick(final LevelTickEvent.Post event) {
Level level = event.getLevel();
var list = level.players();
for (int enti = list.size() - 1; enti >= 0; enti--) {
Player curPlayer = list.get(enti);
for (int i = list.size() - 1; i >= 0; i--) {
Player curPlayer = list.get(i);
playerPowerTick(curPlayer, level);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ public static void wipeNearby(Player curPlayer, Level level) {
int max = 20;
Vec3 negative = curPlayer.position().add(-max, -max, -max);
Vec3 positive = curPlayer.position().add(max, max, max);
level
.getEntitiesOfClass(Player.class, new AABB(negative, positive))
.forEach(otherPlayer -> otherPlayer
.getData(AllomancerAttachment.ALLOMANCY_DATA)
.drainMetals(Metal.values()));
level.getEntitiesOfClass(Player.class, new AABB(negative, positive)).forEach(Enhancement::wipePlayer);
}
}
}

0 comments on commit f832619

Please sign in to comment.