Search in sources :

Example 1 with ItemMekaSuitArmor

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

the class RenderTickHandler method renderArm.

@SubscribeEvent
public void renderArm(RenderArmEvent event) {
    AbstractClientPlayerEntity player = event.getPlayer();
    ItemStack chestStack = player.getItemBySlot(EquipmentSlotType.CHEST);
    if (chestStack.getItem() instanceof ItemMekaSuitArmor) {
        MekaSuitArmor armor = (MekaSuitArmor) ((ItemMekaSuitArmor) chestStack.getItem()).getGearModel();
        armor.setAllVisible(true);
        // Note: We just want it to act as empty even if there is a map as it looks a lot better
        boolean rightHand = event.getArm() == HandSide.RIGHT;
        if (rightHand) {
            armor.rightArmPose = ArmPose.EMPTY;
        } else {
            armor.leftArmPose = ArmPose.EMPTY;
        }
        armor.attackTime = 0.0F;
        armor.crouching = false;
        armor.swimAmount = 0.0F;
        armor.setupAnim(player, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
        armor.renderArm(event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight(), OverlayTexture.NO_OVERLAY, chestStack.hasFoil(), player, rightHand);
        event.setCanceled(true);
    }
}
Also used : ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) AbstractClientPlayerEntity(net.minecraft.client.entity.player.AbstractClientPlayerEntity) ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) MekaSuitArmor(mekanism.client.render.armor.MekaSuitArmor) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with ItemMekaSuitArmor

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

the class RenderTickHandler method renderOverlay.

@SubscribeEvent
public void renderOverlay(RenderGameOverlayEvent.Post event) {
    if (event.getType() == ElementType.HOTBAR) {
        if (!minecraft.player.isSpectator() && MekanismConfig.client.enableHUD.get() && MekanismClient.renderHUD) {
            int count = 0;
            Map<EquipmentSlotType, List<ITextComponent>> renderStrings = new LinkedHashMap<>();
            for (EquipmentSlotType slotType : EQUIPMENT_ORDER) {
                ItemStack stack = minecraft.player.getItemBySlot(slotType);
                if (stack.getItem() instanceof IItemHUDProvider) {
                    List<ITextComponent> list = new ArrayList<>();
                    ((IItemHUDProvider) stack.getItem()).addHUDStrings(list, minecraft.player, stack, slotType);
                    int size = list.size();
                    if (size > 0) {
                        renderStrings.put(slotType, list);
                        count += size;
                    }
                }
            }
            MatrixStack matrix = event.getMatrixStack();
            if (count > 0) {
                int start = (renderStrings.size() * 2) + (count * 9);
                boolean alignLeft = MekanismConfig.client.alignHUDLeft.get();
                MainWindow window = event.getWindow();
                int y = window.getGuiScaledHeight();
                float hudScale = MekanismConfig.client.hudScale.get();
                int yScale = (int) ((1 / hudScale) * y);
                matrix.pushPose();
                matrix.scale(hudScale, hudScale, hudScale);
                for (Map.Entry<EquipmentSlotType, List<ITextComponent>> entry : renderStrings.entrySet()) {
                    for (ITextComponent text : entry.getValue()) {
                        drawString(window, matrix, text, alignLeft, yScale - start, 0xC8C8C8);
                        start -= 9;
                    }
                    start -= 2;
                }
                matrix.popPose();
            }
            if (minecraft.player.getItemBySlot(EquipmentSlotType.HEAD).getItem() instanceof ItemMekaSuitArmor) {
                hudRenderer.renderHUD(matrix, event.getPartialTicks());
            }
        }
    } else if (event.getType() == ElementType.ARMOR) {
        FloatingLong capacity = FloatingLong.ZERO, stored = FloatingLong.ZERO;
        for (ItemStack stack : minecraft.player.inventory.armor) {
            if (stack.getItem() instanceof ItemMekaSuitArmor) {
                IEnergyContainer container = StorageUtils.getEnergyContainer(stack, 0);
                if (container != null) {
                    capacity = capacity.plusEqual(container.getMaxEnergy());
                    stored = stored.plusEqual(container.getEnergy());
                }
            }
        }
        if (!capacity.isZero()) {
            int x = event.getWindow().getGuiScaledWidth() / 2 - 91;
            int y = event.getWindow().getGuiScaledHeight() - ForgeIngameGui.left_height + 2;
            int length = (int) Math.round(stored.divide(capacity).doubleValue() * 79);
            MatrixStack matrix = event.getMatrixStack();
            GuiUtils.renderExtendedTexture(matrix, GuiBar.BAR, 2, 2, x, y, 81, 6);
            minecraft.getTextureManager().bind(POWER_BAR);
            AbstractGui.blit(matrix, x + 1, y + 1, length, 4, 0, 0, length, 4, 79, 4);
            minecraft.getTextureManager().bind(AbstractGui.GUI_ICONS_LOCATION);
            ForgeIngameGui.left_height += 8;
        }
    }
}
Also used : ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) ITextComponent(net.minecraft.util.text.ITextComponent) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) IItemHUDProvider(mekanism.common.item.interfaces.IItemHUDProvider) FloatingLong(mekanism.api.math.FloatingLong) IEnergyContainer(mekanism.api.energy.IEnergyContainer) MainWindow(net.minecraft.client.MainWindow) ArrayList(java.util.ArrayList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) EnumMap(java.util.EnumMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with ItemMekaSuitArmor

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

the class ModuleNutritionalInjectionUnit method addHUDElements.

@Override
public void addHUDElements(IModule<ModuleNutritionalInjectionUnit> module, PlayerEntity player, Consumer<IHUDElement> hudElementAdder) {
    if (module.isEnabled()) {
        ItemStack container = module.getContainer();
        GasStack stored = ((ItemMekaSuitArmor) container.getItem()).getContainedGas(container, MekanismGases.NUTRITIONAL_PASTE.get());
        double ratio = StorageUtils.getRatio(stored.getAmount(), MekanismConfig.gear.mekaSuitNutritionalMaxStorage.getAsLong());
        hudElementAdder.accept(MekanismAPI.getModuleHelper().hudElementPercent(icon, ratio));
    }
}
Also used : ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) GasStack(mekanism.api.chemical.gas.GasStack) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ItemMekaSuitArmor

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

