Hammers
|
@ -1,11 +1,23 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
|
||||
public class EndAxe extends AxeItem {
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.tag.Tag;
|
||||
|
||||
public class EndAxe extends AxeItem implements DynamicAttributeTool {
|
||||
|
||||
public EndAxe(ToolMaterial material, float attackDamage, float attackSpeed, Settings settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
||||
return this.getMaterial().getMiningLevel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,14 @@ import java.util.UUID;
|
|||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import io.netty.util.internal.ThreadLocalRandom;
|
||||
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.ToolManager;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
@ -16,50 +20,39 @@ import net.minecraft.entity.attribute.EntityAttribute;
|
|||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ToolItem;
|
||||
import net.minecraft.item.MiningToolItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.item.Vanishable;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EndHammer extends ToolItem implements Vanishable {
|
||||
public class EndHammer extends MiningToolItem implements DynamicAttributeTool {
|
||||
|
||||
public final static UUID ATTACK_KNOCKBACK_MODIFIER_ID = MathHelper.randomUuid(ThreadLocalRandom.current());
|
||||
|
||||
private final float attackDamage;
|
||||
private final Multimap<EntityAttribute, EntityAttributeModifier> attributeModifiers;
|
||||
private ItemStack itemStack;
|
||||
|
||||
public EndHammer(ToolMaterial material, float attackDamage, float attackSpeed, double knockback, Settings settings) {
|
||||
super(material, settings);
|
||||
|
||||
this.attackDamage = attackDamage + material.getAttackDamage();
|
||||
super(attackDamage, attackSpeed, material, Sets.newHashSet(), settings);
|
||||
|
||||
Builder<EntityAttribute, EntityAttributeModifier> builder = ImmutableMultimap.builder();
|
||||
builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", this.attackDamage, EntityAttributeModifier.Operation.ADDITION));
|
||||
builder.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", attackDamage + material.getAttackDamage(), EntityAttributeModifier.Operation.ADDITION));
|
||||
builder.put(EntityAttributes.GENERIC_ATTACK_SPEED, new EntityAttributeModifier(ATTACK_SPEED_MODIFIER_ID, "Weapon modifier", attackSpeed, EntityAttributeModifier.Operation.ADDITION));
|
||||
builder.put(EntityAttributes.GENERIC_ATTACK_KNOCKBACK, new EntityAttributeModifier(ATTACK_KNOCKBACK_MODIFIER_ID, "Weapon modifier", knockback, EntityAttributeModifier.Operation.ADDITION));
|
||||
this.attributeModifiers = builder.build();
|
||||
}
|
||||
|
||||
public float getAttackDamage() {
|
||||
return this.attackDamage;
|
||||
this.itemStack = new ItemStack(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canMine(BlockState state, World world, BlockPos pos, PlayerEntity miner) {
|
||||
return !miner.isCreative() || state.getMaterial().equals(Material.STONE);
|
||||
}
|
||||
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
if (state.isOf(Blocks.COBWEB)) {
|
||||
return 15.0F;
|
||||
} else {
|
||||
Material material = state.getMaterial();
|
||||
return material != Material.PLANT && material != Material.REPLACEABLE_PLANT && material != Material.UNUSED_PLANT && !state.isIn(BlockTags.LEAVES) && material != Material.GOURD ? 1.0F : 1.5F;
|
||||
}
|
||||
return !miner.isCreative() || state.getMaterial().equals(Material.STONE) || state.getMaterial().equals(Material.GLASS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
|
||||
stack.damage(1, attacker, ((entity) -> {
|
||||
entity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND);
|
||||
|
@ -68,9 +61,10 @@ public class EndHammer extends ToolItem implements Vanishable {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean postMine(ItemStack stack, World world, BlockState state, BlockPos pos, LivingEntity miner) {
|
||||
if (state.getHardness(world, pos) != 0.0F) {
|
||||
stack.damage(2, miner, ((entity) -> {
|
||||
stack.damage(1, miner, ((entity) -> {
|
||||
entity.sendEquipmentBreakStatus(EquipmentSlot.MAINHAND);
|
||||
}));
|
||||
}
|
||||
|
@ -78,10 +72,31 @@ public class EndHammer extends ToolItem implements Vanishable {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean isEffectiveOn(BlockState state) {
|
||||
return state.getMaterial().equals(Material.STONE);
|
||||
@Override
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
if (state.getMaterial().equals(Material.GLASS)) {
|
||||
return 10.0F;
|
||||
}
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
||||
return this.getMaterial().getMiningLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEffectiveOn(BlockState state) {
|
||||
if (state.getMaterial().equals(Material.GLASS)) {
|
||||
return true;
|
||||
}
|
||||
if (!state.getMaterial().equals(Material.STONE)) {
|
||||
return false;
|
||||
}
|
||||
return ToolManager.handleIsEffectiveOnIgnoresVanilla(state, itemStack, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Multimap<EntityAttribute, EntityAttributeModifier> getAttributeModifiers(EquipmentSlot slot) {
|
||||
return slot == EquipmentSlot.MAINHAND ? this.attributeModifiers : super.getAttributeModifiers(slot);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,22 @@
|
|||
package ru.betterend.item;
|
||||
|
||||
import net.fabricmc.fabric.api.tool.attribute.v1.DynamicAttributeTool;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.tag.Tag;
|
||||
|
||||
public class EndPickaxe extends PickaxeItem {
|
||||
public class EndPickaxe extends PickaxeItem implements DynamicAttributeTool {
|
||||
|
||||
public EndPickaxe(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) {
|
||||
super(material, attackDamage, attackSpeed, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMiningLevel(Tag<Item> tag, BlockState state, ItemStack stack, LivingEntity user) {
|
||||
return this.getMaterial().getMiningLevel();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ public class CraftingRecipes {
|
|||
registerPickaxe(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_PICKAXE);
|
||||
registerAxe(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_AXE);
|
||||
registerHoe(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_HOE);
|
||||
registerHammer(material, ItemRegistry.TERMINITE_INGOT, ItemRegistry.TERMINITE_HAMMER);
|
||||
}
|
||||
if (itemExists(ItemRegistry.AETERNIUM_INGOT)) {
|
||||
String material = "aeternium";
|
||||
|
@ -63,7 +64,13 @@ public class CraftingRecipes {
|
|||
registerPickaxe(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_PICKAXE);
|
||||
registerAxe(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_AXE);
|
||||
registerHoe(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_HOE);
|
||||
registerHammer(material, ItemRegistry.AETERNIUM_INGOT, ItemRegistry.AETERNIUM_HAMMER);
|
||||
}
|
||||
|
||||
registerHammer("iron", Items.IRON_INGOT, ItemRegistry.IRON_HAMMER);
|
||||
registerHammer("golden", Items.GOLD_INGOT, ItemRegistry.GOLDEN_HAMMER);
|
||||
registerHammer("diamond", Items.DIAMOND, ItemRegistry.DIAMOND_HAMMER);
|
||||
registerHammer("netherite", Items.NETHERITE_INGOT, ItemRegistry.NETHERITE_HAMMER);
|
||||
}
|
||||
|
||||
private static void registerHelmet(String name, Item material, Item result) {
|
||||
|
@ -134,6 +141,14 @@ public class CraftingRecipes {
|
|||
.build();
|
||||
}
|
||||
|
||||
private static void registerHammer(String name, Item material, Item result) {
|
||||
RecipeBuilder.make(name + "_hammer", result)
|
||||
.setShape(new String[] { "I I", "I#I", " # " })
|
||||
.addMaterial('I', material)
|
||||
.addMaterial('#', Items.STICK)
|
||||
.build();
|
||||
}
|
||||
|
||||
protected static boolean itemExists(Item item) {
|
||||
return Registry.ITEM.getId(item) != Registry.ITEM.getDefaultId();
|
||||
}
|
||||
|
|
|
@ -49,14 +49,19 @@ public class ItemRegistry {
|
|||
public static ToolItem TERMINITE_SHOVEL = registerTool("terminite_shovel", new ShovelItem(EndToolMaterial.TERMINITE, 1.5F, -3.0F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem TERMINITE_SWORD = registerTool("terminite_sword", new SwordItem(EndToolMaterial.TERMINITE, 3, -2.4F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem TERMINITE_PICKAXE = registerTool("terminite_pickaxe", new EndPickaxe(EndToolMaterial.TERMINITE, 1, -2.8F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem TERMINITE_AXE = registerTool("terminite_axe", new EndAxe(EndToolMaterial.TERMINITE, 5.0F, -3.0F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem TERMINITE_AXE = registerTool("terminite_axe", new EndAxe(EndToolMaterial.TERMINITE, 6.0F, -3.0F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem TERMINITE_HOE = registerTool("terminite_hoe", new EndHoe(EndToolMaterial.TERMINITE, -3, 0.0F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem TERMINITE_HAMMER = registerTool("terminite_hammer", new EndHammer(EndToolMaterial.TERMINITE, 5.0F, -3.2F, 0.3D, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem AETERNIUM_SHOVEL = registerTool("aeternium_shovel", new ShovelItem(EndToolMaterial.AETERNIUM, 1.5F, -3.0F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem AETERNIUM_SWORD = registerTool("aeternium_sword", new SwordItem(EndToolMaterial.AETERNIUM, 3, -2.4F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem AETERNIUM_PICKAXE = registerTool("aeternium_pickaxe", new EndPickaxe(EndToolMaterial.AETERNIUM, 1, -2.8F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem AETERNIUM_AXE = registerTool("aeternium_axe", new EndAxe(EndToolMaterial.AETERNIUM, 5.0F, -3.0F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem AETERNIUM_HOE = registerTool("aeternium_hoe", new EndHoe(EndToolMaterial.AETERNIUM, -3, 0.0F, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem AETERNIUM_HAMMER = registerTool("aeternium_hammer", new EndHammer(EndToolMaterial.AETERNIUM, 6.0F, -3.0F, 0.3D, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem IRON_HAMMER = registerTool("iron_hammer", new EndHammer(ToolMaterials.IRON, 5.0F, -3.2F, 0.2D, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem GOLDEN_HAMMER = registerTool("golden_hammer", new EndHammer(ToolMaterials.GOLD, 4.5F, -3.4F, 0.3D, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem DIAMOND_HAMMER = registerTool("diamond_hammer", new EndHammer(ToolMaterials.DIAMOND, 5.5F, -3.1F, 0.2D, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
public static ToolItem NETHERITE_HAMMER = registerTool("netherite_hammer", new EndHammer(ToolMaterials.DIAMOND, 6.0F, -3.0F, 0.2D, new Item.Settings().group(CreativeTab.END_TAB)));
|
||||
|
||||
protected static Item registerItem(String name, Item item) {
|
||||
if (item != Items.AIR) {
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
"item.betterend.terminite_pickaxe": "Terminite Pickaxe",
|
||||
"item.betterend.terminite_axe": "Terminite Axe",
|
||||
"item.betterend.terminite_hoe": "Terminite Hoe",
|
||||
"item.betterend.terminite_hammer": "Terminite Smith Hammer",
|
||||
"item.betterend.aeternium_helmet": "Aeternium Helmet",
|
||||
"item.betterend.aeternium_chestplate": "Aeternium Chestplate",
|
||||
"item.betterend.aeternium_leggings": "Aeternium Leggings",
|
||||
|
@ -35,6 +36,11 @@
|
|||
"item.betterend.aeternium_pickaxe": "Aeternium Pickaxe",
|
||||
"item.betterend.aeternium_axe": "Aeternium Axe",
|
||||
"item.betterend.aeternium_hoe": "Aeternium Hoe",
|
||||
"item.betterend.aeternium_hammer": "Aeternium Smith Hammer",
|
||||
"item.betterend.iron_hammer": "Iron Smith Hammer",
|
||||
"item.betterend.golden_hammer": "Golden Smith Hammer",
|
||||
"item.betterend.diamond_hammer": "Diamond Smith Hammer",
|
||||
"item.betterend.netherite_hammer": "Netherite Smith Hammer",
|
||||
|
||||
"block.betterend.mossy_glowshroom_sapling": "Mossy Glowshroom Sapling",
|
||||
"block.betterend.mossy_glowshroom_cap": "Mossy Glowshroom Cap",
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
"item.betterend.terminite_pickaxe": "Кирка из Терминита",
|
||||
"item.betterend.terminite_axe": "Топор из Терминита",
|
||||
"item.betterend.terminite_hoe": "Мотыга из Терминита",
|
||||
"item.betterend.terminite_hammer": "Кузнечный Молот из Терминита",
|
||||
"item.betterend.aeternium_helmet": "Этериевый Шлем",
|
||||
"item.betterend.aeternium_chestplate": "Этериевая Кираса",
|
||||
"item.betterend.aeternium_leggings": "Этериевые Поножи",
|
||||
|
@ -35,6 +36,11 @@
|
|||
"item.betterend.aeternium_pickaxe": "Этериевая Кирка",
|
||||
"item.betterend.aeternium_axe": "Этериевый Топор",
|
||||
"item.betterend.aeternium_hoe": "Этериевая Мотыга",
|
||||
"item.betterend.aeternium_hammer": "Этериевый Кузнечный Молот",
|
||||
"item.betterend.iron_hammer": "Железный Кузнечный Молот",
|
||||
"item.betterend.golden_hammer": "Золотой Кузнечный Молот",
|
||||
"item.betterend.diamond_hammer": "Алмазный Кузнечный Молот",
|
||||
"item.betterend.netherite_hammer": "Кузнечный Молот из Незерита",
|
||||
|
||||
"block.betterend.mossy_glowshroom_sapling": "Саженец мшистого светогриба",
|
||||
"block.betterend.mossy_glowshroom_cap": "Шляпка мшистого светогриба",
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "betterend:item/aeternium_hammer"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "betterend:item/diamond_hammer"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "betterend:item/golden_hammer"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "betterend:item/netherite_hammer"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "betterend:item/terminite_hammer"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 477 B |
After Width: | Height: | Size: 425 B |
After Width: | Height: | Size: 473 B |
Before Width: | Height: | Size: 325 B After Width: | Height: | Size: 352 B |
After Width: | Height: | Size: 497 B |
After Width: | Height: | Size: 418 B |