本文整理汇总了Java中net.minecraft.util.MovingObjectPosition.getBlockPos方法的典型用法代码示例。如果您正苦于以下问题:Java MovingObjectPosition.getBlockPos方法的具体用法?Java MovingObjectPosition.getBlockPos怎么用?Java MovingObjectPosition.getBlockPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.MovingObjectPosition
的用法示例。
在下文中一共展示了MovingObjectPosition.getBlockPos方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawSelectionBox
import net.minecraft.util.MovingObjectPosition; //导入方法依赖的package包/类
/**
* Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
*/
public void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int p_72731_3_, float partialTicks)
{
if (p_72731_3_ == 0 && movingObjectPositionIn.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
GL11.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
float f = 0.002F;
BlockPos blockpos = movingObjectPositionIn.getBlockPos();
Block block = this.theWorld.getBlockState(blockpos).getBlock();
if (block.getMaterial() != Material.air && this.theWorld.getWorldBorder().contains(blockpos))
{
block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
func_181561_a(block.getSelectedBoundingBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
}
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
}
示例2: onItemRightClick
import net.minecraft.util.MovingObjectPosition; //导入方法依赖的package包/类
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
if (movingobjectposition == null)
{
return itemStackIn;
}
else
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
BlockPos blockpos = movingobjectposition.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos))
{
return itemStackIn;
}
if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
{
return itemStackIn;
}
if (worldIn.getBlockState(blockpos).getBlock().getMaterial() == Material.water)
{
--itemStackIn.stackSize;
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
if (itemStackIn.stackSize <= 0)
{
return new ItemStack(Items.potionitem);
}
if (!playerIn.inventory.addItemStackToInventory(new ItemStack(Items.potionitem)))
{
playerIn.dropPlayerItemWithRandomChoice(new ItemStack(Items.potionitem, 1, 0), false);
}
}
}
return itemStackIn;
}
}
示例3: onItemRightClick
import net.minecraft.util.MovingObjectPosition; //导入方法依赖的package包/类
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
if (worldIn.isRemote)
{
return itemStackIn;
}
else
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
if (movingobjectposition == null)
{
return itemStackIn;
}
else
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
BlockPos blockpos = movingobjectposition.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos))
{
return itemStackIn;
}
if (!playerIn.canPlayerEdit(blockpos, movingobjectposition.sideHit, itemStackIn))
{
return itemStackIn;
}
if (worldIn.getBlockState(blockpos).getBlock() instanceof BlockLiquid)
{
Entity entity = spawnCreature(worldIn, itemStackIn.getMetadata(), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D);
if (entity != null)
{
if (entity instanceof EntityLivingBase && itemStackIn.hasDisplayName())
{
((EntityLiving)entity).setCustomNameTag(itemStackIn.getDisplayName());
}
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
}
}
}
return itemStackIn;
}
}
}
示例4: onItemRightClick
import net.minecraft.util.MovingObjectPosition; //导入方法依赖的package包/类
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
boolean flag = this.isFull == Blocks.air;
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, flag);
if (movingobjectposition == null)
{
return itemStackIn;
}
else
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
BlockPos blockpos = movingobjectposition.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos))
{
return itemStackIn;
}
if (flag)
{
if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
{
return itemStackIn;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos);
Material material = iblockstate.getBlock().getMaterial();
if (material == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
{
worldIn.setBlockToAir(blockpos);
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
return this.fillBucket(itemStackIn, playerIn, Items.water_bucket);
}
if (material == Material.lava && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)
{
worldIn.setBlockToAir(blockpos);
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
return this.fillBucket(itemStackIn, playerIn, Items.lava_bucket);
}
}
else
{
if (this.isFull == Blocks.air)
{
return new ItemStack(Items.bucket);
}
BlockPos blockpos1 = blockpos.offset(movingobjectposition.sideHit);
if (!playerIn.canPlayerEdit(blockpos1, movingobjectposition.sideHit, itemStackIn))
{
return itemStackIn;
}
if (this.tryPlaceContainedLiquid(worldIn, blockpos1) && !playerIn.capabilities.isCreativeMode)
{
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
return new ItemStack(Items.bucket);
}
}
}
return itemStackIn;
}
}
示例5: onItemRightClick
import net.minecraft.util.MovingObjectPosition; //导入方法依赖的package包/类
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
if (movingobjectposition == null)
{
return itemStackIn;
}
else
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
BlockPos blockpos = movingobjectposition.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos))
{
return itemStackIn;
}
if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
{
return itemStackIn;
}
BlockPos blockpos1 = blockpos.up();
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))
{
worldIn.setBlockState(blockpos1, Blocks.waterlily.getDefaultState());
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
}
}
return itemStackIn;
}
}
示例6: drawSelectionBox
import net.minecraft.util.MovingObjectPosition; //导入方法依赖的package包/类
/**
* Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
*/
public void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int p_72731_3_, float partialTicks)
{
if (p_72731_3_ == 0 && movingObjectPositionIn.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
GL11.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
if (Config.isShaders())
{
Shaders.disableTexture2D();
}
GlStateManager.depthMask(false);
float f = 0.002F;
BlockPos blockpos = movingObjectPositionIn.getBlockPos();
Block block = this.theWorld.getBlockState(blockpos).getBlock();
if (block.getMaterial() != Material.air && this.theWorld.getWorldBorder().contains(blockpos))
{
block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
func_181561_a(block.getSelectedBoundingBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
}
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
if (Config.isShaders())
{
Shaders.enableTexture2D();
}
GlStateManager.disableBlend();
}
}