Search in sources :

Example 1 with CapturedMob

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

the class ItemSoulVial method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, @Nonnull List<String> tooltip, @Nonnull ITooltipFlag flagIn) {
    super.addInformation(stack, worldIn, tooltip, flagIn);
    CapturedMob capturedMob = CapturedMob.create(stack);
    if (capturedMob != null) {
        tooltip.add(capturedMob.getDisplayName());
        float health = capturedMob.getHealth();
        if (health >= 0) {
            float maxHealth = capturedMob.getMaxHealth();
            if (maxHealth >= 0) {
                tooltip.add(Lang.SOUL_VIAL_HEALTH.get(String.format("%3.1f/%3.1f", health, maxHealth)));
            } else {
                tooltip.add(Lang.SOUL_VIAL_HEALTH.get(String.format("%3.1f", health)));
            }
        }
        String fluidName = capturedMob.getFluidName();
        if (fluidName != null) {
            Fluid fluid = FluidRegistry.getFluid(fluidName);
            if (fluid != null) {
                String localizedName = fluid.getLocalizedName(new FluidStack(fluid, 1));
                tooltip.add(Lang.SOUL_VIAL_FLUID.get(localizedName));
            }
        }
        DyeColor color = capturedMob.getColor();
        if (color != null) {
            tooltip.add(Lang.SOUL_VIAL_COLOR.get(color.getLocalisedName()));
        }
    } else {
        tooltip.add(Lang.SOUL_VIAL_EMPTY.get());
    }
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) DyeColor(com.enderio.core.common.util.DyeColor) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with CapturedMob

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

the class ItemSoulVial method onItemUse.

@Override
@Nonnull
public EnumActionResult onItemUse(@Nonnull EntityPlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumHand hand, @Nonnull EnumFacing side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        return EnumActionResult.PASS;
    }
    ItemStack itemstack = player.getHeldItem(hand);
    CapturedMob capturedMob = CapturedMob.create(itemstack);
    if (capturedMob == null) {
        return EnumActionResult.SUCCESS;
    }
    if (!PermissionAPI.hasPermission(player.getGameProfile(), permissionPlace, new BlockPosContext(player, pos, null, side))) {
        player.sendMessage(Lang.SOUL_VIAL_DENIED.toChatServer());
        return EnumActionResult.SUCCESS;
    }
    if (!capturedMob.spawn(world, pos, side, true)) {
        return EnumActionResult.SUCCESS;
    }
    if (!player.capabilities.isCreativeMode) {
        itemstack.shrink(1);
        final ItemStack emptyVial = new ItemStack(this);
        if (Prep.isInvalid(itemstack)) {
            player.setHeldItem(hand, emptyVial);
        } else if (!player.inventory.addItemStackToInventory(emptyVial)) {
            player.dropItem(emptyVial, false);
        }
        player.inventoryContainer.detectAndSendChanges();
    }
    return EnumActionResult.SUCCESS;
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) BlockPosContext(net.minecraftforge.server.permission.context.BlockPosContext) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Example 3 with CapturedMob

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

