Search in sources :

Example 1 with TileAltar

use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.

the class BlockAltar method breakBlock.

@Override
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
    TileEntity tile = world.getTileEntity(blockPos);
    if (tile instanceof TileAltar)
        ((TileAltar) tile).dropItems();
    super.breakBlock(world, blockPos, blockState);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileAltar(WayofTime.bloodmagic.tile.TileAltar)

Example 2 with TileAltar

use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.

the class BlockAltar method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    TileAltar altar = (TileAltar) world.getTileEntity(pos);
    if (altar == null || player.isSneaking())
        return false;
    ItemStack playerItem = player.getHeldItem(hand);
    if (playerItem.getItem() instanceof IAltarReader || playerItem.getItem() instanceof IAltarManipulator) {
        playerItem.getItem().onItemRightClick(world, player, hand);
        return true;
    }
    if (Utils.insertItemToTile(altar, player))
        altar.startCycle();
    else
        altar.setActive();
    world.notifyBlockUpdate(pos, state, state, 3);
    return true;
}
Also used : ItemStack(net.minecraft.item.ItemStack) TileAltar(WayofTime.bloodmagic.tile.TileAltar) IAltarReader(WayofTime.bloodmagic.iface.IAltarReader)

Example 3 with TileAltar

use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.

the class DataProviderBloodAltar method getNBTData.

@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
    TileAltar altar = (TileAltar) te;
    boolean hasSigil = false;
    boolean hasSeer = false;
    switch(ConfigHandler.compat.wailaAltarDisplayMode) {
        case ALWAYS:
            {
                hasSigil = hasSeer = true;
                break;
            }
        case SIGIL_HELD:
            {
                hasSeer = holdingSeerSigil(player);
                hasSigil = hasSeer || holdingDivinationSigil(player);
                break;
            }
        case SIGIL_CONTAINED:
            {
                hasSeer = hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_SEER), player);
                hasSigil = hasSeer || hasStack(new ItemStack(RegistrarBloodMagicItems.SIGIL_DIVINATION), player);
                break;
            }
    }
    if (!hasSeer && !hasSigil)
        return tag;
    NBTTagCompound altarData = new NBTTagCompound();
    altarData.setInteger("tier", altar.getTier().toInt());
    altarData.setInteger("capacity", altar.getCapacity());
    altarData.setInteger("stored", altar.getCurrentBlood());
    if (hasSeer) {
        altarData.setInteger("progress", (int) (((double) altar.getProgress() / (double) altar.getLiquidRequired() * 100) / altar.getStackInSlot(0).getCount()));
        altarData.setInteger("charge", altar.getTotalCharge());
    }
    tag.setTag("altar", altarData);
    return tag;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) TileAltar(WayofTime.bloodmagic.tile.TileAltar) Nonnull(javax.annotation.Nonnull)

Example 4 with TileAltar

use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.

the class AltarUtil method getTier.

@Nonnull
public static AltarTier getTier(World world, BlockPos pos) {
    TileEntity tile = world.getTileEntity(pos);
    if (!(tile instanceof TileAltar))
        return AltarTier.ONE;
    AltarTier lastCheck = AltarTier.ONE;
    for (AltarTier tier : AltarTier.values()) {
        for (AltarComponent component : tier.getAltarComponents()) {
            BlockPos componentPos = pos.add(component.getOffset());
            IBlockState worldState = world.getBlockState(componentPos);
            if (worldState.getBlock() instanceof IAltarComponent)
                if (((IAltarComponent) worldState.getBlock()).getType(world, worldState, componentPos) == component.getComponent())
                    continue;
            if (component.getComponent() == ComponentType.NOTAIR && worldState.getMaterial() != Material.AIR && !worldState.getMaterial().isLiquid())
                continue;
            List<IBlockState> validStates = BloodMagicAPI.INSTANCE.getComponentStates(component.getComponent());
            if (!validStates.contains(worldState))
                return lastCheck;
        }
        lastCheck = tier;
    }
    return lastCheck;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) TileAltar(WayofTime.bloodmagic.tile.TileAltar) Nonnull(javax.annotation.Nonnull)

