"Enhanced Stalinium items and effects. Increased speed, knockback resistance, and added attack speed to StaliniumChargeEffect for better combat utility. Adjusted StaliniumSwordItem cooldown and implemented ally boost effect on hit. Made all tools implement hurtEnemy for consistency. Removed unnecessary getMaxDamage overrides and kept items unbreakable. Minor cleanup in code formatting."

This commit is contained in:
IM23a-spirgif
2025-05-27 09:51:01 +02:00
parent 7007a9684b
commit ef9489574e
5 changed files with 54 additions and 34 deletions
@@ -13,14 +13,20 @@ public class StaliniumChargeEffect extends MobEffect {
this.addAttributeModifier(
Attributes.MOVEMENT_SPEED,
ResourceLocation.fromNamespaceAndPath(Stalinium.MODID, "stalinium_charge_speed"),
0.2,
0.25,
AttributeModifier.Operation.ADD_MULTIPLIED_BASE
);
this.addAttributeModifier(
Attributes.KNOCKBACK_RESISTANCE,
ResourceLocation.fromNamespaceAndPath(Stalinium.MODID, "stalinium_charge_knockback"),
0.5,
0.75,
AttributeModifier.Operation.ADD_VALUE
);
this.addAttributeModifier(
Attributes.ATTACK_SPEED,
ResourceLocation.fromNamespaceAndPath(Stalinium.MODID, "stalinium_charge_toughness"),
0.1,
AttributeModifier.Operation.ADD_MULTIPLIED_BASE
);
}
}
@@ -36,8 +36,12 @@ public class StaliniumAxeItem extends AxeItem {
return true;
}
@Override
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
return true;
}
private void cutDownTree(Level level, BlockPos start, Player player, ItemStack stack) {
// 1) Gather all logs to break
Set<BlockPos> toBreak = new HashSet<>();
Deque<BlockPos> queue = new ArrayDeque<>();
queue.add(start);
@@ -99,23 +103,12 @@ public class StaliniumAxeItem extends AxeItem {
if (id == null) return null;
String path = id.getPath();
if (!path.endsWith("_log")) return null;
String plankPath = path.substring(0, path.length() - 4) + "_planks";
ResourceLocation plankId = ResourceLocation.fromNamespaceAndPath(id.getNamespace(), plankPath);
// fall back to oak planks if the specific one isn't registered
return BuiltInRegistries.BLOCK.getOptional(plankId)
.orElse(Blocks.OAK_PLANKS);
}
@Override
public int getMaxDamage(ItemStack stack) {
return 2;
}
@Override
public boolean isDamageable(ItemStack stack) {
return false;
@@ -1,5 +1,6 @@
package net.krituximon.stalinium.item;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.HoeItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@@ -11,8 +12,8 @@ public class StaliniumHoeItem extends HoeItem {
}
@Override
public int getMaxDamage(ItemStack stack) {
return 2;
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
return true;
}
@Override
@@ -38,7 +38,6 @@ public class StaliniumShovelItem extends ShovelItem {
}
}
}
if (anyBroken && miningEntity instanceof Player player) {
MobEffectInstance selfHaste = new MobEffectInstance(MobEffects.DIG_SPEED, 100, 1, false, true, true);
player.addEffect(selfHaste);
@@ -57,6 +56,11 @@ public class StaliniumShovelItem extends ShovelItem {
return true;
}
@Override
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
return true;
}
@Override
public boolean isDamageable(ItemStack stack) {
return false;
@@ -67,11 +71,6 @@ public class StaliniumShovelItem extends ShovelItem {
return false;
}
@Override
public int getMaxDamage(ItemStack stack) {
return 2;
}
@Override
public InteractionResult useOn(UseOnContext ctx) {
ItemStack stack = ctx.getItemInHand();
@@ -8,6 +8,8 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.item.ItemStack;
@@ -22,26 +24,40 @@ import net.minecraft.server.level.ServerPlayer;
import java.util.List;
public class StaliniumSwordItem extends SwordItem {
private static final double RANGE = 6.0;
private static final double HALF_ANGLE = Math.toRadians(30);
private static final double RANGE = 6.0;
private static final double HALF_ANGLE = Math.toRadians(30);
private static final double COS_HALF_ANG = Math.cos(HALF_ANGLE);
private static final int DURATION = 5 * 20;
private static final int AMP = 0;
private static final int COOLDOWN = 20 * 20; // 20s
private static final int DURATION = 5 * 20;
private static final int AMP = 0;
private static final int COOLDOWN = 30 * 20;
public StaliniumSwordItem(Tier tier, Properties props) {
super(tier, props);
}
@Override
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
Level world = attacker.getCommandSenderWorld();
if (!world.isClientSide && attacker instanceof Player player) {
AABB box = player.getBoundingBox().inflate(5.0);
List<Player> allies = world.getEntitiesOfClass(
Player.class, box,
p -> p instanceof ServerPlayer && player.isAlliedTo(p)
);
MobEffectInstance allyBuff = new MobEffectInstance(MobEffects.DAMAGE_BOOST, 100, 0, false, true);
for (Player ally : allies) {
ally.addEffect(allyBuff);
}
}
return true;
}
@Override
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
ItemStack stack = player.getItemInHand(hand);
// 1) if still on cooldown, fail
if (player.getCooldowns().isOnCooldown(this)) {
return InteractionResultHolder.fail(stack);
}
if (!world.isClientSide) {
Holder<MobEffect> chargeHolder = world
.registryAccess()
@@ -76,9 +92,14 @@ public class StaliniumSwordItem extends SwordItem {
public UseAnim getUseAnimation(ItemStack stack) {
return UseAnim.BOW;
}
@Override
public boolean isDamageable(ItemStack stack) {
return false;
}
// keep it unbreakable
@Override public boolean isDamageable(ItemStack stack) { return false; }
@Override public boolean isDamaged(ItemStack stack) { return false; }
@Override public int getMaxDamage(ItemStack stack) { return 2; }
@Override
public boolean isDamaged(ItemStack stack) {
return false;
}
}