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);
}
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();
}
Aggregations