the class ItemBrokenSpawner method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, @Nonnull List<String> tooltip, @Nonnull ITooltipFlag flagIn) {
    super.addInformation(stack, worldIn, tooltip, flagIn);
    CapturedMob mob = CapturedMob.create(stack);
    if (mob != null) {
        tooltip.add(mob.getDisplayName());
    }
    if (!SpecialTooltipHandler.showAdvancedTooltips()) {
        SpecialTooltipHandler.addShowDetailsTooltip(tooltip);
    } else {
        SpecialTooltipHandler.addDetailedTooltipFromResources(tooltip, stack);
    }
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with CapturedMob

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

the class LootManager method onLootTableLoad.

@SubscribeEvent
public void onLootTableLoad(@Nonnull LootTableLoadEvent evt) {
    LootTable table = evt.getTable();
    LootPool lp = new LootPool(new LootEntry[0], NO_CONDITIONS, new RandomValueRange(1, 3), new RandomValueRange(0, 0), EnderIO.MOD_NAME);
    if (evt.getName().equals(LootTableList.CHESTS_SIMPLE_DUNGEON)) {
        lp.addEntry(createLootEntry(Alloy.DARK_STEEL.getStackIngot(), 1, 3, 0.25F));
        lp.addEntry(createLootEntry(itemConduitProbe.getItemNN(), 0.10F));
        lp.addEntry(createLootEntry(Items.QUARTZ, 3, 16, 0.25F));
        lp.addEntry(createLootEntry(Items.NETHER_WART, 1, 4, 0.20F));
        lp.addEntry(createLootEntry(Items.ENDER_PEARL, 1, 2, 0.30F));
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 0.1F));
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBoots.getItemNN(), 0.1F));
        lp.addEntry(createLootEntry(Material.GEAR_WOOD.getStack(), 1, 2, 0.5F));
        lp.addEntry(createLootCapacitor(0.15F));
        lp.addEntry(createLootCapacitor(0.15F));
        lp.addEntry(createLootCapacitor(0.15F));
    } else if (evt.getName().equals(LootTableList.CHESTS_ABANDONED_MINESHAFT)) {
        lp.addEntry(createLootEntry(Alloy.DARK_STEEL.getStackIngot(), 1, 3, 0.05F));
        lp.addEntry(createLootEntry(Items.ENDER_PEARL, 1, 2, 0.10F));
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 0.2F));
        lp.addEntry(createLootEntry(Material.GEAR_WOOD.getStack(), 1, 2, 0.5F));
        lp.addEntry(createLootCapacitor(0.15F));
        lp.addEntry(createLootCapacitor(0.05F));
        lp.addEntry(createLootEntry(ModObject.blockExitRail.getItemNN(), 1, 2, 0.15F));
    } else if (evt.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) {
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBoots.getItemNN(), 0.1F));
        lp.addEntry(createLootEntry(Material.GEAR_IRON.getStack(), 1, 2, 0.5F));
        lp.addEntry(createLootCapacitor(0.15F));
    } else if (evt.getName().equals(LootTableList.CHESTS_IGLOO_CHEST)) {
        final CapturedMob polarBear = CapturedMob.create(new ResourceLocation("minecraft", "polar_bear"));
        if (polarBear != null) {
            lp.addEntry(new LootEntryItem(ModObject.itemSoulVial.getItemNN(), 1, 1, new LootFunction[] { setCount(1, 1), new SetNBT(NO_CONDITIONS, polarBear.toNbt(null)) }, new LootCondition[] { new RandomChance(.2F) }, "PolarBearSoulVial"));
        }
        lp.addEntry(createLootEntry(ModObject.itemSoulVial.getItemNN(), 1, 3, 0.5F));
        lp.addEntry(createLootCapacitor(0.05F));
    } else if (evt.getName().equals(LootTableList.CHESTS_JUNGLE_TEMPLE_DISPENSER)) {
        ItemStack bucket = Fluids.FIRE_WATER.getBucket();
        lp.addEntry(new LootEntryItem(bucket.getItem(), 1, 1, new LootFunction[] { setCount(1, 1), setMetadata(bucket.getMetadata()), setNBT(bucket) }, new LootCondition[] { new RandomChance(.05F) }, bucket.getItem().getUnlocalizedName() + ":" + bucket.getMetadata()));
    } else if (evt.getName().equals(LootTableList.CHESTS_VILLAGE_BLACKSMITH)) {
        lp.addEntry(createLootEntry(Alloy.ELECTRICAL_STEEL.getStackIngot(), 2, 6, 0.20F));
        lp.addEntry(createLootEntry(Alloy.REDSTONE_ALLOY.getStackIngot(), 3, 6, 0.35F));
        lp.addEntry(createLootEntry(Alloy.DARK_STEEL.getStackIngot(), 3, 6, 0.35F));
        lp.addEntry(createLootEntry(Alloy.PULSATING_IRON.getStackIngot(), 1, 2, 0.3F));
        lp.addEntry(createLootEntry(Alloy.VIBRANT_ALLOY.getStackIngot(), 1, 2, 0.2F));
        lp.addEntry(createLootEntry(Material.GEAR_WOOD.getStack(), 1, 2, 0.5F));
        lp.addEntry(createLootEntry(Material.GEAR_STONE.getStack(), 1, 2, 0.4F));
        lp.addEntry(createLootEntry(Material.GEAR_IRON.getStack(), 1, 2, 0.25F));
        lp.addEntry(createLootEntry(Material.GEAR_ENERGIZED.getStack(), 1, 2, 0.125F));
        lp.addEntry(createLootEntry(Material.GEAR_VIBRANT.getStack(), 1, 2, 0.0625F));
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 1, 1, 0.25F));
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBoots.getItemNN(), 1, 1, 0.25F));
        lp.addEntry(createLootCapacitor(0.1F));
    } else if (evt.getName().equals(LootTableList.CHESTS_DESERT_PYRAMID)) {
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 0.2F));
        lp.addEntry(createLootEntry(Material.GEAR_VIBRANT.getStack(), 1, 2, 0.0625F));
        lp.addEntry(createLootEntry(itemTravelStaff.getItemNN(), 0.1F));
        lp.addEntry(createLootCapacitor(25));
    } else if (evt.getName().equals(LootTableList.CHESTS_JUNGLE_TEMPLE)) {
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelSword.getItemNN(), 1, 1, 0.25F));
        lp.addEntry(createLootEntry(itemTravelStaff.getItemNN(), 1, 1, 0.1F));
        lp.addEntry(createLootCapacitor(0.25F));
        lp.addEntry(createLootCapacitor(0.25F));
    } else if (evt.getName().equals(LootTableList.CHESTS_WOODLAND_MANSION)) {
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBow.getItemNN(), 1, 1, 0.25F));
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelAxe.getItemNN(), 1, 1, 0.25F));
        lp.addEntry(createLootEntry(Material.GEAR_STONE.getStack(), 1, 2, 0.4F));
        lp.addEntry(createLootCapacitor(0.25F));
        lp.addEntry(createLootEntry(itemTravelStaff.getItemNN(), 1, 1, 0.1F));
    } else if (evt.getName().equals(LootTableList.CHESTS_END_CITY_TREASURE)) {
        final CapturedMob shulker = CapturedMob.create(new ResourceLocation("minecraft", "shulker"));
        if (shulker != null) {
            lp.addEntry(new LootEntryItem(ModObject.itemSoulVial.getItemNN(), 1, 1, new LootFunction[] { setCount(1, 1), new SetNBT(NO_CONDITIONS, shulker.toNbt(null)) }, new LootCondition[] { new RandomChance(.2F) }, "ShulkerSoulVial"));
        }
        lp.addEntry(createLootEntry(ModObject.itemSoulVial.getItemNN(), 1, 3, 0.5F));
        lp.addEntry(createLootEntry(Material.GEAR_ENERGIZED.getStack(), 1, 2, 0.125F));
        lp.addEntry(createLootEntry(Material.GEAR_VIBRANT.getStack(), 1, 2, 0.125F));
        lp.addEntry(createLootCapacitor(0.05F));
        lp.addEntry(createDarkSteelLootEntry(ModObject.itemDarkSteelBow.getItemNN(), 1, 1, 0.25F));
    } else {
        return;
    }
    if (table.isFrozen()) {
        throw new RuntimeException("Some other mod (a list of suspects is printed in the log file) put a frozen loot table into the load event for loot table '" + evt.getName() + "'. This is a bug in that other mod. Ender IO is the victim here. Don't blame the victim!");
    }
    table.addPool(lp);
}
Also used : LootTable(net.minecraft.world.storage.loot.LootTable) RandomValueRange(net.minecraft.world.storage.loot.RandomValueRange) CapturedMob(crazypants.enderio.util.CapturedMob) ResourceLocation(net.minecraft.util.ResourceLocation) SetNBT(net.minecraft.world.storage.loot.functions.SetNBT) RandomChance(net.minecraft.world.storage.loot.conditions.RandomChance) LootEntryItem(net.minecraft.world.storage.loot.LootEntryItem) LootFunction(net.minecraft.world.storage.loot.functions.LootFunction) LootPool(net.minecraft.world.storage.loot.LootPool) LootCondition(net.minecraft.world.storage.loot.conditions.LootCondition) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with CapturedMob

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

the class Entity method enforceValidity.

@Override
public void enforceValidity() throws InvalidRecipeConfigException {
    if (!isValid()) {
        Log.warn("Could not find an entity for '" + name + "'");
        Log.warn("Available entities are:");
        for (CapturedMob possible : CapturedMob.getAllSouls()) {
            Log.warn(" -> " + possible.getEntityName() + " (" + possible.getDisplayName() + ")");
        // Log.warn(" <entity name=\"" + possible.getEntityName() + "\" costMultiplier=\"1\" disabled=\"false\"/> <!-- " + possible.getDisplayName() + " -->");
        }
        throw new InvalidRecipeConfigException("Could not find an entity for '" + name + "'");
    }
}
Also used : CapturedMob(crazypants.enderio.util.CapturedMob) InvalidRecipeConfigException(crazypants.enderio.base.config.recipes.InvalidRecipeConfigException)

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