Skip to content

Commit

Permalink
armor renders/new weapons
Browse files Browse the repository at this point in the history
  • Loading branch information
Bandit-bytes committed Aug 1, 2024
1 parent c6e761d commit a288d73
Show file tree
Hide file tree
Showing 41 changed files with 568 additions and 60 deletions.
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ repositories {
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven {url 'https://libs.azuredoom.com:4443/mods'}
maven { url "https://maven.shedaniel.me/" }
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/"
}

maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
}

fabricApi {
Expand All @@ -30,6 +43,7 @@ dependencies {

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "mod.azure.azurelib:azurelib-fabric-${project.minecraft_version}:${project.azurelib_version}"

}

Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ maven_group=net.bandit.black_iron
archives_base_name=black-iron

# Dependencies
fabric_version=0.92.2+1.20.1
fabric_version=0.92.2+1.20.1
azurelib_version=2.0.18
2 changes: 2 additions & 0 deletions src/main/java/net/bandit/black_iron/BlackIronMod.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.bandit.black_iron;


import mod.azure.azurelib.AzureLib;
import net.bandit.black_iron.item.ModItemGroups;
import net.bandit.black_iron.item.ModItems;
import net.bandit.black_iron.client.ModItemPropertiesClient;
Expand All @@ -17,6 +18,7 @@ public class BlackIronMod implements ModInitializer {
@Override
public void onInitialize() {
ModItemGroups.registerItemGroups();
AzureLib.initialize();

ModItems.registerModItems();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.bandit.black_iron.client.model;

import mod.azure.azurelib.model.GeoModel;
import net.bandit.black_iron.BlackIronMod;
import net.bandit.black_iron.item.custom.CustomHelmet;
import net.minecraft.resources.ResourceLocation;

public class CustomHelmetModel extends GeoModel<CustomHelmet> {
private static final ResourceLocation model = new ResourceLocation(BlackIronMod.MOD_ID, "geo/blackironhelmet.geo.json");
private static final ResourceLocation texture = new ResourceLocation(BlackIronMod.MOD_ID, "textures/item/black_iron_helmet.png");
private static final ResourceLocation animation = new ResourceLocation(BlackIronMod.MOD_ID, "geo/black_iron_helmet.json");
@Override
public ResourceLocation getModelResource(CustomHelmet customHelmet) {
return model;
}

@Override
public ResourceLocation getTextureResource(CustomHelmet customHelmet) {
return texture;
}

@Override
public ResourceLocation getAnimationResource(CustomHelmet customHelmet) {
return animation;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package net.bandit.black_iron.client.renderer;

import mod.azure.azurelib.renderer.GeoArmorRenderer;
import net.bandit.black_iron.client.model.CustomHelmetModel;
import net.bandit.black_iron.item.custom.CustomHelmet;
import net.minecraft.resources.ResourceLocation;

public class CustomHelmetRenderer extends GeoArmorRenderer<CustomHelmet> {

public CustomHelmetRenderer() {
super(new CustomHelmetModel());

}

}
4 changes: 3 additions & 1 deletion src/main/java/net/bandit/black_iron/item/ModItemGroups.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
public class ModItemGroups {
public static final CreativeModeTab BLACK_IRON_GROUP = Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB,
new ResourceLocation(BlackIronMod.MOD_ID, "black_iron"),
FabricItemGroup.builder().title(Component.translatable("itemGroup.black_iron"))
FabricItemGroup.builder().title(Component.translatable("itemgroup.black_iron"))
.icon(() -> new ItemStack(ModItems.BLACK_IRON_BOW))
.displayItems((displayContext, entries) -> {
entries.accept(ModItems.BLACK_IRON);
entries.accept(ModItems.BLACK_IRON_BOW);
entries.accept(ModItems.BLACK_IRON_SWORD);
entries.accept(ModItems.BLACK_IRON_AXE);
entries.accept(ModItems.BLACK_IRON_HELMET);
entries.accept(ModItems.BLACK_IRON_CHESTPLATE);
entries.accept(ModItems.BLACK_IRON_LEGGINGS);
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/net/bandit/black_iron/item/ModItems.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package net.bandit.black_iron.item;

import net.bandit.black_iron.BlackIronMod;
import net.bandit.black_iron.item.custom.BlackIronAxe;
import net.bandit.black_iron.item.custom.BlackIronBow;
import net.bandit.black_iron.item.custom.BlackIronSword;
import net.bandit.black_iron.item.custom.CustomHelmet;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Rarity;

public class ModItems {

Expand All @@ -16,9 +20,16 @@ public class ModItems {
public static final Item BLACK_IRON_BOW = registerItem("black_iron_bow", new BlackIronBow(new FabricItemSettings()));

public static final Item BLACK_IRON_HELMET = registerItem("black_iron_helmet",
new ArmorItem(ModArmorMaterials.BLACK_IRON, ArmorItem.Type.HELMET, new FabricItemSettings()));
new CustomHelmet(ModArmorMaterials.BLACK_IRON, ArmorItem.Type.HELMET, new FabricItemSettings()));

public static final Item BLACK_IRON_CHESTPLATE = registerItem("black_iron_chestplate",
new ArmorItem(ModArmorMaterials.BLACK_IRON, ArmorItem.Type.CHESTPLATE, new FabricItemSettings()));
public static final Item BLACK_IRON_SWORD = registerItem("black_iron_sword",
new BlackIronSword(ModToolMaterial.BLACK_IRON, 3, -2.4F,
new Item.Properties().rarity(Rarity.UNCOMMON)));
public static final Item BLACK_IRON_AXE = registerItem("black_iron_axe",
new BlackIronAxe(ModToolMaterial.BLACK_IRON, 6.0f, -3.1f,
new Item.Properties()));
public static final Item BLACK_IRON_LEGGINGS = registerItem("black_iron_leggings",
new ArmorItem(ModArmorMaterials.BLACK_IRON, ArmorItem.Type.LEGGINGS, new FabricItemSettings()));
public static final Item BLACK_IRON_BOOTS = registerItem("black_iron_boots",
Expand All @@ -33,4 +44,4 @@ private static Item registerItem(String name, Item item) {
public static void registerModItems() {
System.out.println("Registering Mod Items for " + BlackIronMod.MOD_ID);
}
}
}
71 changes: 71 additions & 0 deletions src/main/java/net/bandit/black_iron/item/custom/BlackIronAxe.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package net.bandit.black_iron.item.custom;

import net.bandit.black_iron.item.ModToolMaterial;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.AxeItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class BlackIronAxe extends AxeItem {

public BlackIronAxe(ModToolMaterial tier, float attackDamage, float attackSpeed, Properties properties) {
super(tier, attackDamage, attackSpeed, properties
.stacksTo(1) // Set the max stack count to 1
.rarity(Rarity.RARE)); // Set the rarity to rare
}

@Override
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
if (attacker instanceof Player player) {
Level world = attacker.level();
BlockPos pos = target.blockPosition();
AABB areaOfEffect = new AABB(pos).inflate(3);

List<LivingEntity> entities = world.getEntitiesOfClass(LivingEntity.class, areaOfEffect, entity -> entity != attacker && entity != target);
for (LivingEntity entity : entities) {
entity.hurt(target.damageSources().playerAttack(player), 4.0F);
}

// Play sound effect
world.playSound(null, pos, SoundEvents.PLAYER_ATTACK_SWEEP, SoundSource.PLAYERS, 1.0F, 1.0F);
}
return super.hurtEnemy(stack, target, attacker);
}

@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
ItemStack itemStack = player.getItemInHand(hand);
if (!level.isClientSide()) {
List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, player.getBoundingBox().inflate(3), entity -> entity != player);
for (LivingEntity entity : entities) {
entity.hurt(player.damageSources().playerAttack(player), 3.0F);
}
player.getCooldowns().addCooldown(this, 80);
level.playSound(null, player.blockPosition(), SoundEvents.AXE_STRIP, SoundSource.PLAYERS, 1.0F, 1.0F);
return InteractionResultHolder.success(itemStack);
}
return InteractionResultHolder.pass(itemStack);
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag context) {
tooltip.add(Component.translatable("item.black_iron.black_iron_axe.tooltip1").withStyle(net.minecraft.ChatFormatting.GRAY));
tooltip.add(Component.translatable("item.black_iron.black_iron_axe.tooltip2").withStyle(net.minecraft.ChatFormatting.DARK_PURPLE));
tooltip.add(Component.translatable("item.black_iron.black_iron_axe.tooltip3").withStyle(net.minecraft.ChatFormatting.GOLD));
super.appendHoverText(stack, world, tooltip, context);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package net.bandit.black_iron.item.custom;

import net.bandit.black_iron.item.ModToolMaterial;
import net.minecraft.core.BlockPos;;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class BlackIronSword extends SwordItem {

public BlackIronSword(ModToolMaterial tier, int attackDamage, float attackSpeed, Properties properties) {
super(tier, attackDamage, attackSpeed, properties
.stacksTo(1)
.rarity(Rarity.EPIC));
}

@Override
public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) {
if (attacker instanceof Player player) {
Level world = attacker.level();
BlockPos pos = target.blockPosition();
AABB areaOfEffect = new AABB(pos).inflate(3);

List<LivingEntity> entities = world.getEntitiesOfClass(LivingEntity.class, areaOfEffect, entity -> entity != attacker && entity != target);
for (LivingEntity entity : entities) {
entity.hurt(target.damageSources().playerAttack(player), 5.0F);
}

world.playSound(null, pos, SoundEvents.PLAYER_ATTACK_CRIT, SoundSource.PLAYERS, 1.0F, 1.0F);
}
return super.hurtEnemy(stack, target, attacker);
}

@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
ItemStack itemStack = player.getItemInHand(hand);
if (!level.isClientSide()) {
List<LivingEntity> entities = level.getEntitiesOfClass(LivingEntity.class, player.getBoundingBox().inflate(3), entity -> entity != player);
for (LivingEntity entity : entities) {
entity.setSecondsOnFire(5);
}
player.getCooldowns().addCooldown(this, 100);
level.playSound(null, player.blockPosition(), SoundEvents.ENDER_DRAGON_GROWL, SoundSource.PLAYERS, 0.5F, 0.5F);
return InteractionResultHolder.success(itemStack);
}
return InteractionResultHolder.pass(itemStack);
}

@Override
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag context) {
tooltip.add(Component.translatable("item.black_iron.black_iron_sword.tooltip1").withStyle(net.minecraft.ChatFormatting.GRAY));
tooltip.add(Component.translatable("item.black_iron.black_iron_sword.tooltip2").withStyle(net.minecraft.ChatFormatting.DARK_PURPLE));
tooltip.add(Component.translatable("item.black_iron.black_iron_sword.tooltip3").withStyle(net.minecraft.ChatFormatting.GOLD));
super.appendHoverText(stack, world, tooltip, context);
}
}
68 changes: 68 additions & 0 deletions src/main/java/net/bandit/black_iron/item/custom/CustomHelmet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package net.bandit.black_iron.item.custom;

import mod.azure.azurelib.animatable.GeoItem;
import mod.azure.azurelib.animatable.client.RenderProvider;
import mod.azure.azurelib.core.animatable.instance.AnimatableInstanceCache;
import mod.azure.azurelib.core.animation.AnimatableManager;
import mod.azure.azurelib.core.animation.AnimationController;
import mod.azure.azurelib.core.object.PlayState;
import mod.azure.azurelib.util.AzureLibUtil;
import net.bandit.black_iron.client.renderer.CustomHelmetRenderer;
import net.minecraft.ChatFormatting;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.*;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.function.Consumer;
import java.util.function.Supplier;

public class CustomHelmet extends ArmorItem implements GeoItem {

private final AnimatableInstanceCache cache = AzureLibUtil.createInstanceCache(this);
private final Supplier<Object> renderProvider = GeoItem.makeRenderer(this);

public CustomHelmet(ArmorMaterial material, ArmorItem.Type type, Item.Properties properties) {
super(material, type, properties);
}

@Override
public void appendHoverText(ItemStack itemStack, @Nullable Level level, List<Component> list, TooltipFlag tooltipFlag) {
list.add(Component.literal("A helmet forged from Black Iron").withStyle(ChatFormatting.DARK_GRAY));
super.appendHoverText(itemStack, level, list, tooltipFlag);
}

@Override
public void createRenderer(Consumer<Object> consumer) {
consumer.accept(new RenderProvider() {
private CustomHelmetRenderer renderer;

@Override
public HumanoidModel<LivingEntity> getHumanoidArmorModel(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<LivingEntity> original) {
if (renderer == null) renderer = new CustomHelmetRenderer();

renderer.prepForRender(livingEntity, itemStack, equipmentSlot, original);
return renderer;
}
});
}

@Override
public Supplier<Object> getRenderProvider() {
return renderProvider;
}

@Override
public void registerControllers(AnimatableManager.ControllerRegistrar controllerRegistrar) {
controllerRegistrar.add(new AnimationController<>(this, "controllerName", 0, event -> PlayState.STOP));
}

@Override
public AnimatableInstanceCache getAnimatableInstanceCache() {
return cache;
}
}
Loading

0 comments on commit a288d73

Please sign in to comment.