From e888820fee98d919e7469625ac46b502d3b3c87e Mon Sep 17 00:00:00 2001 From: agmas Date: Mon, 16 Sep 2024 16:23:54 +0400 Subject: [PATCH] rp work --- README.md | 2 - .../java/org/agmas/scythes/ScythesItems.java | 15 +++-- .../java/org/agmas/scythes/items/Scythe.java | 66 ++----------------- 3 files changed, 14 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 2431a67..e25ed30 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ Adds in Scythes, a new weapon that increases attack reach by 2.6m instead of att - Install [Polymer](https://modrinth.com/mod/polymer) (you may already have it installed as a dependency) - Follow [this guide](https://polymer.pb4.eu/latest/user/resource-pack-hosting/) for up-to-date details on how to host your pack for your specific scenario. -- **Make sure to run** `/polymer generate-pack` and rejoin your server to see the textures properly. - # Obtaining - The crafting recipes, listed in the `Recipes` Section diff --git a/src/main/java/org/agmas/scythes/ScythesItems.java b/src/main/java/org/agmas/scythes/ScythesItems.java index abd618c..f47b5b4 100644 --- a/src/main/java/org/agmas/scythes/ScythesItems.java +++ b/src/main/java/org/agmas/scythes/ScythesItems.java @@ -1,6 +1,7 @@ package org.agmas.scythes; import net.minecraft.item.Item; +import net.minecraft.item.Items; import net.minecraft.item.ToolMaterial; import net.minecraft.item.ToolMaterials; import net.minecraft.registry.Registries; @@ -12,31 +13,31 @@ public class ScythesItems { public static final Item DIAMOND_SCYTHE = register( - new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.DIAMOND, 4f, -3.2f)), ToolMaterials.DIAMOND), + new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.DIAMOND, 4f, -3.2f)), ToolMaterials.DIAMOND, "diamond_scythe", Items.DIAMOND_HOE), "diamond_scythe" ); public static final Item IRON_SCYTHE = register( - new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.IRON, 4f, -3.2f)), ToolMaterials.IRON), + new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.IRON, 4f, -3.2f)), ToolMaterials.IRON, "iron_scythe", Items.IRON_HOE), "iron_scythe" ); public static final Item GOLDEN_SCYTHE = register( - new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.GOLD, 4f, -3.2f)), ToolMaterials.GOLD), + new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.GOLD, 4f, -3.2f)), ToolMaterials.GOLD, "golden_scythe", Items.GOLDEN_HOE), "golden_scythe" ); public static final Item NETHERITE_SCYTHE = register( - new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.NETHERITE, 3.6f, -3.2f)), ToolMaterials.NETHERITE), + new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.NETHERITE, 3.6f, -3.2f)), ToolMaterials.NETHERITE, "netherite_scythe", Items.NETHERITE_HOE), "netherite_scythe" ); public static final Item WOODEN_SCYTHE = register( - new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.WOOD, 4f, -3.2f)), ToolMaterials.WOOD), + new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.WOOD, 4f, -3.2f)), ToolMaterials.WOOD, "wooden_scythe", Items.WOODEN_HOE), "wooden_scythe" ); public static final Item STONE_SCYTHE = register( - new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.STONE, 4f, -3.2f)), ToolMaterials.STONE), + new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(ToolMaterials.STONE, 4f, -3.2f)), ToolMaterials.STONE, "stone_scythe", Items.STONE_HOE), "stone_scythe" ); public static final Item CLOUD_SCYTHE = register( - new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(CloudMaterial.INSTANCE, 4f, -3.2f)), CloudMaterial.INSTANCE), + new Scythe(new Item.Settings().attributeModifiers(Scythe.createAttributeModifiers(CloudMaterial.INSTANCE, 4f, -3.2f)), CloudMaterial.INSTANCE, "cloud_scythe", Items.IRON_HOE), "cloud_scythe" ); diff --git a/src/main/java/org/agmas/scythes/items/Scythe.java b/src/main/java/org/agmas/scythes/items/Scythe.java index 710a437..8be79ef 100644 --- a/src/main/java/org/agmas/scythes/items/Scythe.java +++ b/src/main/java/org/agmas/scythes/items/Scythe.java @@ -33,9 +33,13 @@ public class Scythe extends ToolItem implements PolymerItem { ToolMaterial toolMaterial; + PolymerModelData modelData; + Item item; - public Scythe(Settings settings, ToolMaterial material) { + public Scythe(Settings settings, ToolMaterial material, String modelName, Item item) { super(material, settings); + modelData = PolymerResourcePackUtils.requestModel(item, Identifier.of("scythes", "item/"+modelName)); + this.item = item; toolMaterial = material; } @@ -102,27 +106,6 @@ public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, @Override public ItemStack getPolymerItemStack(ItemStack itemStack, TooltipType tooltipType, RegistryWrapper.WrapperLookup lookup, @Nullable ServerPlayerEntity player) { var itemStack1 = PolymerItem.super.getPolymerItemStack(itemStack, tooltipType, lookup, player); - PolymerModelData modelData = PolymerResourcePackUtils.requestModel(itemStack1.getItem(), Identifier.of("scythes", "item/cloud_scythe")); - if (itemStack.getItem() instanceof Scythe s) { - if (s.toolMaterial == ToolMaterials.IRON) { - modelData = PolymerResourcePackUtils.requestModel(itemStack1.getItem(), Identifier.of("scythes", "item/iron_scythe")); - } - if (s.toolMaterial == ToolMaterials.DIAMOND) { - modelData = PolymerResourcePackUtils.requestModel(itemStack1.getItem(), Identifier.of("scythes", "item/diamond_scythe")); - } - if (s.toolMaterial == ToolMaterials.NETHERITE) { - modelData = PolymerResourcePackUtils.requestModel(itemStack1.getItem(), Identifier.of("scythes", "item/netherite_scythe")); - } - if (s.toolMaterial == ToolMaterials.STONE) { - modelData = PolymerResourcePackUtils.requestModel(itemStack1.getItem(), Identifier.of("scythes", "item/stone_scythe")); - } - if (s.toolMaterial == ToolMaterials.WOOD) { - modelData = PolymerResourcePackUtils.requestModel(itemStack1.getItem(), Identifier.of("scythes", "item/wooden_scythe")); - } - if (s.toolMaterial == ToolMaterials.GOLD) { - modelData = PolymerResourcePackUtils.requestModel(itemStack1.getItem(), Identifier.of("scythes", "item/golden_scythe")); - } - } itemStack1.set(DataComponentTypes.CUSTOM_MODEL_DATA, modelData.asComponent()); return itemStack1; } @@ -135,43 +118,6 @@ public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attack @Override public Item getPolymerItem(ItemStack itemStack, @Nullable ServerPlayerEntity player) { - try { - if (itemStack.getItem() instanceof Scythe s) { - if (s.toolMaterial.equals(CloudMaterial.INSTANCE)) { - return Items.IRON_HOE.asItem(); - } - - /* - - "oh why don't you use a switch statement here" - IDK I TRIED TO AND IT FOR SOME REASOn CAUSED TEN BILLION ERRORS IMS ORRYY - - */ - - if (s.toolMaterial == ToolMaterials.IRON) { - return Items.IRON_HOE.asItem(); - } - if (s.toolMaterial == ToolMaterials.DIAMOND) { - return Items.DIAMOND_HOE.asItem(); - } - if (s.toolMaterial == ToolMaterials.NETHERITE) { - return Items.NETHERITE_HOE.asItem(); - } - if (s.toolMaterial == ToolMaterials.STONE) { - return Items.STONE_HOE.asItem(); - } - if (s.toolMaterial == ToolMaterials.WOOD) { - return Items.WOODEN_HOE.asItem(); - } - if (s.toolMaterial == ToolMaterials.GOLD) { - return Items.GOLDEN_HOE.asItem(); - } - return Items.BEDROCK.asItem(); - } else { - return Items.WOODEN_SWORD.asItem(); - } - } catch (Exception e) { - return Items.DEEPSLATE.asItem(); - } + return item; } }