Adjusted damage boost levels for player and allies. Removed inventory-based effect application logic.
This commit is contained in:
@@ -23,13 +23,13 @@ public class StaliniumSwordItem extends SwordItem {
|
|||||||
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
||||||
Level world = attacker.getCommandSenderWorld();
|
Level world = attacker.getCommandSenderWorld();
|
||||||
if (!world.isClientSide && attacker instanceof Player player) {
|
if (!world.isClientSide && attacker instanceof Player player) {
|
||||||
player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, 100, 1, false, true));
|
player.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, 100, 0, false, true));
|
||||||
AABB box = player.getBoundingBox().inflate(5.0);
|
AABB box = player.getBoundingBox().inflate(5.0);
|
||||||
List<Player> allies = world.getEntitiesOfClass(
|
List<Player> allies = world.getEntitiesOfClass(
|
||||||
Player.class, box,
|
Player.class, box,
|
||||||
p -> p instanceof ServerPlayer && player.isAlliedTo(p)
|
p -> p instanceof ServerPlayer && player.isAlliedTo(p)
|
||||||
);
|
);
|
||||||
MobEffectInstance allyBuff = new MobEffectInstance(MobEffects.DAMAGE_BOOST, 100, 0, false, true);
|
MobEffectInstance allyBuff = new MobEffectInstance(MobEffects.DAMAGE_BOOST, 100, 1, false, true);
|
||||||
for (Player ally : allies) {
|
for (Player ally : allies) {
|
||||||
ally.addEffect(allyBuff);
|
ally.addEffect(allyBuff);
|
||||||
}
|
}
|
||||||
@@ -37,36 +37,6 @@ public class StaliniumSwordItem extends SwordItem {
|
|||||||
return super.hurtEnemy(stack, target, attacker);
|
return super.hurtEnemy(stack, target, attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
|
|
||||||
super.inventoryTick(stack, world, entity, slot, selected);
|
|
||||||
if (world.isClientSide || !selected || !(entity instanceof Player player)) return;
|
|
||||||
if (player.getHealth() < 10.0f) {
|
|
||||||
MobEffectInstance res = new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 20, 0, false, false);
|
|
||||||
player.addEffect(res);
|
|
||||||
AABB area = player.getBoundingBox().inflate(3.0);
|
|
||||||
List<Player> allies = world.getEntitiesOfClass(
|
|
||||||
Player.class, area,
|
|
||||||
p -> p != player && player.isAlliedTo(p)
|
|
||||||
);
|
|
||||||
for (Player ally : allies) {
|
|
||||||
ally.addEffect(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (player.getHealth() < 4.0f) {
|
|
||||||
MobEffectInstance res = new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 100, 1, false, false);
|
|
||||||
player.addEffect(res);
|
|
||||||
AABB area = player.getBoundingBox().inflate(5.0);
|
|
||||||
List<Player> allies = world.getEntitiesOfClass(
|
|
||||||
Player.class, area,
|
|
||||||
p -> p != player && player.isAlliedTo(p)
|
|
||||||
);
|
|
||||||
for (Player ally : allies) {
|
|
||||||
ally.addEffect(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDamageable(ItemStack stack) {
|
public boolean isDamageable(ItemStack stack) {
|
||||||
|
|||||||
Reference in New Issue
Block a user