Search in sources :

Example 6 with CapturedMob

use of crazypants.enderio.util.CapturedMob in project EnderIO by SleepyTrousers.

the class AbstractSoulBinderRecipe method getCompletedResult.

@Override
@Nonnull
public ResultStack[] getCompletedResult(long nextSeed, float chanceMultiplier, @Nonnull NNList<MachineRecipeInput> inputs) {
    CapturedMob mobType = null;
    ItemStack inputItem = null;
    for (MachineRecipeInput input : inputs) {
        if (input != null && input.slotNumber == 0 && CapturedMob.containsSoul(input.item)) {
            mobType = CapturedMob.create(input.item);
        } else if (input != null && input.slotNumber == 1 && isValidInputItem(input.item)) {
            inputItem = input.item;
        }
    }
    if (mobType == null || !isValidInputSoul(mobType) || inputItem == null) {
        return new ResultStack[0];
    }
    ItemStack resultStack = getOutputStack(inputItem, mobType);
    ItemStack soulVessel = new ItemStack(itemSoulVial.getItemNN());
    return new ResultStack[] { new ResultStack(soulVessel), new ResultStack(resultStack) };
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) MachineRecipeInput(crazypants.enderio.base.recipe.MachineRecipeInput) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 7 with CapturedMob

use of crazypants.enderio.util.CapturedMob in project EnderIO by SleepyTrousers.

the class MobNameOverlayRenderHelper method doItemOverlayIntoGUI.

@SideOnly(Side.CLIENT)
public static void doItemOverlayIntoGUI(@Nonnull ItemStack stack, int xPosition, int yPosition) {
    if (EnderIO.proxy.getClientPlayer().isSneaking() || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
        CapturedMob capturedMob = CapturedMob.create(stack);
        if (capturedMob != null) {
            String name = capturedMob.getDisplayName();
            int idx = (int) ((EnderIO.proxy.getTickCount() / 4) % name.length());
            name = (name + " " + name).substring(idx, idx + 3);
            FontRenderer fr = Minecraft.getMinecraft().getRenderManager().getFontRenderer();
            GlStateManager.disableLighting();
            GlStateManager.disableDepth();
            GlStateManager.disableBlend();
            GlStateManager.enableBlend();
            fr.drawStringWithShadow(name, xPosition + 8 - fr.getStringWidth(name) / 2, yPosition + 5, 0xFF0030B0);
            GlStateManager.enableLighting();
            GlStateManager.enableDepth();
            GlStateManager.enableBlend();
        }
    }
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) FontRenderer(net.minecraft.client.gui.FontRenderer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 8 with CapturedMob

use of crazypants.enderio.util.CapturedMob in project EnderIO by SleepyTrousers.

the class BlockPoweredSpawner method getSubBlocks.

@SuppressWarnings("null")
@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> list) {
    super.getSubBlocks(tab, list);
    if (SpawnerConfig.poweredSpawnerAddAllMobsCreative.get()) {
        CapturedMob.getAllSouls().apply(new Callback<CapturedMob>() {

            @Override
            public void apply(CapturedMob mob) {
                list.add(mob.toStack(BlockPoweredSpawner.this, 0, 1));
            }
        });
    } else {
        list.add(CapturedMob.create(new ResourceLocation("enderman")).toStack(this, 0, 1));
        list.add(CapturedMob.create(new ResourceLocation("chicken")).toStack(this, 0, 1));
        list.add(CapturedMob.create(new ResourceLocation("skeleton")).toStack(this, 0, 1));
        list.add(CapturedMob.create(new ResourceLocation("wither_skeleton")).toStack(this, 0, 1));
        list.add(CapturedMob.create(new ResourceLocation("stray")).toStack(this, 0, 1));
    }
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) ResourceLocation(net.minecraft.util.ResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 9 with CapturedMob

use of crazypants.enderio.util.CapturedMob in project EnderIO by SleepyTrousers.

the class BlockPoweredSpawner method handleAnvilEvent.

@SubscribeEvent
public void handleAnvilEvent(AnvilUpdateEvent evt) {
    if (Prep.isInvalid(evt.getLeft()) || evt.getLeft().getCount() != 1 || evt.getLeft().getItem() != block_powered_spawner.getItem()) {
        return;
    }
    if (Prep.isInvalid(evt.getRight()) || evt.getRight().getCount() != 1 || evt.getRight().getItem() != ModObject.itemBrokenSpawner.getItem()) {
        return;
    }
    CapturedMob spawnerType = CapturedMob.create(evt.getRight());
    if (spawnerType == null || isBlackListed(spawnerType.getEntityName())) {
        return;
    }
    evt.setCost(SpawnerConfig.powerSpawnerAddSpawnerCost.get());
    evt.setOutput(evt.getLeft().copy());
    evt.getOutput().setTagCompound(spawnerType.toNbt(evt.getOutput().getTagCompound()));
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 10 with CapturedMob

use of crazypants.enderio.util.CapturedMob in project EnderIO by SleepyTrousers.

the class BlockPaintedPressurePlate method getDrop.

@Nonnull
protected ItemStack getDrop(@Nonnull IBlockAccess world, @Nonnull BlockPos pos) {
    CapturedMob mobType = getMobType(world, pos);
    ItemStack drop = mobType != null ? mobType.toStack(Item.getItemFromBlock(this), getMetaForStack(world, pos), 1) : new ItemStack(Item.getItemFromBlock(this), 1, getMetaForStack(world, pos));
    PaintUtil.setSourceBlock(drop, getPaintSource(world.getBlockState(pos), world, pos));
    return drop;
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Aggregations

CapturedMob (crazypants.enderio.util.CapturedMob)15 ItemStack (net.minecraft.item.ItemStack)9 ResourceLocation (net.minecraft.util.ResourceLocation)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 Nonnull (javax.annotation.Nonnull)3 BlockMobSpawner (net.minecraft.block.BlockMobSpawner)2 MobSpawnerBaseLogic (net.minecraft.tileentity.MobSpawnerBaseLogic)2 TileEntityMobSpawner (net.minecraft.tileentity.TileEntityMobSpawner)2 DyeColor (com.enderio.core.common.util.DyeColor)1 InvalidRecipeConfigException (crazypants.enderio.base.config.recipes.InvalidRecipeConfigException)1 ModObject (crazypants.enderio.base.init.ModObject)1 EnergyIngredient (crazypants.enderio.base.integration.jei.energy.EnergyIngredient)1 MachineRecipeInput (crazypants.enderio.base.recipe.MachineRecipeInput)1 ArrayList (java.util.ArrayList)1 IGuiItemStackGroup (mezz.jei.api.gui.IGuiItemStackGroup)1 FontRenderer (net.minecraft.client.gui.FontRenderer)1 IEntityOwnable (net.minecraft.entity.IEntityOwnable)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 TileEntity (net.minecraft.tileentity.TileEntity)1