Skip to content

Commit

Permalink
rp work
Browse files Browse the repository at this point in the history
  • Loading branch information
agmass committed Sep 16, 2024
1 parent f892332 commit e888820
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 69 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/org/agmas/scythes/ScythesItems.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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"
);

Expand Down
66 changes: 6 additions & 60 deletions src/main/java/org/agmas/scythes/items/Scythe.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
}

0 comments on commit e888820

Please sign in to comment.