當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。