Search in sources :

Example 1 with TileTotemPole

use of pokefenn.totemic.tileentity.totem.TileTotemPole in project Totemic by TeamTotemic.

the class BlockTotemPole method onTotemicStaffRightClick.

@Override
public EnumActionResult onTotemicStaffRightClick(World world, BlockPos pos, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
        TileTotemPole pole = (TileTotemPole) world.getTileEntity(pos);
        String name = pole.getEffect() != null ? pole.getEffect().getUnlocalizedName() : "totemicmisc.noEffect";
        player.sendStatusMessage(new TextComponentTranslation("totemicmisc.activeEffect", new TextComponentTranslation(name)), true);
    }
    return EnumActionResult.SUCCESS;
}
Also used : TileTotemPole(pokefenn.totemic.tileentity.totem.TileTotemPole) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation)

Example 2 with TileTotemPole

use of pokefenn.totemic.tileentity.totem.TileTotemPole in project Totemic by TeamTotemic.

the class ItemMedicineBag method trySetEffect.

private EnumActionResult trySetEffect(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand) {
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileTotemPole) {
        TotemEffect effect = ((TileTotemPole) tile).getEffect();
        if (effect != null) {
            if (!effect.isPortable()) {
                if (world.isRemote)
                    player.sendStatusMessage(new TextComponentTranslation("totemicmisc.effectNotPortable", new TextComponentTranslation(effect.getUnlocalizedName())), true);
                return EnumActionResult.FAIL;
            }
            ItemStack newStack = stack.copy();
            NBTTagCompound tag = ItemUtil.getOrCreateTag(newStack);
            tag.setString(MED_BAG_TOTEM_KEY, effect.getRegistryName().toString());
            if (tag.getInteger(MED_BAG_CHARGE_KEY) != -1)
                tag.setInteger(MED_BAG_CHARGE_KEY, 0);
            player.setHeldItem(hand, newStack);
            return EnumActionResult.SUCCESS;
        }
    }
    return EnumActionResult.FAIL;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileTotemPole(pokefenn.totemic.tileentity.totem.TileTotemPole) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TotemEffect(pokefenn.totemic.api.totem.TotemEffect) StateTotemEffect(pokefenn.totemic.tileentity.totem.StateTotemEffect) ItemStack(net.minecraft.item.ItemStack)

Example 3 with TileTotemPole

use of pokefenn.totemic.tileentity.totem.TileTotemPole in project Totemic by TeamTotemic.

the class ItemTotemWhittlingKnife method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (player.isSneaking()) {
        player.setHeldItem(hand, changeIndex(stack, true));
        return EnumActionResult.SUCCESS;
    } else {
        IBlockState state = world.getBlockState(pos);
        WoodVariant wood = WoodVariant.fromLog(state);
        if (wood == null) {
            // Fall back to oak if it is an unrecognized log type
            if (state.getBlock().isWood(world, pos) && state.getBlock() != ModBlocks.stripped_cedar_log)
                wood = WoodVariant.OAK;
            else
                return EnumActionResult.FAIL;
        }
        TotemEffect effect = getCarvingEffect(stack);
        if (effect != null) {
            world.setBlockState(pos, ModBlocks.totem_pole.getDefaultState().withProperty(BlockTotemPole.WOOD, wood), 0);
            TileTotemPole tile = (TileTotemPole) world.getTileEntity(pos);
            tile.setEffect(effect);
            tile.markForUpdate();
        } else {
            world.setBlockState(pos, ModBlocks.totem_base.getDefaultState().withProperty(BlockTotemBase.WOOD, wood), 3);
        }
        state = world.getBlockState(pos);
        state.getBlock().onBlockPlacedBy(world, pos, state, player, stack);
        stack.damageItem(1, player);
        return EnumActionResult.SUCCESS;
    }
}
Also used : WoodVariant(pokefenn.totemic.lib.WoodVariant) TileTotemPole(pokefenn.totemic.tileentity.totem.TileTotemPole) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack) TotemEffect(pokefenn.totemic.api.totem.TotemEffect)

Aggregations

TileTotemPole (pokefenn.totemic.tileentity.totem.TileTotemPole)3 ItemStack (net.minecraft.item.ItemStack)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 TotemEffect (pokefenn.totemic.api.totem.TotemEffect)2 IBlockState (net.minecraft.block.state.IBlockState)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 TileEntity (net.minecraft.tileentity.TileEntity)1 WoodVariant (pokefenn.totemic.lib.WoodVariant)1 StateTotemEffect (pokefenn.totemic.tileentity.totem.StateTotemEffect)1