use of net.minecraft.item.ArmorItem in project RealisticArmorTiers by IsakViste.
the class Armor method checkArmor.
private void checkArmor(ServerPlayerEntity player) {
// Maybe use ... to get armors and check against this
// player.getArmorSlots()
ArmorItem chestplate = (ArmorItem) player.getItemBySlot(EquipmentSlotType.CHEST).getItem().getItem();
if (this.set.getChestplates().contains(chestplate)) {
this.armorPieces++;
}
ArmorItem boots = (ArmorItem) player.getItemBySlot(EquipmentSlotType.FEET).getItem().getItem();
if (set.getBoots().contains(boots)) {
this.armorPieces++;
}
ArmorItem leggings = (ArmorItem) player.getItemBySlot(EquipmentSlotType.LEGS).getItem().getItem();
if (set.getLeggings().contains(leggings)) {
this.armorPieces++;
}
ArmorItem helmet = (ArmorItem) player.getItemBySlot(EquipmentSlotType.HEAD).getItem().getItem();
if (set.getHelmets().contains(helmet)) {
this.armorPieces++;
}
}
use of net.minecraft.item.ArmorItem in project RealisticArmorTiers by IsakViste.
the class EquipmentSetsParser method makeItemArmorListFromStringList.
public List<ArmorItem> makeItemArmorListFromStringList(List<String> armors) {
List<ArmorItem> items = new ArrayList<>();
for (String armor : armors) {
RegistryObject<ArmorItem> armorObj = RegistryObject.of(new ResourceLocation(armor), ForgeRegistries.ITEMS);
if (!armorObj.isPresent()) {
log.warn("-> (Armors) Could not find " + armorObj);
}
items.add(armorObj.get());
}
return items;
}
use of net.minecraft.item.ArmorItem in project minecolonies by Minecolonies.
the class CitizenItemHandler method updateArmorDamage.
/**
* Updates the armour damage after being hit.
*
* @param damage damage dealt.
*/
@Override
public void updateArmorDamage(final double damage) {
for (final ItemStack stack : citizen.getArmorSlots()) {
if (ItemStackUtils.isEmpty(stack) || !(stack.getItem() instanceof ArmorItem)) {
continue;
}
if (citizen.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(ARMOR_DURABILITY) > 0) {
if (citizen.getRandom().nextDouble() > (1 / (1 + citizen.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(ARMOR_DURABILITY)))) {
return;
}
}
final int armorDmg = Math.max(1, (int) (damage / 4));
final int slot = InventoryUtils.findFirstSlotInItemHandlerNotEmptyWith(citizen.getInventoryCitizen(), invStack -> invStack != stack && ItemStackUtils.compareItemStacksIgnoreStackSize(invStack, stack, false, true));
if (slot != -1) {
if (citizen.getInventoryCitizen().damageInventoryItem(slot, armorDmg, citizen, (entityCitizen) -> {
entityCitizen.broadcastBreakEvent(Hand.MAIN_HAND);
})) {
stack.setCount(0);
return;
}
}
stack.hurtAndBreak(armorDmg, citizen, (i) -> {
i.broadcastBreakEvent(Hand.MAIN_HAND);
});
}
}
use of net.minecraft.item.ArmorItem in project EnvironmentZ by Globox1997.
the class SmithingScreenHandlerMixin method canTakeOutputMixin.
@Inject(method = "canTakeOutput", at = @At("HEAD"), cancellable = true)
public void canTakeOutputMixin(PlayerEntity player, boolean present, CallbackInfoReturnable<Boolean> info) {
ItemStack itemStack = this.input.getStack(0);
ItemStack itemStack2 = this.input.getStack(1);
if (itemStack.getItem() instanceof ArmorItem && itemStack2.isIn(TagInit.INSOLATING_ITEM)) {
info.setReturnValue(true);
}
}
use of net.minecraft.item.ArmorItem in project BleachHack by BleachDrinker420.
the class AutoArmor method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (mc.player.playerScreenHandler != mc.player.currentScreenHandler || !BleachQueue.isEmpty("autoarmor_equip"))
return;
if (tickDelay > 0) {
tickDelay--;
return;
}
tickDelay = (getSetting(2).asToggle().getState() ? getSetting(2).asToggle().getChild(0).asSlider().getValueInt() : 0);
/* [Slot type, [Armor slot, Armor prot, New armor slot, New armor prot]] */
Map<EquipmentSlot, int[]> armorMap = new HashMap<>(4);
armorMap.put(EquipmentSlot.FEET, new int[] { 36, getProtection(mc.player.getInventory().getStack(36)), -1, -1 });
armorMap.put(EquipmentSlot.LEGS, new int[] { 37, getProtection(mc.player.getInventory().getStack(37)), -1, -1 });
armorMap.put(EquipmentSlot.CHEST, new int[] { 38, getProtection(mc.player.getInventory().getStack(38)), -1, -1 });
armorMap.put(EquipmentSlot.HEAD, new int[] { 39, getProtection(mc.player.getInventory().getStack(39)), -1, -1 });
/* Anti Break */
if (getSetting(0).asToggle().getState()) {
for (Entry<EquipmentSlot, int[]> e : armorMap.entrySet()) {
ItemStack is = mc.player.getInventory().getStack(e.getValue()[0]);
int armorSlot = (e.getValue()[0] - 34) + (39 - e.getValue()[0]) * 2;
if (is.isDamageable() && is.getMaxDamage() - is.getDamage() < 7) {
/* Look for an empty slot to quick move to */
int forceMoveSlot = -1;
for (int s = 0; s < 36; s++) {
if (mc.player.getInventory().getStack(s).isEmpty()) {
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, armorSlot, 1, SlotActionType.QUICK_MOVE, mc.player);
return;
} else if (!(mc.player.getInventory().getStack(s).getItem() instanceof ToolItem) && !(mc.player.getInventory().getStack(s).getItem() instanceof ArmorItem) && !(mc.player.getInventory().getStack(s).getItem() instanceof ElytraItem) && mc.player.getInventory().getStack(s).getItem() != Items.TOTEM_OF_UNDYING && forceMoveSlot == -1) {
forceMoveSlot = s;
}
}
/* Bruh no empty spots, then force move to a non-totem/tool/armor item */
if (forceMoveSlot != -1) {
// System.out.println(forceMoveSlot);
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, forceMoveSlot < 9 ? 36 + forceMoveSlot : forceMoveSlot, 1, SlotActionType.THROW, mc.player);
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, armorSlot, 1, SlotActionType.QUICK_MOVE, mc.player);
return;
}
/* No spots to move to, yeet the armor to not cause any bruh moments */
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, armorSlot, 1, SlotActionType.THROW, mc.player);
return;
}
}
}
for (int s = 0; s < 36; s++) {
int prot = getProtection(mc.player.getInventory().getStack(s));
if (prot > 0) {
EquipmentSlot slot = (mc.player.getInventory().getStack(s).getItem() instanceof ElytraItem ? EquipmentSlot.CHEST : ((ArmorItem) mc.player.getInventory().getStack(s).getItem()).getSlotType());
for (Entry<EquipmentSlot, int[]> e : armorMap.entrySet()) {
if (e.getKey() == slot) {
if (prot > e.getValue()[1] && prot > e.getValue()[3]) {
e.getValue()[2] = s;
e.getValue()[3] = prot;
}
}
}
}
}
for (Entry<EquipmentSlot, int[]> e : armorMap.entrySet()) {
if (e.getValue()[2] != -1) {
if (e.getValue()[1] == -1 && e.getValue()[2] < 9) {
if (e.getValue()[2] != mc.player.getInventory().selectedSlot) {
mc.player.getInventory().selectedSlot = e.getValue()[2];
mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(e.getValue()[2]));
}
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 36 + e.getValue()[2], 1, SlotActionType.QUICK_MOVE, mc.player);
} else if (mc.player.playerScreenHandler == mc.player.currentScreenHandler) {
/* Convert inventory slots to container slots */
int armorSlot = (e.getValue()[0] - 34) + (39 - e.getValue()[0]) * 2;
int newArmorslot = e.getValue()[2] < 9 ? 36 + e.getValue()[2] : e.getValue()[2];
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, newArmorslot, 0, SlotActionType.PICKUP, mc.player);
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, armorSlot, 0, SlotActionType.PICKUP, mc.player);
if (e.getValue()[1] != -1)
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, newArmorslot, 0, SlotActionType.PICKUP, mc.player);
}
return;
}
}
}
Aggregations