Search in sources :

Example 1 with IDarkSteelItem

use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.

the class DarkSteelUpgradeRecipeCategory method registerSubtypes.

public static void registerSubtypes(ISubtypeRegistry subtypeRegistry) {
    DarkSteelUpgradeSubtypeInterpreter dsusi = new DarkSteelUpgradeSubtypeInterpreter();
    Set<Item> items = new HashSet<Item>();
    for (ItemStack stack : ItemHelper.getValidItems()) {
        if (stack.getItem() instanceof IDarkSteelItem)
            items.add(stack.getItem());
    }
    for (Item item : items) {
        if (item != null) {
            subtypeRegistry.registerSubtypeInterpreter(item, dsusi);
        }
    }
}
Also used : Item(net.minecraft.item.Item) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem) ItemStack(net.minecraft.item.ItemStack) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem) HashSet(java.util.HashSet)

Example 2 with IDarkSteelItem

use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.

the class EnergyUpgradePowerAdapter method attachCapabilities.

@SubscribeEvent
public static void attachCapabilities(@Nonnull AttachCapabilitiesEvent<ItemStack> evt) {
    if (evt.getCapabilities().containsKey(KEY)) {
        return;
    }
    final ItemStack stack = evt.getObject();
    if (stack != null && stack.getItem() instanceof IDarkSteelItem) {
        EnergyUpgadeCap cap = new EnergyUpgadeCap(stack);
        evt.addCapability(KEY, cap);
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with IDarkSteelItem

use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.

the class UpgradeRenderDispatcher method doRenderLayer.

@Override
public void doRenderLayer(@Nonnull AbstractClientPlayer player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
    NNList.of(EntityEquipmentSlot.class).apply(new Callback<EntityEquipmentSlot>() {

        @Override
        public void apply(@Nonnull EntityEquipmentSlot slot) {
            ItemStack item = player.getItemStackFromSlot(slot);
            if (item.getItem() instanceof IDarkSteelItem) {
                for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) {
                    if (upgrade instanceof IHasPlayerRenderer && upgrade.hasUpgrade(item)) {
                        ((IHasPlayerRenderer) upgrade).getRender().doRenderLayer(renderPlayer, slot, item, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
                    }
                }
            }
            if (item.getItem() instanceof IHasPlayerRenderer) {
                ((IHasPlayerRenderer) item.getItem()).getRender().doRenderLayer(renderPlayer, slot, item, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
            }
        }
    });
    IInventory baubles = BaublesUtil.instance().getBaubles(player);
    if (baubles != null) {
        for (int i = 0; i < baubles.getSizeInventory(); i++) {
            ItemStack piece = baubles.getStackInSlot(i);
            if (piece.getItem() instanceof IHasPlayerRenderer) {
                ((IHasPlayerRenderer) piece.getItem()).getRender().doRenderLayer(renderPlayer, null, piece, player, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
            }
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) IHasPlayerRenderer(crazypants.enderio.api.upgrades.IHasPlayerRenderer) ItemStack(net.minecraft.item.ItemStack) IDarkSteelUpgrade(crazypants.enderio.api.upgrades.IDarkSteelUpgrade) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem)

Example 4 with IDarkSteelItem

use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.

the class DarkSteelController method onFall.

@SubscribeEvent
public static void onFall(LivingFallEvent event) {
    float distance = event.getDistance();
    if (distance > 3) {
        ItemStack boots = event.getEntityLiving().getItemStackFromSlot(EntityEquipmentSlot.FEET);
        if (boots.getItem() instanceof IDarkSteelItem) {
            int energyStored = EnergyUpgradeManager.getEnergyStored(boots);
            if (energyStored > 0) {
                float toMitigate = distance - 3;
                int energyCost = (int) Math.min(energyStored, Math.ceil(toMitigate * Config.darkSteelFallDistanceCost));
                float mitigated = energyCost / (float) Config.darkSteelFallDistanceCost;
                if (!event.getEntity().world.isRemote) {
                    EnergyUpgradeManager.extractEnergy(boots, (IDarkSteelItem) boots.getItem(), energyCost, false);
                }
                if (mitigated < toMitigate) {
                    // Log.debug("Mitigating fall damage partially: original=", distance, " mitigated=", mitigated, " remaining=", distance - mitigated, " power used=",
                    // energyCost);
                    event.setDistance(distance - mitigated);
                } else {
                    // Log.debug("Canceling fall damage: original=", distance, " power used=", energyCost);
                    event.setCanceled(true);
                }
            }
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with IDarkSteelItem

use of crazypants.enderio.api.upgrades.IDarkSteelItem in project EnderIO by SleepyTrousers.

the class DarkSteelController method onPlayerTick.

@SubscribeEvent
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
    EntityPlayer player = event.player;
    if (event.phase == Phase.START && !player.isSpectator()) {
        // boots
        updateStepHeightAndFallDistance(player);
        // leggings
        SpeedController.updateSpeed(player);
        NNList.of(EntityEquipmentSlot.class).apply(new Callback<EntityEquipmentSlot>() {

            @Override
            public void apply(@Nonnull EntityEquipmentSlot slot) {
                ItemStack item = player.getItemStackFromSlot(slot);
                if (item.getItem() instanceof IDarkSteelItem) {
                    for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) {
                        if (upgrade.hasUpgrade(item)) {
                            upgrade.onPlayerTick(item, (IDarkSteelItem) item.getItem(), player);
                        }
                    }
                }
            }
        });
    }
}
Also used : EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) IDarkSteelUpgrade(crazypants.enderio.api.upgrades.IDarkSteelUpgrade) IDarkSteelItem(crazypants.enderio.api.upgrades.IDarkSteelItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IDarkSteelItem (crazypants.enderio.api.upgrades.IDarkSteelItem)8 ItemStack (net.minecraft.item.ItemStack)6 IDarkSteelUpgrade (crazypants.enderio.api.upgrades.IDarkSteelUpgrade)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)3 EntityEquipmentSlot (net.minecraft.inventory.EntityEquipmentSlot)2 IAdvancedTooltipProvider (com.enderio.core.api.client.gui.IAdvancedTooltipProvider)1 NNList (com.enderio.core.common.util.NNList)1 IHasPlayerRenderer (crazypants.enderio.api.upgrades.IHasPlayerRenderer)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Nonnull (javax.annotation.Nonnull)1 Minecraft (net.minecraft.client.Minecraft)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 IInventory (net.minecraft.inventory.IInventory)1 Item (net.minecraft.item.Item)1 EnumActionResult (net.minecraft.util.EnumActionResult)1 Vec3d (net.minecraft.util.math.Vec3d)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1