Example 5 with TileAltar

use of WayofTime.bloodmagic.tile.TileAltar in project BloodMagic by WayofTime.

the class ItemSacrificialDagger method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    if (PlayerHelper.isFakePlayer(player))
        return super.onItemRightClick(world, player, hand);
    if (this.canUseForSacrifice(stack)) {
        player.setActiveHand(hand);
        return new ActionResult<>(EnumActionResult.SUCCESS, stack);
    }
    int lpAdded = ConfigHandler.values.sacrificialDaggerConversion * 2;
    RayTraceResult rayTrace = rayTrace(world, player, false);
    if (rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK) {
        TileEntity tile = world.getTileEntity(rayTrace.getBlockPos());
        if (tile != null && tile instanceof TileAltar && stack.getItemDamage() == 1)
            lpAdded = ((TileAltar) tile).getCapacity();
    }
    if (!player.capabilities.isCreativeMode) {
        SacrificeKnifeUsedEvent evt = new SacrificeKnifeUsedEvent(player, true, true, 2, lpAdded);
        if (MinecraftForge.EVENT_BUS.post(evt))
            return super.onItemRightClick(world, player, hand);
        if (evt.shouldDrainHealth) {
            player.hurtResistantTime = 0;
            player.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 0.001F);
            player.setHealth(Math.max(player.getHealth() - 2, 0.0001f));
            if (player.getHealth() <= 0.001f) {
                player.onDeath(DamageSourceBloodMagic.INSTANCE);
                player.setHealth(0);
            }
        // player.attackEntityFrom(BloodMagicAPI.getDamageSource(), 2.0F);
        }
        if (!evt.shouldFillAltar)
            return super.onItemRightClick(world, player, hand);
        lpAdded = evt.lpAdded;
    }
    double posX = player.posX;
    double posY = player.posY;
    double posZ = player.posZ;
    world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
    for (int l = 0; l < 8; ++l) world.spawnParticle(EnumParticleTypes.REDSTONE, posX + Math.random() - Math.random(), posY + Math.random() - Math.random(), posZ + Math.random() - Math.random(), 0, 0, 0);
    if (!world.isRemote && PlayerHelper.isFakePlayer(player))
        return super.onItemRightClick(world, player, hand);
    // TODO - Check if SoulFray is active
    PlayerSacrificeHelper.findAndFillAltar(world, player, lpAdded, false);
    return super.onItemRightClick(world, player, hand);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) SacrificeKnifeUsedEvent(WayofTime.bloodmagic.event.SacrificeKnifeUsedEvent) RayTraceResult(net.minecraft.util.math.RayTraceResult) ItemStack(net.minecraft.item.ItemStack) TileAltar(WayofTime.bloodmagic.tile.TileAltar)

Aggregations

TileAltar (WayofTime.bloodmagic.tile.TileAltar)8 TileEntity (net.minecraft.tileentity.TileEntity)5 ItemStack (net.minecraft.item.ItemStack)4 Nonnull (javax.annotation.Nonnull)2 BlockPos (net.minecraft.util.math.BlockPos)2 BloodMagic (WayofTime.bloodmagic.BloodMagic)1 Sprite (WayofTime.bloodmagic.client.Sprite)1 Binding (WayofTime.bloodmagic.core.data.Binding)1 SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)1 SacrificeKnifeUsedEvent (WayofTime.bloodmagic.event.SacrificeKnifeUsedEvent)1 IAltarReader (WayofTime.bloodmagic.iface.IAltarReader)1 IBindable (WayofTime.bloodmagic.iface.IBindable)1 BloodOrb (WayofTime.bloodmagic.orb.BloodOrb)1 IBloodOrb (WayofTime.bloodmagic.orb.IBloodOrb)1 TileIncenseAltar (WayofTime.bloodmagic.tile.TileIncenseAltar)1 TileInversionPillar (WayofTime.bloodmagic.tile.TileInversionPillar)1 NumeralHelper (WayofTime.bloodmagic.util.helper.NumeralHelper)1 List (java.util.List)1 Function (java.util.function.Function)1 IBlockState (net.minecraft.block.state.IBlockState)1