当前位置: 首页>>代码示例>>Java>>正文


Java IBlockSource.getBlockPos方法代码示例

本文整理汇总了Java中net.minecraft.dispenser.IBlockSource.getBlockPos方法的典型用法代码示例。如果您正苦于以下问题:Java IBlockSource.getBlockPos方法的具体用法?Java IBlockSource.getBlockPos怎么用?Java IBlockSource.getBlockPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.dispenser.IBlockSource的用法示例。


在下文中一共展示了IBlockSource.getBlockPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dispenseStack

import net.minecraft.dispenser.IBlockSource; //导入方法依赖的package包/类
@Override
public ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
       World world = source.getWorld();
       BlockPos pos = source.getBlockPos();
       Vec3d pos2 = new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
       Vec3d dir = this.getNearestTargetDirection(world, pos);
       if(dir == null) return null;
       IPosition ipos = new PositionImpl(pos2.x + dir.x * .75, pos2.y + dir.y * .75, pos2.z + dir.z * .75);
          double d0 = ipos.getX();
          double d1 = ipos.getY();
          double d2 = ipos.getZ();
          Random random = world.rand;
          double d3 = random.nextGaussian() * 0.05D + dir.x;
          double d4 = random.nextGaussian() * 0.05D + dir.y;
          double d5 = random.nextGaussian() * 0.05D + dir.z;
          world.spawnEntity(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5));
          stack.splitStack(1);
          return stack;
}
 
开发者ID:sblectric,项目名称:AdvancedCombat,代码行数:20,代码来源:TrackingDispenserBehavior.java

示例2: dispenseStack

import net.minecraft.dispenser.IBlockSource; //导入方法依赖的package包/类
@Override
public ItemStack dispenseStack(IBlockSource blocksource, ItemStack itemstack)
{

	BlockPos blockpos = blocksource.getBlockPos();
	boolean canfire = false;
	normalDispense = false;

	// / double x = MathHelper.floor_double(blockpos.getX());
	// double y = MathHelper.floor_double(blockpos.getY());
	// double z = MathHelper.floor_double(blockpos.getZ());

	TileEntity tileentity = blocksource.getWorld().getTileEntity(blockpos);
	if (tileentity instanceof TileEntityDispenser)
	{
		TileEntityDispenser dispenser = ((TileEntityDispenser) tileentity);
		Item itemtocheck = null;
		if (itemstack.getItem() == Items.gunpowder)
		{
			itemtocheck = WeaponModule.items.ballista_bolt;
		}
		else if (itemstack.getItem() == WeaponModule.items.ballista_bolt)
		{
			itemtocheck = Items.gunpowder;
		}

		for (int i = 0; i < dispenser.getSizeInventory(); i++)
		{
			ItemStack itemstack1 = dispenser.getStackInSlot(i);
			if (itemstack1 != null && itemstack1.getItem() == itemtocheck)
			{
				dispenser.decrStackSize(i, 1);
				canfire = true;
				break;
			}
		}
	}

	if (!canfire)
	{
		normalDispense = true;
		return super.dispenseStack(blocksource, itemstack);
	}

	EnumFacing face = BlockDispenser.getFacing(blocksource.getBlockMetadata());
	double xvel = face.getFrontOffsetX() * 1.5D;
	double yvel = face.getFrontOffsetY() * 1.5D;
	double zvel = face.getFrontOffsetZ() * 1.5D;
	IPosition pos = BlockDispenser.getDispensePosition(blocksource);

	EntityBallistaBolt entityballistabolt = new EntityBallistaBolt(blocksource.getWorld(),
			pos.getX() + xvel, pos.getY() + yvel, pos.getZ() + zvel);
	entityballistabolt.setThrowableHeading(xvel, yvel + 0.15D, zvel, 2.0F, 2.0F);
	blocksource.getWorld().spawnEntityInWorld(entityballistabolt);
	itemstack.splitStack(1);
	return itemstack;
}
 
开发者ID:Archiving,项目名称:ARKCraft-Code,代码行数:58,代码来源:DispenseBallistaBolt.java


注:本文中的net.minecraft.dispenser.IBlockSource.getBlockPos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。