Skip to content

Commit

Permalink
- Added constants to represent weapon parents
Browse files Browse the repository at this point in the history
- Turned the key for the weaponWithParent map into a ResourceKey
- Removed unnecessary early return
  • Loading branch information
Dweblenod committed Jun 2, 2024
1 parent 0c83a1c commit 5e4334e
Showing 1 changed file with 106 additions and 84 deletions.
190 changes: 106 additions & 84 deletions src/main/java/com/mraof/minestuck/data/BetterCombatProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataProvider;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.item.Item;
import net.neoforged.neoforge.registries.DeferredItem;

Expand All @@ -23,9 +24,33 @@
@MethodsReturnNonnullByDefault
public class BetterCombatProvider implements DataProvider
{
private static final String SICKLE = "bettercombat:sickle";
private static final String SCYTHE = "bettercombat:scythe";
private static final String CLAW = "bettercombat:claw";
private static final String PICKAXE = "bettercombat:pickaxe";
private static final String HAMMER = "bettercombat:hammer";
private static final String AXE = "bettercombat:axe";
private static final String HEAVY_AXE = "bettercombat:heavy_axe";
private static final String CHAINSAW = "minestuck:chainsaw_base";
private static final String MACE = "bettercombat:mace";
private static final String SWORD = "bettercombat:sword";
private static final String KATANA = "bettercombat:katana";
private static final String CUTLASS = "bettercombat:cutlass";
private static final String CLAYMORE = "bettercombat:claymore";
private static final String RAPIER = "bettercombat:rapier";
private static final String DAGGER = "bettercombat:dagger";
private static final String LANCE = "bettercombat:lance";
private static final String STAFF = "bettercombat:battlestaff";
private static final String CANE = "minestuck:cane_base";
private static final String FORK = "minestuck:fork_base";
private static final String WAND = "bettercombat:wand";
private static final String HALBERD = "bettercombat:halberd";
private static final String SPEAR = "bettercombat:spear";
private static final String TRIDENT = "bettercombat:trident";

private final PackOutput output;

Map<String, String> weaponWithParent = new HashMap<>();
private final Map<ResourceKey<Item>, String> weaponWithParent = new HashMap<>();

public BetterCombatProvider(PackOutput output)
{
Expand All @@ -44,27 +69,24 @@ public final CompletableFuture<?> run(CachedOutput cache)

MSItems.REGISTER.getEntries().forEach(weaponHolder ->
{
if(weaponHolder.asOptional().isEmpty())
return;

if(weaponHolder.get() instanceof WeaponItem weaponItem && weaponItem.getToolType() != null)
{
String parent = getWeaponParent(weaponItem.getToolType());

if(!parent.isEmpty())
weaponWithParent.put(weaponHolder.getKey().location().getPath(), parent);
weaponWithParent.put(weaponHolder.getKey(), parent);
}
});

customWeapons();

for(Map.Entry<String, String> entry : weaponWithParent.entrySet())
for(Map.Entry<ResourceKey<Item>, String> entry : weaponWithParent.entrySet())
{
JsonObject object = new JsonObject();

object.addProperty("parent", entry.getValue());

futures.add(DataProvider.saveStable(cache, object, basePath.resolve(entry.getKey() + ".json")));
futures.add(DataProvider.saveStable(cache, object, basePath.resolve(entry.getKey().location().getPath() + ".json")));
}

return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
Expand All @@ -73,106 +95,106 @@ public final CompletableFuture<?> run(CachedOutput cache)
public String getWeaponParent(MSToolType toolType)
{
if(toolType == SICKLE_TOOL)
return "bettercombat:sickle";
return SICKLE;
else if(toolType == SCYTHE_TOOL)
return "bettercombat:scythe";
return SCYTHE;
else if(toolType == CLAWS_TOOL)
return "bettercombat:claw";
return CLAW;
else if(toolType == PICKAXE_TOOL)
return "bettercombat:pickaxe";
return PICKAXE;
else if(toolType == HAMMER_TOOL)
return "bettercombat:hammer";
return HAMMER;
else if(toolType == AXE_TOOL)
return "bettercombat:axe";
return AXE;
else if(toolType == CHAINSAW_TOOL)
return "minestuck:chainsaw_base";
return CHAINSAW;
else if(toolType == CLUB_TOOL || toolType == SHOVEL_TOOL)
return "bettercombat:mace";
return MACE;
else if(toolType == SWORD_TOOL || toolType == KEY_TOOL || toolType == BATON_TOOL)
return "bettercombat:sword";
return SWORD;
else if(toolType == KNIFE_TOOL || toolType == FAN_TOOL)
return "bettercombat:dagger";
return DAGGER;
else if(toolType == LANCE_TOOL)
return "bettercombat:lance";
return LANCE;
else if(toolType == STAFF_TOOL)
return "bettercombat:battlestaff";
return STAFF;
else if(toolType == CANE_TOOL)
return "minestuck:cane_base";
return CANE;
else if(toolType == FORK_TOOL)
return "minestuck:fork_base";
return FORK;
else if(toolType == WAND_TOOL)
return "bettercombat:wand";
return WAND;
return "";
}

public void customWeapons()
{
addWeapon(MSItems.MAILBOX, "bettercombat:hammer");
addWeapon(MSItems.ESTROGEN_EMPOWERED_EVERYTHING_ERADICATOR, "bettercombat:hammer");
addWeapon(MSItems.BOOMBOX_BEATER, "bettercombat:hammer");

addWeapon(MSItems.CLAW_HAMMER, "bettercombat:mace");
addWeapon(MSItems.BLACKSMITH_HAMMER, "bettercombat:mace");

addWeapon(MSItems.SWONGE, "bettercombat:sword");
addWeapon(MSItems.WET_SWONGE, "bettercombat:sword");
addWeapon(MSItems.PUMORD, "bettercombat:sword");
addWeapon(MSItems.WET_PUMORD, "bettercombat:sword");
addWeapon(MSItems.MUSIC_SWORD, "bettercombat:sword");

addWeapon(MSItems.CHAINSAW_KATANA, "bettercombat:katana");
addWeapon(MSItems.KATANA, "bettercombat:katana");
addWeapon(MSItems.UNBREAKABLE_KATANA, "bettercombat:katana");

addWeapon(MSItems.CACTACEAE_CUTLASS, "bettercombat:cutlass");
addWeapon(MSItems.CUTLASS_OF_ZILLYWAIR, "bettercombat:cutlass");
addWeapon(MSItems.SCARLET_RIBBITAR, "bettercombat:cutlass");
addWeapon(MSItems.TOO_HOT_TO_HANDLE, "bettercombat:cutlass");
addWeapon(MSItems.COBALT_SABRE, "bettercombat:cutlass");

addWeapon(MSItems.CLAYMORE, "bettercombat:claymore");
addWeapon(MSItems.MACUAHUITL, "bettercombat:claymore");
addWeapon(MSItems.FROSTY_MACUAHUITL, "bettercombat:claymore");
addWeapon(MSItems.CRUEL_FATE_CRUCIBLE, "bettercombat:claymore");
addWeapon(MSItems.SUBTRACTSHUMIDIRE_ZOMORRODNEGATIVE, "bettercombat:claymore");

addWeapon(MSItems.ANGEL_APOCALYPSE, "bettercombat:rapier");
addWeapon(MSItems.FIRE_POKER, "bettercombat:rapier");

addWeapon(MSItems.NIFE, "bettercombat:dagger");

addWeapon(MSItems.BATTLEAXE, "bettercombat:heavy_axe");
addWeapon(MSItems.CANDY_BATTLEAXE, "bettercombat:heavy_axe");
addWeapon(MSItems.CHOCO_LOCO_WOODSPLITTER, "bettercombat:heavy_axe");
addWeapon(MSItems.STEEL_EDGE_CANDYCUTTER, "bettercombat:heavy_axe");
addWeapon(MSItems.PISTON_POWERED_POGO_AXEHAMMER, "bettercombat:heavy_axe");
addWeapon(MSItems.FISSION_FOCUSED_FAULT_FELLER, "bettercombat:heavy_axe");
addWeapon(MSItems.BISECTOR, "bettercombat:heavy_axe");
addWeapon(MSItems.FINE_CHINA_AXE, "bettercombat:heavy_axe");

addWeapon(MSItems.LUCERNE_HAMMER, "bettercombat:halberd");
addWeapon(MSItems.LUCERNE_HAMMER_OF_UNDYING, "bettercombat:halberd");

addWeapon(MSItems.OBSIDIAN_AXE_KNIFE, "bettercombat:claw");

addWeapon(MSItems.PROSPECTING_PICKSCYTHE, "bettercombat:scythe");

addWeapon(MSItems.CUESTICK, "bettercombat:lance");
addWeapon(MSItems.TV_ANTENNA, "bettercombat:sword");

addWeapon(MSItems.CROWBAR, "bettercombat:heavy_axe");
addWeapon(MSItems.UMBRELLA, "minestuck:fork_base");
addWeapon(MSItems.BARBERS_BEST_FRIEND, "minestuck:fork_base");
addWeapon(MSItems.SPEAR_CANE, "bettercombat:spear");

addWeapon(MSItems.MEATFORK, "bettercombat:trident");
addWeapon(MSItems.BIDENT, "bettercombat:trident");
addWeapon(MSItems.DOUBLE_ENDED_TRIDENT, "bettercombat:trident");
addWeapon(MSItems.MAILBOX, HAMMER);
addWeapon(MSItems.ESTROGEN_EMPOWERED_EVERYTHING_ERADICATOR, HAMMER);
addWeapon(MSItems.BOOMBOX_BEATER, HAMMER);

addWeapon(MSItems.CLAW_HAMMER, MACE);
addWeapon(MSItems.BLACKSMITH_HAMMER, MACE);

addWeapon(MSItems.SWONGE, SWORD);
addWeapon(MSItems.WET_SWONGE, SWORD);
addWeapon(MSItems.PUMORD, SWORD);
addWeapon(MSItems.WET_PUMORD, SWORD);
addWeapon(MSItems.MUSIC_SWORD, SWORD);

addWeapon(MSItems.CHAINSAW_KATANA, KATANA);
addWeapon(MSItems.KATANA, KATANA);
addWeapon(MSItems.UNBREAKABLE_KATANA, KATANA);

addWeapon(MSItems.CACTACEAE_CUTLASS, CUTLASS);
addWeapon(MSItems.CUTLASS_OF_ZILLYWAIR, CUTLASS);
addWeapon(MSItems.SCARLET_RIBBITAR, CUTLASS);
addWeapon(MSItems.TOO_HOT_TO_HANDLE, CUTLASS);
addWeapon(MSItems.COBALT_SABRE, CUTLASS);

addWeapon(MSItems.CLAYMORE, CLAYMORE);
addWeapon(MSItems.MACUAHUITL, CLAYMORE);
addWeapon(MSItems.FROSTY_MACUAHUITL, CLAYMORE);
addWeapon(MSItems.CRUEL_FATE_CRUCIBLE, CLAYMORE);
addWeapon(MSItems.SUBTRACTSHUMIDIRE_ZOMORRODNEGATIVE, CLAYMORE);

addWeapon(MSItems.ANGEL_APOCALYPSE, RAPIER);
addWeapon(MSItems.FIRE_POKER, RAPIER);

addWeapon(MSItems.NIFE, DAGGER);

addWeapon(MSItems.BATTLEAXE, HEAVY_AXE);
addWeapon(MSItems.CANDY_BATTLEAXE, HEAVY_AXE);
addWeapon(MSItems.CHOCO_LOCO_WOODSPLITTER, HEAVY_AXE);
addWeapon(MSItems.STEEL_EDGE_CANDYCUTTER, HEAVY_AXE);
addWeapon(MSItems.PISTON_POWERED_POGO_AXEHAMMER, HEAVY_AXE);
addWeapon(MSItems.FISSION_FOCUSED_FAULT_FELLER, HEAVY_AXE);
addWeapon(MSItems.BISECTOR, HEAVY_AXE);
addWeapon(MSItems.FINE_CHINA_AXE, HEAVY_AXE);

addWeapon(MSItems.LUCERNE_HAMMER, HALBERD);
addWeapon(MSItems.LUCERNE_HAMMER_OF_UNDYING, HALBERD);

addWeapon(MSItems.OBSIDIAN_AXE_KNIFE, CLAW);

addWeapon(MSItems.PROSPECTING_PICKSCYTHE, SCYTHE);

addWeapon(MSItems.CUESTICK, LANCE);
addWeapon(MSItems.TV_ANTENNA, SWORD);

addWeapon(MSItems.CROWBAR, HEAVY_AXE);
addWeapon(MSItems.UMBRELLA, FORK);
addWeapon(MSItems.BARBERS_BEST_FRIEND, FORK);
addWeapon(MSItems.SPEAR_CANE, SPEAR);

addWeapon(MSItems.MEATFORK, TRIDENT);
addWeapon(MSItems.BIDENT, TRIDENT);
addWeapon(MSItems.DOUBLE_ENDED_TRIDENT, TRIDENT);
}

public void addWeapon(DeferredItem<Item> weapon, String parent)
{
weaponWithParent.put(weapon.getKey().location().getPath(), parent);
weaponWithParent.put(weapon.getKey(), parent);
}

@Override
Expand Down

0 comments on commit 5e4334e

Please sign in to comment.