use of net.minecraft.item.ArmorItem in project FrostedHeart by TeamMoegMC.
the class ClientRegistryEvents method onModelBake.
@SubscribeEvent
public static void onModelBake(ModelBakeEvent event) {
for (ResourceLocation location : event.getModelRegistry().keySet()) {
// Now find all armors
ResourceLocation item = new ResourceLocation(location.getNamespace(), location.getPath());
if (ForgeRegistries.ITEMS.getValue(item) instanceof ArmorItem) {
ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation(item, "inventory");
IBakedModel model = event.getModelRegistry().get(itemModelResourceLocation);
if (model == null) {
FHLogger.warn("Did not find the expected vanilla baked model for " + item + " in registry");
} else if (model instanceof LiningModel) {
FHLogger.warn("Tried to replace " + item + " twice");
} else {
// Replace the model with our IBakedModel
LiningModel customModel = new LiningModel(model);
event.getModelRegistry().put(itemModelResourceLocation, customModel);
}
}
}
}
use of net.minecraft.item.ArmorItem in project FrostedHeart by TeamMoegMC.
the class LiningItemOverrideList method getOverrideModel.
@Override
public IBakedModel getOverrideModel(IBakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity) {
String s = ItemNBTHelper.getString(stack, "inner_cover");
EquipmentSlotType slotType = ((ArmorItem) stack.getItem()).getEquipmentSlot();
if (s.length() > 0 && slotType != null) {
String liningType = new ResourceLocation(s).getPath();
String slotName = "feet";
if (slotType.getName().equals("feet")) {
slotName = "feet";
} else if (slotType.getName().equals("legs")) {
slotName = "legs";
} else if (slotType.getName().equals("chest")) {
slotName = "torso";
} else if (slotType.getName().equals("head")) {
slotName = "helmet";
}
ResourceLocation textureLocation = FHMain.rl("item/lining_overlay/" + liningType + "_" + slotName);
return new LiningFinalizedModel(originalModel, textureLocation);
}
return originalModel;
}
use of net.minecraft.item.ArmorItem in project Vampirism by TeamLapen.
the class MinionInventory method damageArmor.
public void damageArmor(DamageSource source, float damage, MinionEntity<?> entity) {
if (damage > 0) {
damage = damage / 6.0F;
if (damage < 1.0F && damage >= 0.5f) {
damage = 1.0F;
}
if (damage >= 1) {
for (int i = 0; i < this.inventoryArmor.size(); ++i) {
ItemStack itemstack = this.inventoryArmor.get(i);
if ((!source.isFire() || !itemstack.getItem().isFireResistant()) && itemstack.getItem() instanceof ArmorItem) {
final int i_final = i;
itemstack.hurtAndBreak((int) damage, entity, (e) -> {
e.broadcastBreakEvent(EquipmentSlotType.byTypeAndIndex(EquipmentSlotType.Group.ARMOR, i_final));
});
}
}
}
}
}
use of net.minecraft.item.ArmorItem in project NinjaGear by InfinityRaider.
the class AnvilHandler method onAnvilUse.
@SubscribeEvent
@SuppressWarnings("unused")
public void onAnvilUse(AnvilUpdateEvent event) {
// Fetch input stacks
ItemStack left = event.getLeft();
ItemStack right = event.getRight();
// Verify imbuing conditions
if (left == null || right == null || left.isEmpty() || right.isEmpty()) {
// Do nothing if either slot is empty
return;
}
if (!(left.getItem() instanceof ArmorItem)) {
// Do nothing if the left slot does not contain an armor piece
return;
}
if (!(right.getItem() instanceof ArmorItem)) {
// Do nothing if the right slot does not contain an armor piece
return;
}
if ((left.getItem() instanceof ItemNinjaArmor) && (right.getItem() instanceof ItemNinjaArmor)) {
// Do nothing if both slots contain ninja armor
return;
}
if (!(left.getItem() instanceof ItemNinjaArmor) && !(right.getItem() instanceof ItemNinjaArmor)) {
// Do nothing if neither slot contains ninja armor
return;
}
if (((ArmorItem) left.getItem()).getEquipmentSlot() != ((ArmorItem) right.getItem()).getEquipmentSlot()) {
// Do nothing if the slots contain armor pieces for different body parts
return;
}
// Fetch the input ItemStack
ItemStack input = (left.getItem() instanceof ItemNinjaArmor) ? right : left;
// Check if the input stack is imbued already
if (CapabilityNinjaArmor.isNinjaArmor(input)) {
// Do nothing if the input stack is already imbued
return;
}
// Copy the input ItemStack
ItemStack output = input.copy();
// Activate the ninja armor status on the capability
output.getCapability(CapabilityNinjaArmor.CAPABILITY).ifPresent(cap -> cap.setNinjaArmor(true));
// Set the name
String inputName = event.getName();
if (inputName == null || inputName.isEmpty()) {
output.clearCustomName();
} else {
output.setDisplayName(new StringTextComponent(inputName));
}
// Set the output
event.setOutput(output);
// Set the cost
event.setCost(NinjaGear.instance.getConfig().getImbueCost());
}
use of net.minecraft.item.ArmorItem in project Fabric-Course-118 by Kaupenjoe.
the class ModArmorItem method hasCorrectArmorOn.
private boolean hasCorrectArmorOn(ArmorMaterial material, PlayerEntity player) {
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;
}
Aggregations