the class ModuleNutritionalInjectionUnit method tickServer.

@Override
public void tickServer(IModule<ModuleNutritionalInjectionUnit> module, PlayerEntity player) {
    FloatingLong usage = MekanismConfig.gear.mekaSuitEnergyUsageNutritionalInjection.get();
    if (MekanismUtils.isPlayingMode(player) && player.canEat(false)) {
        // Check if we can use a single iteration of it
        ItemStack container = module.getContainer();
        ItemMekaSuitArmor item = (ItemMekaSuitArmor) container.getItem();
        long needed = Math.min(20 - player.getFoodData().getFoodLevel(), item.getContainedGas(container, MekanismGases.NUTRITIONAL_PASTE.get()).getAmount() / MekanismConfig.general.nutritionalPasteMBPerFood.get());
        long toFeed = Math.min(module.getContainerEnergy().divideToInt(usage), needed);
        if (toFeed > 0) {
            module.useEnergy(player, usage.multiply(toFeed));
            item.useGas(container, MekanismGases.NUTRITIONAL_PASTE.get(), toFeed * MekanismConfig.general.nutritionalPasteMBPerFood.get());
            player.getFoodData().eat((int) needed, needed * MekanismConfig.general.nutritionalPasteSaturation.get());
        }
    }
}
Also used : FloatingLong(mekanism.api.math.FloatingLong) ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) ItemStack(net.minecraft.item.ItemStack)

Example 5 with ItemMekaSuitArmor

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

the class ModuleJetpackUnit method addHUDElements.

@Override
public void addHUDElements(IModule<ModuleJetpackUnit> module, PlayerEntity player, Consumer<IHUDElement> hudElementAdder) {
    if (module.isEnabled()) {
        ItemStack container = module.getContainer();
        GasStack stored = ((ItemMekaSuitArmor) container.getItem()).getContainedGas(container, MekanismGases.HYDROGEN.get());
        double ratio = StorageUtils.getRatio(stored.getAmount(), MekanismConfig.gear.mekaSuitJetpackMaxStorage.getAsLong());
        hudElementAdder.accept(MekanismAPI.getModuleHelper().hudElementPercent(jetpackMode.get().getHUDIcon(), ratio));
    }
}
Also used : ItemMekaSuitArmor(mekanism.common.item.gear.ItemMekaSuitArmor) GasStack(mekanism.api.chemical.gas.GasStack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

ItemMekaSuitArmor (mekanism.common.item.gear.ItemMekaSuitArmor)9 ItemStack (net.minecraft.item.ItemStack)9 GasStack (mekanism.api.chemical.gas.GasStack)3 EquipmentSlotType (net.minecraft.inventory.EquipmentSlotType)3 ArrayList (java.util.ArrayList)2 EnumMap (java.util.EnumMap)2 Map (java.util.Map)2 FloatingLong (mekanism.api.math.FloatingLong)2 ItemMekaTool (mekanism.common.item.gear.ItemMekaTool)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 Object2BooleanMap (it.unimi.dsi.fastutil.objects.Object2BooleanMap)1 Object2BooleanOpenHashMap (it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap)1 Object2ObjectOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 IEnergyContainer (mekanism.api.energy.IEnergyContainer)1 IHUDElement (mekanism.api.gear.IHUDElement)1 IModuleHelper (mekanism.api.gear.IModuleHelper)1