Search in sources :

Example 1 with ItemMekaTool

use of mekanism.common.item.gear.ItemMekaTool in project Mekanism by mekanism.

the class MekaSuitArmor method key.

public QuickHash key(LivingEntity player) {
    Object2BooleanMap<ModuleModelSpec> modules = new Object2BooleanOpenHashMap<>();
    Set<EquipmentSlotType> wornParts = EnumSet.noneOf(EquipmentSlotType.class);
    IModuleHelper moduleHelper = MekanismAPI.getModuleHelper();
    for (EquipmentSlotType slotType : EnumUtils.ARMOR_SLOTS) {
        ItemStack wornItem = player.getItemBySlot(slotType);
        if (!wornItem.isEmpty() && wornItem.getItem() instanceof ItemMekaSuitArmor) {
            wornParts.add(slotType);
            for (Map.Entry<ModuleData<?>, ModuleModelSpec> entry : moduleModelSpec.row(slotType).entrySet()) {
                if (moduleHelper.isEnabled(wornItem, entry.getKey())) {
                    ModuleModelSpec spec = entry.getValue();
                    modules.put(spec, spec.isActive(player));
                }
            }
        }
    }
    return new QuickHash(modules.isEmpty() ? Object2BooleanMaps.emptyMap() : modules, wornParts.isEmpty() ? Collections.emptySet() : wornParts, MekanismUtils.getItemInHand(player, HandSide.LEFT).getItem() instanceof ItemMekaTool, MekanismUtils.getItemInHand(player, HandSide.RIGHT).getItem() instanceof ItemMekaTool);
}
Also used : ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) QuickHash(mekanism.client.render.obj.TransmitterBakedModel.QuickHash) Object2BooleanOpenHashMap(it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap) ItemMekaTool(mekanism.common.item.gear.ItemMekaTool) ModuleData(mekanism.api.gear.ModuleData) IModuleHelper(mekanism.api.gear.IModuleHelper) ItemStack(net.minecraft.item.ItemStack) Object2BooleanMap(it.unimi.dsi.fastutil.objects.Object2BooleanMap) Object2ObjectOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) Map(java.util.Map) Object2BooleanOpenHashMap(it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap) EnumMap(java.util.EnumMap)

Example 2 with ItemMekaTool

use of mekanism.common.item.gear.ItemMekaTool in project Mekanism by mekanism.

the class HUDRenderer method renderMekaSuitModuleIcons.

private void renderMekaSuitModuleIcons(MatrixStack matrix, float partialTick, int color) {
    // create list of all elements to render
    List<IHUDElement> elements = new ArrayList<>();
    // Add any elements that might be on modules in the meka suit while worn
    for (EquipmentSlotType type : EnumUtils.ARMOR_SLOTS) {
        ItemStack stack = getStack(type);
        if (stack.getItem() instanceof ItemMekaSuitArmor) {
            elements.addAll(((ItemMekaSuitArmor) stack.getItem()).getHUDElements(minecraft.player, stack));
        }
    }
    // Add any elements that might be on modules in the meka tool when it is held
    for (EquipmentSlotType type : EnumUtils.HAND_SLOTS) {
        ItemStack stack = getStack(type);
        if (stack.getItem() instanceof ItemMekaTool) {
            elements.addAll(((ItemMekaTool) stack.getItem()).getHUDElements(minecraft.player, stack));
        }
    }
    int startX = minecraft.getWindow().getGuiScaledWidth() - 10;
    int curY = minecraft.getWindow().getGuiScaledHeight() - 10;
    matrix.pushPose();
    for (IHUDElement element : elements) {
        int elementWidth = 24 + minecraft.font.width(element.getText());
        curY -= 18;
        renderHUDElement(matrix, startX - elementWidth, curY, element, color, true);
    }
    matrix.popPose();
}
Also used : ItemMekaTool(mekanism.common.item.gear.ItemMekaTool) ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) IHUDElement(mekanism.api.gear.IHUDElement)

Aggregations

ItemMekaSuitArmor (mekanism.common.item.gear.ItemMekaSuitArmor)2 ItemMekaTool (mekanism.common.item.gear.ItemMekaTool)2 EquipmentSlotType (net.minecraft.inventory.EquipmentSlotType)2 ItemStack (net.minecraft.item.ItemStack)2 Object2BooleanMap (it.unimi.dsi.fastutil.objects.Object2BooleanMap)1 Object2BooleanOpenHashMap (it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap)1 Object2ObjectOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)1 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 Map (java.util.Map)1 IHUDElement (mekanism.api.gear.IHUDElement)1 IModuleHelper (mekanism.api.gear.IModuleHelper)1 ModuleData (mekanism.api.gear.ModuleData)1 QuickHash (mekanism.client.render.obj.TransmitterBakedModel.QuickHash)1