Skip to content

Commit

Permalink
Start custom item builders
Browse files Browse the repository at this point in the history
  • Loading branch information
IcarussOne committed Aug 6, 2024
1 parent 2a8284f commit b451d6d
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 6 deletions.
18 changes: 18 additions & 0 deletions src/main/java/mod/emt/balkonsexpansion/BEItemBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mod.emt.balkonsexpansion;

import javax.annotation.Nonnull;

import ckathode.weaponmod.WMItemBuilder;
import ckathode.weaponmod.item.ItemMelee;
import mod.emt.balkonsexpansion.item.MeleeCompBattleaxeCustom;
import net.minecraft.item.Item;

public class BEItemBuilder {
public static ItemMelee createCustomBattleaxe(String id, @Nonnull Item.ToolMaterial material) {
return WMItemBuilder.createItemMelee(BalkonsExpansion.MOD_ID, id, new MeleeCompBattleaxeCustom(material, 0.1F, 1.0F));
}

public static ItemMelee createCustomBattleaxe(String id, @Nonnull Item.ToolMaterial material, float knockbackAmount, float ignoreArmorAmount) {
return WMItemBuilder.createItemMelee(BalkonsExpansion.MOD_ID, id, new MeleeCompBattleaxeCustom(material, knockbackAmount, ignoreArmorAmount));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import micdoodle8.mods.galacticraft.planets.asteroids.items.AsteroidsItems;
import micdoodle8.mods.galacticraft.planets.mars.items.MarsItems;
import mod.emt.balkonsexpansion.BEConfig;
import mod.emt.balkonsexpansion.BEItemBuilder;
import mod.emt.balkonsexpansion.BERecipes;
import mod.emt.balkonsexpansion.BERegistry;
import mod.emt.balkonsexpansion.BalkonsExpansion;
Expand Down Expand Up @@ -55,7 +56,7 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
if (BEConfig.galacticraft_settings.GC_HEAVY_DUTY_MATERIAL) {
registry.register(spearHeavyDuty = WMItemBuilder.createStandardSpear(BalkonsExpansion.MOD_ID, "spear.heavy_duty", GCItems.TOOL_STEEL));
registry.register(halberdHeavyDuty = WMItemBuilder.createStandardHalberd(BalkonsExpansion.MOD_ID, "halberd.heavy_duty", GCItems.TOOL_STEEL));
registry.register(battleaxeHeavyDuty = WMItemBuilder.createStandardBattleaxe(BalkonsExpansion.MOD_ID, "battleaxe.heavy_duty", GCItems.TOOL_STEEL));
registry.register(battleaxeHeavyDuty = BEItemBuilder.createCustomBattleaxe("battleaxe.heavy_duty", GCItems.TOOL_STEEL, 0.2F, 1.0F));
registry.register(knifeHeavyDuty = WMItemBuilder.createStandardKnife(BalkonsExpansion.MOD_ID, "knife.heavy_duty", GCItems.TOOL_STEEL));
registry.register(warhammerHeavyDuty = WMItemBuilder.createStandardWarhammer(BalkonsExpansion.MOD_ID, "warhammer.heavy_duty", GCItems.TOOL_STEEL));
registry.register(flailHeavyDuty = WMItemBuilder.createStandardFlail(BalkonsExpansion.MOD_ID, "flail.heavy_duty", GCItems.TOOL_STEEL));
Expand All @@ -67,7 +68,7 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
if (BEConfig.galacticraft_settings.GC_DESH_MATERIAL) {
registry.register(spearDesh = WMItemBuilder.createStandardSpear(BalkonsExpansion.MOD_ID, "spear.desh", MarsItems.TOOLDESH));
registry.register(halberdDesh = WMItemBuilder.createStandardHalberd(BalkonsExpansion.MOD_ID, "halberd.desh", MarsItems.TOOLDESH));
registry.register(battleaxeDesh = WMItemBuilder.createStandardBattleaxe(BalkonsExpansion.MOD_ID, "battleaxe.desh", MarsItems.TOOLDESH));
registry.register(battleaxeDesh = BEItemBuilder.createCustomBattleaxe("battleaxe.desh", MarsItems.TOOLDESH, 0.3F, 1.0F));
registry.register(knifeDesh = WMItemBuilder.createStandardKnife(BalkonsExpansion.MOD_ID, "knife.desh", MarsItems.TOOLDESH));
registry.register(warhammerDesh = WMItemBuilder.createStandardWarhammer(BalkonsExpansion.MOD_ID, "warhammer.desh", MarsItems.TOOLDESH));
registry.register(flailDesh = WMItemBuilder.createStandardFlail(BalkonsExpansion.MOD_ID, "flail.desh", MarsItems.TOOLDESH));
Expand All @@ -79,7 +80,7 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
if (BEConfig.galacticraft_settings.GC_TITANIUM_MATERIAL) {
registry.register(spearTitanium = WMItemBuilder.createStandardSpear(BalkonsExpansion.MOD_ID, "spear.titanium", AsteroidsItems.TOOL_TITANIUM));
registry.register(halberdTitanium = WMItemBuilder.createStandardHalberd(BalkonsExpansion.MOD_ID, "halberd.titanium", AsteroidsItems.TOOL_TITANIUM));
registry.register(battleaxeTitanium = WMItemBuilder.createStandardBattleaxe(BalkonsExpansion.MOD_ID, "battleaxe.titanium", AsteroidsItems.TOOL_TITANIUM));
registry.register(battleaxeTitanium = BEItemBuilder.createCustomBattleaxe("battleaxe.titanium", AsteroidsItems.TOOL_TITANIUM, 0.45F, 1.0F));
registry.register(knifeTitanium = WMItemBuilder.createStandardKnife(BalkonsExpansion.MOD_ID, "knife.titanium", AsteroidsItems.TOOL_TITANIUM));
registry.register(warhammerTitanium = WMItemBuilder.createStandardWarhammer(BalkonsExpansion.MOD_ID, "warhammer.titanium", AsteroidsItems.TOOL_TITANIUM));
registry.register(flailTitanium = WMItemBuilder.createStandardFlail(BalkonsExpansion.MOD_ID, "flail.titanium", AsteroidsItems.TOOL_TITANIUM));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ckathode.weaponmod.item.ItemMusket;
import ic2.core.util.helpers.ToolHelper;
import mod.emt.balkonsexpansion.BEConfig;
import mod.emt.balkonsexpansion.BEItemBuilder;
import mod.emt.balkonsexpansion.BERecipes;
import mod.emt.balkonsexpansion.BERegistry;
import mod.emt.balkonsexpansion.BalkonsExpansion;
Expand Down Expand Up @@ -35,7 +36,7 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
if (BEConfig.ic2_classic_settings.IC2C_BRONZE_MATERIAL) {
registry.register(spearBronze = WMItemBuilder.createStandardSpear(BalkonsExpansion.MOD_ID, "spear.bronze.ic2c", ToolHelper.bronzeToolMaterial));
registry.register(halberdBronze = WMItemBuilder.createStandardHalberd(BalkonsExpansion.MOD_ID, "halberd.bronze.ic2c", ToolHelper.bronzeToolMaterial));
registry.register(battleaxeBronze = WMItemBuilder.createStandardBattleaxe(BalkonsExpansion.MOD_ID, "battleaxe.bronze.ic2c", ToolHelper.bronzeToolMaterial));
registry.register(battleaxeBronze = BEItemBuilder.createCustomBattleaxe("battleaxe.bronze.ic2c", ToolHelper.bronzeToolMaterial, 0.2F, 1.0F));
registry.register(knifeBronze = WMItemBuilder.createStandardKnife(BalkonsExpansion.MOD_ID, "knife.bronze.ic2c", ItemMaterials.STEEL_TOOL));
registry.register(warhammerBronze = WMItemBuilder.createStandardWarhammer(BalkonsExpansion.MOD_ID, "warhammer.bronze.ic2c", ToolHelper.bronzeToolMaterial));
registry.register(flailBronze = WMItemBuilder.createStandardFlail(BalkonsExpansion.MOD_ID, "flail.bronze.ic2c", ToolHelper.bronzeToolMaterial));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ckathode.weaponmod.item.ItemMelee;
import ckathode.weaponmod.item.ItemMusket;
import mod.emt.balkonsexpansion.BEConfig;
import mod.emt.balkonsexpansion.BEItemBuilder;
import mod.emt.balkonsexpansion.BERecipes;
import mod.emt.balkonsexpansion.BERegistry;
import mod.emt.balkonsexpansion.BalkonsExpansion;
Expand Down Expand Up @@ -37,7 +38,7 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
if (BEConfig.railcraft_settings.RC_STEEL_MATERIAL) {
registry.register(spearSteel = WMItemBuilder.createStandardSpear(BalkonsExpansion.MOD_ID, "spear.steel.rc", ItemMaterials.STEEL_TOOL));
registry.register(halberdSteel = WMItemBuilder.createStandardHalberd(BalkonsExpansion.MOD_ID, "halberd.steel.rc", ItemMaterials.STEEL_TOOL));
registry.register(battleaxeSteel = WMItemBuilder.createStandardBattleaxe(BalkonsExpansion.MOD_ID, "battleaxe.steel.rc", ItemMaterials.STEEL_TOOL));
registry.register(battleaxeSteel = BEItemBuilder.createCustomBattleaxe("battleaxe.steel.rc", ItemMaterials.STEEL_TOOL, 0.2F, 1.0F));
registry.register(knifeSteel = WMItemBuilder.createStandardKnife(BalkonsExpansion.MOD_ID, "knife.steel.rc", ItemMaterials.STEEL_TOOL));
registry.register(warhammerSteel = WMItemBuilder.createStandardWarhammer(BalkonsExpansion.MOD_ID, "warhammer.steel.rc", ItemMaterials.STEEL_TOOL));
registry.register(flailSteel = WMItemBuilder.createStandardFlail(BalkonsExpansion.MOD_ID, "flail.steel.rc", ItemMaterials.STEEL_TOOL));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ckathode.weaponmod.item.ItemMelee;
import ckathode.weaponmod.item.ItemMusket;
import mod.emt.balkonsexpansion.BEConfig;
import mod.emt.balkonsexpansion.BEItemBuilder;
import mod.emt.balkonsexpansion.BERecipes;
import mod.emt.balkonsexpansion.BERegistry;
import mod.emt.balkonsexpansion.BalkonsExpansion;
Expand Down Expand Up @@ -46,7 +47,7 @@ public static void registerItems(RegistryEvent.Register<Item> event) {
if (BEConfig.thaumcraft_settings.TC_THAUMIUM_MATERIAL) {
registry.register(spearThaumium = WMItemBuilder.createStandardSpear(BalkonsExpansion.MOD_ID, "spear.thaumium", ThaumcraftMaterials.TOOLMAT_THAUMIUM));
registry.register(halberdThaumium = WMItemBuilder.createStandardHalberd(BalkonsExpansion.MOD_ID, "halberd.thaumium", ThaumcraftMaterials.TOOLMAT_THAUMIUM));
registry.register(battleaxeThaumium = WMItemBuilder.createStandardBattleaxe(BalkonsExpansion.MOD_ID, "battleaxe.thaumium", ThaumcraftMaterials.TOOLMAT_THAUMIUM));
registry.register(battleaxeThaumium = BEItemBuilder.createCustomBattleaxe("battleaxe.thaumium", ThaumcraftMaterials.TOOLMAT_THAUMIUM, 0.2F, 1.0F));
registry.register(knifeThaumium = WMItemBuilder.createStandardKnife(BalkonsExpansion.MOD_ID, "knife.thaumium", ThaumcraftMaterials.TOOLMAT_THAUMIUM));
registry.register(warhammerThaumium = WMItemBuilder.createStandardWarhammer(BalkonsExpansion.MOD_ID, "warhammer.thaumium", ThaumcraftMaterials.TOOLMAT_THAUMIUM));
registry.register(flailThaumium = WMItemBuilder.createStandardFlail(BalkonsExpansion.MOD_ID, "flail.thaumium", ThaumcraftMaterials.TOOLMAT_THAUMIUM));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package mod.emt.balkonsexpansion.item;

import com.google.common.collect.Multimap;

import ckathode.weaponmod.WeaponModAttributes;
import ckathode.weaponmod.item.IExtendedReachItem;
import ckathode.weaponmod.item.IItemWeapon;
import ckathode.weaponmod.item.MeleeCompBattleaxe;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;

// Allows us to set custom attribute amount for our battleaxes.
public class MeleeCompBattleaxeCustom extends MeleeCompBattleaxe {
private float knockbackAmount;
private float ignoreArmorAmount;

public MeleeCompBattleaxeCustom(ToolMaterial material, float knockbackAmount, float ignoreArmorAmount) {
super(material);
this.knockbackAmount = knockbackAmount;
this.ignoreArmorAmount = ignoreArmorAmount;
}

@Override
public float getKnockBack(ItemStack itemstack, EntityLivingBase entityliving, EntityLivingBase attacker) {
// Must include (+ 0.4F), otherwise it'll calculate wrong.
return knockbackAmount + 0.4F;
}

@Override
public float getIgnoreArmorAmount(ToolMaterial material) {
return ignoreArmorAmount;
}

@Override
public void addItemAttributeModifiers(Multimap<String, AttributeModifier> multimap) {
float dmg = getEntityDamage();

if (dmg > 0.0f || meleeSpecs.damageMult > 0.0f) {
multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(IItemWeapon.ATTACK_DAMAGE_MODIFIER, "Weapon attack damage modifier", dmg, 0));
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(IItemWeapon.ATTACK_SPEED_MODIFIER, "Weapon attack speed modifier", -meleeSpecs.attackDelay, 0));
}

if (knockbackAmount != 0.0f) {
multimap.put(WeaponModAttributes.WEAPON_KNOCKBACK.getName(),
new AttributeModifier(IItemWeapon.KNOCKBACK_MODIFIER, "Weapon knockback modifier", this.knockbackAmount, 0));
}

if (this instanceof IExtendedReachItem) {
try {
multimap.put(WeaponModAttributes.WEAPON_REACH.getName(), new AttributeModifier(IItemWeapon.REACH_MODIFIER, "Weapon reach modifier",
((IExtendedReachItem) this).getExtendedReach(null, null, null) - 3.0f, 0));
} catch (NullPointerException ignored) {
}
}

if (getIgnoreArmorAmount(weaponMaterial) != 0.0f) {
multimap.put(WeaponModAttributes.IGNORE_ARMOUR_DAMAGE.getName(),
new AttributeModifier(IItemWeapon.IGNORE_ARMOUR_MODIFIER, "Weapon ignore armour modifier", getIgnoreArmorAmount(weaponMaterial), 0));
}
}
}

0 comments on commit b451d6d

Please sign in to comment.