本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.canPlayerEdit方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.canPlayerEdit方法的具体用法?Java EntityPlayer.canPlayerEdit怎么用?Java EntityPlayer.canPlayerEdit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.canPlayerEdit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (stack.stackSize == 0)
return false;
else if (!player.canPlayerEdit(x, y, z, side, stack))
return false;
else {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
boolean flag = meta == 1;
if (block == field_150939_a && (side == 1 && !flag || side == 0 && flag)) {
if (world.checkNoEntityCollision(field_150939_a.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlock(x, y, z, field_150939_a, 2, 3)) {
world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, field_150939_a.stepSound.func_150496_b(), (field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, field_150939_a.stepSound.getPitch() * 0.8F);
stack.stackSize--;
}
return true;
} else
return func_150946_a(stack, player, world, x, y, z, side) ? true : super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ);
}
}
示例2: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (stack.getItemDamage() == EnumItems.TIMEMEAL.ordinal() && player.canPlayerEdit(pos, facing, stack)) {
Block crops = world.getBlockState(pos).getBlock();
if (crops != null && crops instanceof BlockCrops) {
if (crops != UCBlocks.cropMerlinia)
world.setBlockState(pos, ((BlockCrops)crops).withAge(0), 2);
else if (crops == UCBlocks.cropMerlinia)
((Merlinia)crops).merliniaGrowth(world, pos, world.rand.nextInt(1) + 1);
else if (crops instanceof BlockNetherWart)
((BlockNetherWart)crops).updateTick(world, pos, world.getBlockState(pos), world.rand);
if (!player.capabilities.isCreativeMode && !player.worldObj.isRemote)
stack.stackSize--;
UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.VILLAGER_HAPPY, pos.getX() - 0.5D, pos.getY(), pos.getZ() - 0.5D, 6));
return EnumActionResult.SUCCESS;
}
}
return super.onItemUse(stack, player, world, pos, hand, facing, hitX, hitY, hitZ);
}
示例3: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (side == EnumFacing.DOWN)
{
return false;
}
else if (side == EnumFacing.UP)
{
return false;
}
else
{
BlockPos blockpos = pos.offset(side);
if (!playerIn.canPlayerEdit(blockpos, side, stack))
{
return false;
}
else
{
EntityHanging entityhanging = this.createEntity(worldIn, blockpos, side);
if (entityhanging != null && entityhanging.onValidSurface())
{
if (!worldIn.isRemote)
{
worldIn.spawnEntityInWorld(entityhanging);
}
--stack.stackSize;
}
return true;
}
}
}
示例4: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
ItemStack itemstack = stack.getHeldItem(pos);
if (!stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack))
{
return EnumActionResult.FAIL;
}
else
{
IBlockState iblockstate = playerIn.getBlockState(worldIn);
Block block = iblockstate.getBlock();
if (hand != EnumFacing.DOWN && playerIn.getBlockState(worldIn.up()).getMaterial() == Material.AIR && block == Blocks.GRASS)
{
IBlockState iblockstate1 = Blocks.GRASS_PATH.getDefaultState();
playerIn.playSound(stack, worldIn, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
if (!playerIn.isRemote)
{
playerIn.setBlockState(worldIn, iblockstate1, 11);
itemstack.damageItem(1, stack);
}
return EnumActionResult.SUCCESS;
}
else
{
return EnumActionResult.PASS;
}
}
}
示例5: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);
if (raytraceresult == null)
{
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
else
{
if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK)
{
BlockPos blockpos = raytraceresult.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos) || !playerIn.canPlayerEdit(blockpos.offset(raytraceresult.sideHit), raytraceresult.sideHit, itemStackIn))
{
return new ActionResult(EnumActionResult.FAIL, itemStackIn);
}
BlockPos blockpos1 = blockpos.up();
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getMaterial() == Material.LAVA && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))
{
worldIn.setBlockState(blockpos1, UCBlocks.lavalily.getDefaultState(), 11);
if (!playerIn.capabilities.isCreativeMode)
--itemStackIn.stackSize;
worldIn.playSound(playerIn, blockpos, SoundEvents.BLOCK_WATERLILY_PLACE, SoundCategory.BLOCKS, 1.0F, 1.0F);
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
}
return new ActionResult(EnumActionResult.FAIL, itemStackIn);
}
}
示例6: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos);
BlockPos blockpos = flag ? pos : pos.offset(side);
if (!playerIn.canPlayerEdit(blockpos, side, stack))
{
return false;
}
else
{
Block block = worldIn.getBlockState(blockpos).getBlock();
if (!worldIn.canBlockBePlaced(block, blockpos, false, side, (Entity)null, stack))
{
return false;
}
else if (Blocks.redstone_wire.canPlaceBlockAt(worldIn, blockpos))
{
--stack.stackSize;
worldIn.setBlockState(blockpos, Blocks.redstone_wire.getDefaultState());
return true;
}
else
{
return false;
}
}
}
示例7: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
{
return false;
}
else
{
EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(stack.getMetadata());
if (enumdyecolor == EnumDyeColor.WHITE)
{
if (applyBonemeal(stack, worldIn, pos))
{
if (!worldIn.isRemote)
{
worldIn.playAuxSFX(2005, pos, 0);
}
return true;
}
}
else if (enumdyecolor == EnumDyeColor.BROWN)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (block == Blocks.log && iblockstate.getValue(BlockPlanks.VARIANT) == BlockPlanks.EnumType.JUNGLE)
{
if (side == EnumFacing.DOWN)
{
return false;
}
if (side == EnumFacing.UP)
{
return false;
}
pos = pos.offset(side);
if (worldIn.isAirBlock(pos))
{
IBlockState iblockstate1 = Blocks.cocoa.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, 0, playerIn);
worldIn.setBlockState(pos, iblockstate1, 2);
if (!playerIn.capabilities.isCreativeMode)
{
--stack.stackSize;
}
}
return true;
}
}
return false;
}
}
示例8: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
if (side == 0)
return false;
else {
if (side == 1)
y++;
if (side == 2)
z--;
if (side == 3)
z++;
if (side == 4)
x--;
if (side == 5)
x++;
if (!player.canPlayerEdit(x, y, z, side, stack))
return false;
else {
boolean flag1 = !world.isAirBlock(x, y, z) && !world.getBlock(x, y, z).isReplaceable(world, x, y, z);
flag1 |= !world.isAirBlock(x, y + 1, z) && !world.getBlock(x, y + 1, z).isReplaceable(world, x, y + 1, z);
if (flag1)
return false;
else {
double d0 = x;
double d1 = y;
double d2 = z;
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(null, AxisAlignedBB.getBoundingBox(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D));
if (list.size() > 0)
return false;
else {
if (!world.isRemote) {
world.setBlockToAir(x, y, z);
world.setBlockToAir(x, y + 1, z);
EntityArmourStand stand = new EntityArmourStand(world, d0 + 0.5D, d1, d2 + 0.5D);
float f3 = MathHelper.floor_float((MathHelper.wrapAngleTo180_float(player.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F;
stand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f3, 0.0F);
applyRandomRotations(stand, world.rand);
NBTTagCompound nbt = stack.getTagCompound();
if (nbt != null && nbt.hasKey("EntityTag", 10)) {
NBTTagCompound nbt1 = new NBTTagCompound();
stand.writeToNBTOptional(nbt1);
merge(nbt1, nbt.getCompoundTag("EntityTag"));
stand.readFromNBT(nbt1);
}
world.spawnEntityInWorld(stand);
}
stack.stackSize--;
return true;
}
}
}
}
}
示例9: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Applies the data in the EntityTag tag of the given ItemStack to the given
* Entity.
*/
@Override
public ActionResult<ItemStack> onItemRightClick( World worldIn, EntityPlayer playerIn,
EnumHand hand) {
ItemStack itemStackIn=playerIn.getHeldItem(hand);
if (worldIn.isRemote)
return new ActionResult<ItemStack>(EnumActionResult.PASS, itemStackIn);
else {
RayTraceResult raytraceresult = this.rayTrace(worldIn, playerIn, true);
if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK) {
BlockPos blockpos = raytraceresult.getBlockPos();
if (!(worldIn.getBlockState(blockpos).getBlock() instanceof BlockLiquid))
return new ActionResult<ItemStack>(EnumActionResult.PASS, itemStackIn);
else if (worldIn.isBlockModifiable(playerIn, blockpos)
&& playerIn.canPlayerEdit(blockpos, raytraceresult.sideHit, itemStackIn)) {
boolean hastag = itemStackIn.getTagCompound() != null && itemStackIn.getTagCompound().hasKey("SavedEntity");
EntityLivingBase entity = spawnCreature(worldIn, itemStackIn.getItemDamage(),
blockpos.getX() + 0.5D, blockpos.getY() + 0.5D, blockpos.getZ() + 0.5D,
hastag
? itemStackIn.getTagCompound().getCompoundTag("SavedEntity") : null);
if (entity == null)
return new ActionResult(EnumActionResult.PASS, itemStackIn);
else {
if (entity instanceof EntityLivingBase && itemStackIn.hasDisplayName())
entity.setCustomNameTag(itemStackIn.getDisplayName());
if (!playerIn.capabilities.isCreativeMode)
itemStackIn.shrink(1);
if (entity instanceof EntityBuilding) {
((EntityBuilding) entity).setOwner(playerIn);
if(hastag) {
((EntityBuilding) entity).setConstructing(true);
((EntityBuilding) entity).redeploy = true;
}
entity.rotationYaw = playerIn.rotationYawHead;
entity.renderYawOffset = playerIn.rotationYawHead;
entity.rotationYawHead = playerIn.rotationYawHead;
/*
* if(entity instanceof EntityTeleporter){
* ((EntityTeleporter)
* entity).setExit(itemStackIn.getItemDamage()>23);
* }
*/
}
playerIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
} else
return new ActionResult(EnumActionResult.FAIL, itemStackIn);
} else
return new ActionResult(EnumActionResult.PASS, itemStackIn);
}
}
示例10: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
ItemStack itemstack = stack.getHeldItem(pos);
if (playerIn.isRemote)
{
return EnumActionResult.SUCCESS;
}
else if (!stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack))
{
return EnumActionResult.FAIL;
}
else
{
IBlockState iblockstate = playerIn.getBlockState(worldIn);
Block block = iblockstate.getBlock();
if (block == Blocks.MOB_SPAWNER)
{
TileEntity tileentity = playerIn.getTileEntity(worldIn);
if (tileentity instanceof TileEntityMobSpawner)
{
MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
mobspawnerbaselogic.func_190894_a(func_190908_h(itemstack));
tileentity.markDirty();
playerIn.notifyBlockUpdate(worldIn, iblockstate, iblockstate, 3);
if (!stack.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
return EnumActionResult.SUCCESS;
}
}
BlockPos blockpos = worldIn.offset(hand);
double d0 = this.func_190909_a(playerIn, blockpos);
Entity entity = spawnCreature(playerIn, func_190908_h(itemstack), (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + d0, (double)blockpos.getZ() + 0.5D);
if (entity != null)
{
if (entity instanceof EntityLivingBase && itemstack.hasDisplayName())
{
entity.setCustomNameTag(itemstack.getDisplayName());
}
applyItemEntityDataToEntity(playerIn, stack, itemstack, entity);
if (!stack.capabilities.isCreativeMode)
{
itemstack.func_190918_g(1);
}
}
return EnumActionResult.SUCCESS;
}
}
示例11: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Callback for item usage. If the item does something special on right
* clicking, he will have one of those. Return True if something happen and
* false if it don't. This is for ITEMS, not BLOCKS
*/
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos,
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack=playerIn.getHeldItem(hand);
if (worldIn.isRemote)
return EnumActionResult.SUCCESS;
else if (!playerIn.canPlayerEdit(pos.offset(facing), facing, stack))
return EnumActionResult.FAIL;
else {
IBlockState iblockstate = worldIn.getBlockState(pos);
pos = pos.offset(facing);
double d0 = 0.0D;
if (facing == EnumFacing.UP && iblockstate.getBlock() instanceof BlockFence)
d0 = 0.5D;
boolean hastag = stack.getTagCompound() != null && stack.getTagCompound().hasKey("SavedEntity");
EntityLivingBase entity = spawnCreature(worldIn, stack.getItemDamage(), pos.getX() + 0.5D, pos.getY() + d0,
pos.getZ() + 0.5D, hastag
? stack.getTagCompound().getCompoundTag("SavedEntity") : null);
if (entity != null) {
if (entity instanceof EntityLivingBase && stack.hasDisplayName())
entity.setCustomNameTag(stack.getDisplayName());
if (!playerIn.capabilities.isCreativeMode)
stack.shrink(1);
if (entity instanceof EntityBuilding) {
((EntityBuilding) entity).setOwner(playerIn);
if(hastag) {
((EntityBuilding) entity).setConstructing(true);
((EntityBuilding) entity).redeploy = true;
}
entity.rotationYaw = playerIn.rotationYawHead;
entity.renderYawOffset = playerIn.rotationYawHead;
entity.rotationYawHead = playerIn.rotationYawHead;
if (entity instanceof EntityTeleporter)
((EntityTeleporter) entity).setExit(stack.getItemDamage() > 23);
}
}
return EnumActionResult.SUCCESS;
}
}
示例12: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (stack.stackSize == 0)
{
return false;
}
else if (!playerIn.canPlayerEdit(pos, side, stack))
{
return false;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
BlockPos blockpos = pos;
if ((side != EnumFacing.UP || block != this.block) && !block.isReplaceable(worldIn, pos))
{
blockpos = pos.offset(side);
iblockstate = worldIn.getBlockState(blockpos);
block = iblockstate.getBlock();
}
if (block == this.block)
{
int i = ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue();
if (i <= 7)
{
IBlockState iblockstate1 = iblockstate.withProperty(BlockSnow.LAYERS, Integer.valueOf(i + 1));
AxisAlignedBB axisalignedbb = this.block.getCollisionBoundingBox(worldIn, blockpos, iblockstate1);
if (axisalignedbb != null && worldIn.checkNoEntityCollision(axisalignedbb) && worldIn.setBlockState(blockpos, iblockstate1, 2))
{
worldIn.playSoundEffect((double)((float)blockpos.getX() + 0.5F), (double)((float)blockpos.getY() + 0.5F), (double)((float)blockpos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
--stack.stackSize;
return true;
}
}
}
return super.onItemUse(stack, playerIn, worldIn, blockpos, side, hitX, hitY, hitZ);
}
}
示例13: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SuppressWarnings("incomplete-switch")
/**
* Called when a Block is right-clicked with this Item
*/
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
ItemStack itemstack = stack.getHeldItem(pos);
if (!stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack))
{
return EnumActionResult.FAIL;
}
else
{
IBlockState iblockstate = playerIn.getBlockState(worldIn);
Block block = iblockstate.getBlock();
if (hand != EnumFacing.DOWN && playerIn.getBlockState(worldIn.up()).getMaterial() == Material.AIR)
{
if (block == Blocks.GRASS || block == Blocks.GRASS_PATH)
{
this.setBlock(itemstack, stack, playerIn, worldIn, Blocks.FARMLAND.getDefaultState());
return EnumActionResult.SUCCESS;
}
if (block == Blocks.DIRT)
{
switch ((BlockDirt.DirtType)iblockstate.getValue(BlockDirt.VARIANT))
{
case DIRT:
this.setBlock(itemstack, stack, playerIn, worldIn, Blocks.FARMLAND.getDefaultState());
return EnumActionResult.SUCCESS;
case COARSE_DIRT:
this.setBlock(itemstack, stack, playerIn, worldIn, Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.DIRT));
return EnumActionResult.SUCCESS;
}
}
}
return EnumActionResult.PASS;
}
}
示例14: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (side == EnumFacing.DOWN)
{
return false;
}
else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
{
return false;
}
else
{
pos = pos.offset(side);
if (!playerIn.canPlayerEdit(pos, side, stack))
{
return false;
}
else if (!Blocks.standing_banner.canPlaceBlockAt(worldIn, pos))
{
return false;
}
else if (worldIn.isRemote)
{
return true;
}
else
{
if (side == EnumFacing.UP)
{
int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
worldIn.setBlockState(pos, Blocks.standing_banner.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
}
else
{
worldIn.setBlockState(pos, Blocks.wall_banner.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
}
--stack.stackSize;
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBanner)
{
((TileEntityBanner)tileentity).setItemValues(stack);
}
return true;
}
}
}
示例15: onImpact
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onImpact(MovingObjectPosition target)
{
double posiX = 0;
double posiY = 0;
double posiZ = 0;
int plusX = 0;
int plusY = 0;
int plusZ = 0;
if (target.entityHit != null) // hit a entity
{
posiX = target.entityHit.posX;
posiY = target.entityHit.posY;
posiZ = target.entityHit.posZ;
}
else // hit the terrain
{
posiX = target.blockX;
posiY = target.blockY;
posiZ = target.blockZ;
if (target.sideHit == 0) { plusY = -1; } // Bottom
else if (target.sideHit == 1) { plusY = 1; } // Top
else if (target.sideHit == 2) { plusZ = -1; } // East
else if (target.sideHit == 3) { plusZ = 1; } // West
else if (target.sideHit == 4) { plusX = -1; } // North
else if (target.sideHit == 5) { plusX = 1; } // South
}
// Nether Check
if (this.worldObj.provider.isHellWorld)
{
this.worldObj.playSoundEffect((double)((float)this.posX + 0.5F), (double)((float)this.posY + 0.5F), (double)((float)this.posZ + 0.5F),
"random.fizz", 0.5F, 2.6F + (this.worldObj.rand.nextFloat() - this.worldObj.rand.nextFloat()) * 0.8F);
NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 11, (byte) 4);
return; // No water in the nether, yo
}
// Is the space free?
if (this.worldObj.getBlock( (int)posiX + plusX, (int)posiY + plusY, (int)posiZ + plusZ).getMaterial() == Material.air)
{
// Can we edit this block at all?
if (this.shootingEntity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) this.shootingEntity;
if (!player.canPlayerEdit( (int)posiX + plusX, (int)posiY + plusY, (int)posiZ + plusZ, 0, null ) ) { return; } // Nope
}
// Putting water there!
this.worldObj.setBlock((int)posiX + plusX, (int)posiY + plusY, (int)posiZ + plusZ, Blocks.flowing_water, 0, 3);
}
// SFX
NetHelper.sendParticleMessageToAllPlayers(this.worldObj, this.getEntityId(), (byte) 14, (byte) 4);
this.worldObj.playSoundAtEntity(this, "random.splash", 1.0F, 1.0F);
this.setDead(); // We've hit something, so begone with the projectile
}