use of net.tropicraft.core.common.entity.placeable.EntityWallItem 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.tropicraft.core.common.entity.placeable.EntityWallItem 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;
}
}
}
Aggregations