Search in sources :

Example 1 with TileTeleposer

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

the class ItemSigilTeleposition method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (stack.getItem() instanceof ISigil.Holding)
        stack = ((Holding) stack.getItem()).getHeldItem(stack, player);
    if (PlayerHelper.isFakePlayer(player))
        return EnumActionResult.FAIL;
    if (!world.isRemote && player.isSneaking() && NBTHelper.checkNBT(stack) != null) {
        if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileTeleposer) {
            stack.getTagCompound().setInteger(Constants.NBT.DIMENSION_ID, world.provider.getDimension());
            stack.getTagCompound().setInteger(Constants.NBT.X_COORD, pos.getX());
            stack.getTagCompound().setInteger(Constants.NBT.Y_COORD, pos.getY());
            stack.getTagCompound().setInteger(Constants.NBT.Z_COORD, pos.getZ());
            return EnumActionResult.SUCCESS;
        }
    }
    return EnumActionResult.FAIL;
}
Also used : ItemStack(net.minecraft.item.ItemStack) TileTeleposer(WayofTime.bloodmagic.tile.TileTeleposer)

Example 2 with TileTeleposer

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

the class DataProviderTeleposer method getNBTData.

@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
    TileTeleposer teleposer = (TileTeleposer) te;
    ItemStack contained = teleposer.getStackInSlot(0);
    if (!contained.isEmpty() && contained.hasTagCompound()) {
        ItemTelepositionFocus focus = (ItemTelepositionFocus) contained.getItem();
        NBTTagCompound focusData = new NBTTagCompound();
        focusData.setTag("pos", NBTUtil.createPosTag(focus.getBlockPos(contained)));
        focusData.setInteger("dim", contained.getTagCompound().getInteger(Constants.NBT.DIMENSION_ID));
        tag.setTag("focus", focusData);
    }
    return tag;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) TileTeleposer(WayofTime.bloodmagic.tile.TileTeleposer) ItemTelepositionFocus(WayofTime.bloodmagic.item.ItemTelepositionFocus)

Example 3 with TileTeleposer

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

the class BlockTeleposer method breakBlock.

@Override
public void breakBlock(World world, BlockPos blockPos, IBlockState blockState) {
    TileTeleposer tileTeleposer = (TileTeleposer) world.getTileEntity(blockPos);
    if (tileTeleposer != null)
        tileTeleposer.dropItems();
    super.breakBlock(world, blockPos, blockState);
}
Also used : TileTeleposer(WayofTime.bloodmagic.tile.TileTeleposer)

Aggregations

TileTeleposer (WayofTime.bloodmagic.tile.TileTeleposer)3 ItemStack (net.minecraft.item.ItemStack)2 ItemTelepositionFocus (WayofTime.bloodmagic.item.ItemTelepositionFocus)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1