Skip to content

Commit

Permalink
fix: exception from crystal damager
Browse files Browse the repository at this point in the history
Closes #9
  • Loading branch information
Jyguy committed Feb 16, 2024
1 parent 9d4543f commit 5ae078b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package xyz.reknown.fastercrystals.damager;

import net.minecraft.core.Holder;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSources;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftEnderCrystal;
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
Expand All @@ -12,10 +11,8 @@
public class CrystalDamager_1_19_R3 implements ICrystalDamager {
@Override
public void damage(Entity entity, Player player) {
((CraftEnderCrystal) entity).getHandle().hurt(new DamageSource(
Holder.direct(new DamageType("player", 0.1f)),
((CraftPlayer) player).getHandle()),
1
);
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
DamageSources damageSources = serverPlayer.level.damageSources();
((CraftEnderCrystal) entity).getHandle().hurt(damageSources.playerAttack(serverPlayer), 1);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package xyz.reknown.fastercrystals.damager;

import net.minecraft.core.Holder;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSources;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftEnderCrystal;
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
import org.bukkit.entity.Entity;
Expand All @@ -12,10 +11,8 @@
public class CrystalDamager_1_20_R1 implements ICrystalDamager {
@Override
public void damage(Entity entity, Player player) {
((CraftEnderCrystal) entity).getHandle().hurt(new DamageSource(
Holder.direct(new DamageType("player", 0.1f)),
((CraftPlayer) player).getHandle()),
1
);
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
DamageSources damageSources = serverPlayer.level().damageSources();
((CraftEnderCrystal) entity).getHandle().hurt(damageSources.playerAttack(serverPlayer), 1);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package xyz.reknown.fastercrystals.damager;

import net.minecraft.core.Holder;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSources;
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftEnderCrystal;
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer;
import org.bukkit.entity.Entity;
Expand All @@ -12,10 +11,8 @@
public class CrystalDamager_1_20_R2 implements ICrystalDamager {
@Override
public void damage(Entity entity, Player player) {
((CraftEnderCrystal) entity).getHandle().hurt(new DamageSource(
Holder.direct(new DamageType("player", 0.1f)),
((CraftPlayer) player).getHandle()),
1
);
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
DamageSources damageSources = serverPlayer.level().damageSources();
((CraftEnderCrystal) entity).getHandle().hurt(damageSources.playerAttack(serverPlayer), 1);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package xyz.reknown.fastercrystals.damager;

import net.minecraft.core.Holder;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.damagesource.DamageSources;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEnderCrystal;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
Expand All @@ -12,10 +11,8 @@
public class CrystalDamager_1_20_R3 implements ICrystalDamager {
@Override
public void damage(Entity entity, Player player) {
((CraftEnderCrystal) entity).getHandle().hurt(new DamageSource(
Holder.direct(new DamageType("player", 0.1f)),
((CraftPlayer) player).getHandle()),
1
);
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
DamageSources damageSources = serverPlayer.level().damageSources();
((CraftEnderCrystal) entity).getHandle().hurt(damageSources.playerAttack(serverPlayer), 1);
}
}

0 comments on commit 5ae078b

Please sign in to comment.