Prisma Steel Armor Effects

This commit is contained in:
Vos
2025-11-09 17:07:53 -06:00
parent b859c72096
commit 340580f2d0
2 changed files with 99 additions and 4 deletions
@@ -2,6 +2,7 @@ package com.acethewildfire.acesbs.item;
import com.acethewildfire.acesbs.AcesBS; import com.acethewildfire.acesbs.AcesBS;
import com.acethewildfire.acesbs.item.custom.HammerItem; import com.acethewildfire.acesbs.item.custom.HammerItem;
import com.acethewildfire.acesbs.item.custom.ModArmorItem;
import com.acethewildfire.acesbs.item.custom.OracleLemon; import com.acethewildfire.acesbs.item.custom.OracleLemon;
import com.acethewildfire.acesbs.item.custom.Wand; import com.acethewildfire.acesbs.item.custom.Wand;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
@@ -71,19 +72,19 @@ public class ModItems {
); );
public static final Item PRISMA_STEEL_HELMET = registerItem("prisma_steel_helmet", public static final Item PRISMA_STEEL_HELMET = registerItem("prisma_steel_helmet",
new ArmorItem(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL, ArmorItem.Type.HELMET, new Item.Settings() new ModArmorItem(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL, ArmorItem.Type.HELMET, new Item.Settings()
.maxDamage(ArmorItem.Type.HELMET.getMaxDamage(15)))); .maxDamage(ArmorItem.Type.HELMET.getMaxDamage(15))));
public static final Item PRISMA_STEEL_CHESTPLATE = registerItem("prisma_steel_chestplate", public static final Item PRISMA_STEEL_CHESTPLATE = registerItem("prisma_steel_chestplate",
new ArmorItem(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL, ArmorItem.Type.CHESTPLATE, new Item.Settings() new ModArmorItem(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL, ArmorItem.Type.CHESTPLATE, new Item.Settings()
.maxDamage(ArmorItem.Type.CHESTPLATE.getMaxDamage(15)))); .maxDamage(ArmorItem.Type.CHESTPLATE.getMaxDamage(15))));
public static final Item PRISMA_STEEL_LEGGINGS = registerItem("prisma_steel_leggings", public static final Item PRISMA_STEEL_LEGGINGS = registerItem("prisma_steel_leggings",
new ArmorItem(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL, ArmorItem.Type.LEGGINGS, new Item.Settings() new ModArmorItem(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL, ArmorItem.Type.LEGGINGS, new Item.Settings()
.maxDamage(ArmorItem.Type.LEGGINGS.getMaxDamage(15)))); .maxDamage(ArmorItem.Type.LEGGINGS.getMaxDamage(15))));
public static final Item PRISMA_STEEL_BOOTS = registerItem("prisma_steel_boots", public static final Item PRISMA_STEEL_BOOTS = registerItem("prisma_steel_boots",
new ArmorItem(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL, ArmorItem.Type.BOOTS, new Item.Settings() new ModArmorItem(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL, ArmorItem.Type.BOOTS, new Item.Settings()
.maxDamage(ArmorItem.Type.BOOTS.getMaxDamage(15)))); .maxDamage(ArmorItem.Type.BOOTS.getMaxDamage(15))));
private static Item registerItem(String name, Item item){ private static Item registerItem(String name, Item item){
@@ -0,0 +1,94 @@
package com.acethewildfire.acesbs.item.custom;
import com.acethewildfire.acesbs.item.ModArmorMaterials;
import com.google.common.collect.ImmutableMap;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ArmorMaterial;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.world.World;
import java.util.List;
import java.util.Map;
public class ModArmorItem extends ArmorItem {
private static final Map<RegistryEntry<ArmorMaterial>, List<StatusEffectInstance>> MATERIAL_TO_EFFECT_MAP =
(new ImmutableMap.Builder<RegistryEntry<ArmorMaterial>, List<StatusEffectInstance>>())
.put(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL,
List.of(new StatusEffectInstance(StatusEffects.SPEED, 400, 1, false, false),
new StatusEffectInstance(StatusEffects.JUMP_BOOST, 400, 0, false, false)))
// For more materials just add more puts
// .put(ModArmorMaterials.PRISMA_STEEL_ARMOR_MATERIAL,
// List.of(new StatusEffectInstance(StatusEffects.SPEED, 400, 2, false, false),
// new StatusEffectInstance(StatusEffects.JUMP_BOOST, 400, 1, false, false)))
.build();
public ModArmorItem(RegistryEntry<ArmorMaterial> material, Type type, Settings settings) {
super(material, type, settings);
}
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if(!world.isClient()) {
if(entity instanceof PlayerEntity player) {
if(hasFullSuitOfArmorOn(player)) {
evaluateArmorEffects(player);
}
}
}
super.inventoryTick(stack, world, entity, slot, selected);
}
private void evaluateArmorEffects(PlayerEntity player) {
for (Map.Entry<RegistryEntry<ArmorMaterial>, List<StatusEffectInstance>> entry : MATERIAL_TO_EFFECT_MAP.entrySet()) {
RegistryEntry<ArmorMaterial> mapArmorMaterial = entry.getKey();
List<StatusEffectInstance> mapStatusEffects = entry.getValue();
if(hasCorrectArmorOn(mapArmorMaterial, player)) {
addStatusEffectForMaterial(player, mapArmorMaterial, mapStatusEffects);
}
}
}
private void addStatusEffectForMaterial(PlayerEntity player, RegistryEntry<ArmorMaterial> mapArmorMaterial, List<StatusEffectInstance> mapStatusEffect) {
boolean hasPlayerEffect = mapStatusEffect.stream().allMatch(statusEffectInstance -> player.hasStatusEffect(statusEffectInstance.getEffectType()));
if(!hasPlayerEffect) {
for (StatusEffectInstance instance : mapStatusEffect) {
player.addStatusEffect(new StatusEffectInstance(instance.getEffectType(),
instance.getDuration(), instance.getAmplifier(), instance.isAmbient(), instance.shouldShowParticles()));
}
}
}
private boolean hasFullSuitOfArmorOn(PlayerEntity player) {
ItemStack boots = player.getInventory().getArmorStack(0);
ItemStack leggings = player.getInventory().getArmorStack(1);
ItemStack breastplate = player.getInventory().getArmorStack(2);
ItemStack helmet = player.getInventory().getArmorStack(3);
return !helmet.isEmpty() && !breastplate.isEmpty()
&& !leggings.isEmpty() && !boots.isEmpty();
}
private boolean hasCorrectArmorOn(RegistryEntry<ArmorMaterial> material, PlayerEntity player) {
for (ItemStack armorStack: player.getInventory().armor) {
if(!(armorStack.getItem() instanceof ArmorItem)) {
return false;
}
}
ArmorItem boots = ((ArmorItem)player.getInventory().getArmorStack(0).getItem());
ArmorItem leggings = ((ArmorItem)player.getInventory().getArmorStack(1).getItem());
ArmorItem breastplate = ((ArmorItem)player.getInventory().getArmorStack(2).getItem());
ArmorItem helmet = ((ArmorItem)player.getInventory().getArmorStack(3).getItem());
return helmet.getMaterial() == material && breastplate.getMaterial() == material &&
leggings.getMaterial() == material && boots.getMaterial() == material;
}
}