本文整理汇总了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;
}
示例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;
}