use of net.minecraft.entity.EntityHanging in project Tropicraft by Tropicraft.
the class ItemAshenMask method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (facing.getAxis().isVertical()) {
return EnumActionResult.FAIL;
} else {
ItemStack stack = playerIn.getHeldItem(hand);
// It's a wall, place the shell on it.
pos = pos.offset(facing);
// Must set the world coordinates here, or onValidSurface will be false.
EntityHanging entityhanging = new EntityWallItem(worldIn, pos, facing, stack);
if (!playerIn.canPlayerEdit(pos, facing, stack)) {
return EnumActionResult.FAIL;
} else {
if (entityhanging != null && entityhanging.onValidSurface()) {
if (!worldIn.isRemote) {
worldIn.spawnEntity(entityhanging);
}
stack.shrink(1);
}
return EnumActionResult.SUCCESS;
}
}
}
use of net.minecraft.entity.EntityHanging in project Tropicraft by Tropicraft.
the class ItemShell method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (facing.getAxis().isVertical()) {
return EnumActionResult.FAIL;
} else {
// It's a wall, place the shell on it.
ItemStack stack = playerIn.getHeldItem(hand);
pos = pos.offset(facing);
// Must set the world coordinates here, or onValidSurface will be false.
EntityHanging entityhanging = new EntityWallItem(worldIn, pos, facing, stack);
if (!playerIn.canPlayerEdit(pos, facing, stack)) {
return EnumActionResult.FAIL;
} else {
if (entityhanging != null && entityhanging.onValidSurface()) {
if (!worldIn.isRemote) {
worldIn.spawnEntity(entityhanging);
}
stack.shrink(1);
}
return EnumActionResult.SUCCESS;
}
}
}
use of net.minecraft.entity.EntityHanging in project Minestuck by mraof.
the class ItemHanging method onItemUse.
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
BlockPos blockPos = pos.offset(facing);
if (facing != EnumFacing.DOWN && facing != EnumFacing.UP && player.canPlayerEdit(blockPos, facing, stack)) {
EntityHanging entityhanging = this.createEntity(worldIn, blockPos, facing, stack);
if (entityhanging != null && entityhanging.onValidSurface()) {
if (!worldIn.isRemote) {
entityhanging.playPlaceSound();
worldIn.spawnEntity(entityhanging);
}
stack.shrink(1);
}
return EnumActionResult.SUCCESS;
} else {
return EnumActionResult.FAIL;
}
}
Aggregations