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