-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
274 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/it/hurts/metallurgy_reforged/integration/IntegrationSW.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/*============================================================================== | ||
= Class: IntegrationSW | ||
= This class is part of Metallurgy 4: Reforged | ||
= Complete source code is available at https://github.com/Davoleo/Metallurgy-4-Reforged | ||
= This code is licensed under GNU GPLv3 | ||
= Authors: Davoleo, ItHurtsLikeHell, PierKnight100 | ||
= Copyright (c) 2018-2024. | ||
=============================================================================*/ | ||
|
||
package it.hurts.metallurgy_reforged.integration; | ||
|
||
import com.oblivioussp.spartanweaponry.api.IWeaponCallback; | ||
import com.oblivioussp.spartanweaponry.api.SpartanWeaponryAPI; | ||
import it.hurts.metallurgy_reforged.Metallurgy; | ||
import it.hurts.metallurgy_reforged.integration.spartanweaponry.SpartanMetal; | ||
import it.hurts.metallurgy_reforged.integration.spartanweaponry.SpartanMetallurgyTab; | ||
import it.hurts.metallurgy_reforged.integration.spartanweaponry.SpartanWeaponType; | ||
import it.hurts.metallurgy_reforged.material.ModMetals; | ||
import net.minecraft.item.Item; | ||
import net.minecraftforge.registries.IForgeRegistry; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class IntegrationSW { | ||
|
||
public static final String MODID = "spartanweaponry"; | ||
|
||
public static final IWeaponCallback NOOP = (material, stack, world, tooltip, flag) -> { | ||
}; | ||
|
||
public static final SpartanMetallurgyTab CREATIVE_TAB = new SpartanMetallurgyTab(); | ||
|
||
public static final List<SpartanMetal> spartanMetals = new ArrayList<>(); | ||
|
||
public static void registerItems(IForgeRegistry<Item> registry) { | ||
ModMetals.metalMap.forEach((name, metal) -> { | ||
if (metal.hasToolSet()) { | ||
spartanMetals.add(new SpartanMetal(registry, metal.getStats())); | ||
} | ||
}); | ||
|
||
spartanMetals.forEach(spartanMetal -> { | ||
SpartanWeaponryAPI.registerColourHandler( | ||
spartanMetal.getMaterialEx(), | ||
spartanMetal.getItems().values().toArray(new Item[0]) | ||
); | ||
|
||
for (SpartanWeaponType weaponType : SpartanWeaponType.values()) { | ||
SpartanWeaponryAPI.addItemModelToRegistry(spartanMetal.getWeapon(weaponType), | ||
Metallurgy.MODID, IntegrationSW.MODID + '/' + weaponType.name().toLowerCase()); | ||
} | ||
}); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...va/it/hurts/metallurgy_reforged/integration/spartanweaponry/ISpartanWeaponInitalizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/*============================================================================== | ||
= Class: SpartanWeaponInitalizer | ||
= This class is part of Metallurgy 4: Reforged | ||
= Complete source code is available at https://github.com/Davoleo/Metallurgy-4-Reforged | ||
= This code is licensed under GNU GPLv3 | ||
= Authors: Davoleo, ItHurtsLikeHell, PierKnight100 | ||
= Copyright (c) 2018-2024. | ||
=============================================================================*/ | ||
|
||
package it.hurts.metallurgy_reforged.integration.spartanweaponry; | ||
|
||
import com.oblivioussp.spartanweaponry.api.ToolMaterialEx; | ||
import com.oblivioussp.spartanweaponry.api.weaponproperty.WeaponProperty; | ||
import net.minecraft.creativetab.CreativeTabs; | ||
import net.minecraft.item.Item; | ||
|
||
@FunctionalInterface | ||
public interface ISpartanWeaponInitalizer { | ||
|
||
Item create(ToolMaterialEx toolMaterialEx, String modid, CreativeTabs creativeTab, WeaponProperty... properties); | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanMetal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*============================================================================== | ||
= Class: SpartanMetal | ||
= This class is part of Metallurgy 4: Reforged | ||
= Complete source code is available at https://github.com/Davoleo/Metallurgy-4-Reforged | ||
= This code is licensed under GNU GPLv3 | ||
= Authors: Davoleo, ItHurtsLikeHell, PierKnight100 | ||
= Copyright (c) 2018-2024. | ||
=============================================================================*/ | ||
|
||
package it.hurts.metallurgy_reforged.integration.spartanweaponry; | ||
|
||
import com.google.common.base.CaseFormat; | ||
import com.google.common.collect.Maps; | ||
import com.oblivioussp.spartanweaponry.api.ToolMaterialEx; | ||
import it.hurts.metallurgy_reforged.Metallurgy; | ||
import it.hurts.metallurgy_reforged.integration.IntegrationSW; | ||
import it.hurts.metallurgy_reforged.material.MetalStats; | ||
import net.minecraft.item.Item; | ||
import net.minecraftforge.registries.IForgeRegistry; | ||
|
||
import java.util.Map; | ||
|
||
public class SpartanMetal { | ||
|
||
private final MetalStats stats; | ||
|
||
private final ToolMaterialEx toolMaterial; | ||
|
||
private final Map<SpartanWeaponType, Item> items = Maps.newEnumMap(SpartanWeaponType.class); | ||
|
||
public SpartanMetal(IForgeRegistry<Item> registry, MetalStats stats) { | ||
this.stats = stats; | ||
|
||
final String ingotOre = "ingot" + CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, stats.getName()); | ||
final int metalColor = stats.getColorHex(); | ||
this.toolMaterial = new ToolMaterialEx( | ||
stats.getName(), ingotOre, Metallurgy.MODID, metalColor, metalColor, | ||
stats.getToolMaterial().getHarvestLevel(), stats.getToolMaterial().getMaxUses(), stats.getToolMaterial().getEfficiency(), | ||
stats.getToolMaterial().getAttackDamage(), stats.getToolMaterial().getEnchantability() | ||
); | ||
|
||
for (SpartanWeaponType type : SpartanWeaponType.values()) { | ||
final Item weapon = type.initializer.create(toolMaterial, Metallurgy.MODID, IntegrationSW.CREATIVE_TAB); | ||
items.put(type, weapon); | ||
|
||
if (weapon != null) { | ||
registry.register(weapon); | ||
} | ||
} | ||
} | ||
|
||
public MetalStats getStats() { | ||
return stats; | ||
} | ||
|
||
public ToolMaterialEx getMaterialEx() { | ||
return toolMaterial; | ||
} | ||
|
||
public Map<SpartanWeaponType, Item> getItems() { | ||
return items; | ||
} | ||
|
||
public Item getWeapon(SpartanWeaponType type) { | ||
return items.get(type); | ||
} | ||
|
||
public boolean isWeaponEnabled(SpartanWeaponType type) { | ||
return items.get(type) != null; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...n/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanMetallurgyTab.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/*============================================================================== | ||
= Class: SpartanMetallurgyTab | ||
= This class is part of Metallurgy 4: Reforged | ||
= Complete source code is available at https://github.com/Davoleo/Metallurgy-4-Reforged | ||
= This code is licensed under GNU GPLv3 | ||
= Authors: Davoleo, ItHurtsLikeHell, PierKnight100 | ||
= Copyright (c) 2018-2024. | ||
=============================================================================*/ | ||
|
||
package it.hurts.metallurgy_reforged.integration.spartanweaponry; | ||
|
||
import it.hurts.metallurgy_reforged.integration.IntegrationSW; | ||
import it.hurts.metallurgy_reforged.util.MetallurgyTabs; | ||
import net.minecraft.item.ItemStack; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class SpartanMetallurgyTab extends MetallurgyTabs { | ||
|
||
public SpartanMetallurgyTab() { | ||
super(9, IntegrationSW.MODID); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public ItemStack createIcon() { | ||
return new ItemStack(IntegrationSW.spartanMetals.get(0).getWeapon(SpartanWeaponType.KATANA)); | ||
} | ||
} |
Oops, something went wrong.