-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
c6e761d
commit a288d73
Showing
41 changed files
with
568 additions
and
60 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
26 changes: 26 additions & 0 deletions
26
src/main/java/net/bandit/black_iron/client/model/CustomHelmetModel.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,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; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/net/bandit/black_iron/client/renderer/CustomHelmetRenderer.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,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()); | ||
|
||
} | ||
|
||
} |
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
71 changes: 71 additions & 0 deletions
71
src/main/java/net/bandit/black_iron/item/custom/BlackIronAxe.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 @@ | ||
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); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/net/bandit/black_iron/item/custom/BlackIronSword.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,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
68
src/main/java/net/bandit/black_iron/item/custom/CustomHelmet.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,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; | ||
} | ||
} |
Oops, something went wrong.