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;
}
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;
}
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;
}
}
Aggregations