mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 03:26:44 +01:00
Adjust polearm balancing #64
This commit is contained in:
parent
445901733d
commit
a53cb275e9
2 changed files with 38 additions and 6 deletions
|
@ -6,9 +6,13 @@ import com.google.common.collect.ImmutableMultimap;
|
|||
import com.google.common.collect.Multimap;
|
||||
import com.minelittlepony.unicopia.entity.UEntityAttributes;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.attribute.*;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.network.packet.s2c.play.EntityVelocityUpdateS2CPacket;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
public class PolearmItem extends SwordItem {
|
||||
protected static final UUID ATTACK_RANGE_MODIFIER_ID = UUID.fromString("A7B3659C-AA74-469C-963A-09A391DCAA0F");
|
||||
|
@ -26,6 +30,19 @@ public class PolearmItem extends SwordItem {
|
|||
attributeModifiers = builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
if (state.isOf(Blocks.COBWEB)) {
|
||||
return 1;
|
||||
}
|
||||
return super.getMiningSpeedMultiplier(stack, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuitableFor(BlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<EntityAttribute, EntityAttributeModifier> getAttributeModifiers(EquipmentSlot slot) {
|
||||
if (slot == EquipmentSlot.MAINHAND) {
|
||||
|
@ -33,4 +50,19 @@ public class PolearmItem extends SwordItem {
|
|||
}
|
||||
return super.getAttributeModifiers(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
||||
boolean tooNear = target.distanceTo(attacker) <= 2;
|
||||
stack.damage(tooNear ? 4 : 1, attacker, e -> e.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND));
|
||||
target.takeKnockback(0.15, attacker.getX() - target.getX(), attacker.getZ() - target.getZ());
|
||||
if (tooNear) {
|
||||
attacker.takeKnockback(attacker.getRandom().nextTriangular(0.4, 0.2), target.getX() - attacker.getX(), target.getZ() - attacker.getZ());
|
||||
if (attacker instanceof ServerPlayerEntity ply) {
|
||||
ply.networkHandler.sendPacket(new EntityVelocityUpdateS2CPacket(ply));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,12 +78,12 @@ public interface UItems {
|
|||
|
||||
Item DRAGON_BREATH_SCROLL = register("dragon_breath_scroll", new DragonBreathScrollItem(new Item.Settings().rarity(Rarity.UNCOMMON).group(ItemGroup.TOOLS)));
|
||||
|
||||
Item WOODEN_POLEARM = register("wooden_polearm", new PolearmItem(ToolMaterials.WOOD, 3, -2.4F, 2, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item STONE_POLEARM = register("stone_polearm", new PolearmItem(ToolMaterials.STONE, 3, -2.4F, 2, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item IRON_POLEARM = register("iron_polearm", new PolearmItem(ToolMaterials.IRON, 3, -2.4F, 3, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item GOLDEN_POLEARM = register("golden_polearm", new PolearmItem(ToolMaterials.GOLD, 3, -2.4F, 4, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item DIAMOND_POLEARM = register("diamond_polearm", new PolearmItem(ToolMaterials.DIAMOND, 3, -2.4F, 5, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item NETHERITE_POLEARM = register("netherite_polearm", new PolearmItem(ToolMaterials.NETHERITE, 3, -2.4F, 5, new Item.Settings().group(ItemGroup.COMBAT).fireproof()));
|
||||
Item WOODEN_POLEARM = register("wooden_polearm", new PolearmItem(ToolMaterials.WOOD, 2, -3.6F, 2, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item STONE_POLEARM = register("stone_polearm", new PolearmItem(ToolMaterials.STONE, 2, -3.6F, 2, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item IRON_POLEARM = register("iron_polearm", new PolearmItem(ToolMaterials.IRON, 2, -3.6F, 3, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item GOLDEN_POLEARM = register("golden_polearm", new PolearmItem(ToolMaterials.GOLD, 2, -3.6F, 4, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item DIAMOND_POLEARM = register("diamond_polearm", new PolearmItem(ToolMaterials.DIAMOND, 2, -3.6F, 5, new Item.Settings().group(ItemGroup.COMBAT)));
|
||||
Item NETHERITE_POLEARM = register("netherite_polearm", new PolearmItem(ToolMaterials.NETHERITE, 2, -3.6F, 5, new Item.Settings().group(ItemGroup.COMBAT).fireproof()));
|
||||
|
||||
Item BUTTERFLY_SPAWN_EGG = register("butterfly_spawn_egg", new SpawnEggItem(UEntities.BUTTERFLY, 0x222200, 0xaaeeff, new Item.Settings().group(ItemGroup.MISC)));
|
||||
Item BUTTERFLY = register("butterfly", new Item(new Item.Settings().group(ItemGroup.FOOD).food(UFoodComponents.INSECTS)));
|
||||
|
|
Loading…
Reference in a new issue