use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.
the class ItemBlockReinforcedSlabs method onItemUse.
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
if (this.isNotSlab) {
return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
} else if (par1ItemStack.stackSize == 0) {
return false;
} else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) {
return false;
} else {
Block block = par3World.getBlock(par4, par5, par6);
int i1 = par3World.getBlockMetadata(par4, par5, par6);
int j1 = i1 & 7;
boolean flag = (i1 & 8) != 0;
Owner owner = null;
if (par3World.getTileEntity(par4, par5, par6) instanceof IOwnable) {
owner = ((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner();
if (!((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().isOwner(par2EntityPlayer)) {
if (!par3World.isRemote) {
PlayerUtils.sendMessageToPlayer(par2EntityPlayer, StatCollector.translateToLocal("messages.reinforcedSlab"), StatCollector.translateToLocal("messages.reinforcedSlab.cannotDoubleSlab"), EnumChatFormatting.RED);
}
return false;
}
}
if ((par7 == 1 && !flag || par7 == 0 && flag) && isBlock(block) && j1 == par1ItemStack.getItemDamage()) {
if (par3World.checkNoEntityCollision(this.getBlockVariant(i1).getCollisionBoundingBoxFromPool(par3World, par4, par5, par6)) && par3World.setBlock(par4, par5, par6, this.getBlockVariant(block, i1), (block == mod_SecurityCraft.reinforcedStoneSlabs && i1 == 2 ? 2 : j1), 3)) {
par3World.playSoundEffect(par4 + 0.5F, par5 + 0.5F, par6 + 0.5F, this.getBlockVariant(block, i1).stepSound.func_150496_b(), (this.getBlockVariant(block, i1).stepSound.getVolume() + 1.0F) / 2.0F, this.getBlockVariant(block, i1).stepSound.getPitch() * 0.8F);
--par1ItemStack.stackSize;
if (owner != null) {
((IOwnable) par3World.getTileEntity(par4, par5, par6)).getOwner().set(owner);
}
}
return true;
} else {
return this.func_150946_a(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7) ? true : super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
}
}
}
use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.
the class ItemBlockReinforcedSlabs method tryPlace.
private boolean tryPlace(ItemStack stack, World worldIn, BlockPos pos, Object variantInStack) {
IBlockState iblockstate = worldIn.getBlockState(pos);
Owner owner = null;
if (worldIn.getTileEntity(pos) instanceof IOwnable) {
owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
}
if (iblockstate.getBlock() == this.singleSlab) {
Comparable<?> comparable = iblockstate.getValue(this.singleSlab.getVariantProperty());
if (comparable == variantInStack) {
IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty(this.singleSlab.getVariantProperty(), comparable);
if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3)) {
worldIn.playSoundEffect(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F);
--stack.stackSize;
if (owner != null) {
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
}
}
return true;
}
}
return false;
}
use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.
the class ItemBlockReinforcedWoodSlabs method tryPlace.
private boolean tryPlace(ItemStack stack, World worldIn, BlockPos pos, Object variantInStack) {
IBlockState iblockstate = worldIn.getBlockState(pos);
Owner owner = null;
if (worldIn.getTileEntity(pos) instanceof IOwnable) {
owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
}
if (iblockstate.getBlock() == this.singleSlab) {
Comparable<?> comparable = iblockstate.getValue(this.singleSlab.getVariantProperty());
if (comparable == variantInStack) {
IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty(this.singleSlab.getVariantProperty(), comparable);
if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3)) {
worldIn.playSoundEffect(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F);
--stack.stackSize;
if (owner != null) {
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
}
}
return true;
}
}
return false;
}
use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.
the class ItemKeyPanel method onItemUse.
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, BlockPos pos, EnumFacing par5EnumFacing, float hitX, float hitY, float hitZ) {
if (!par3World.isRemote) {
if (BlockUtils.getBlock(par3World, pos) == mod_SecurityCraft.frame) {
Owner owner = ((IOwnable) par3World.getTileEntity(pos)).getOwner();
EnumFacing enumfacing = (EnumFacing) par3World.getBlockState(pos).getValue(BlockKeypad.FACING);
par3World.setBlockState(pos, mod_SecurityCraft.keypad.getDefaultState().withProperty(BlockKeypad.FACING, enumfacing).withProperty(BlockKeypad.POWERED, false));
((IOwnable) par3World.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
par1ItemStack.stackSize -= 1;
}
return true;
}
return false;
}
use of net.geforcemods.securitycraft.api.Owner in project SecurityCraft by Geforce132.
the class ItemBlockReinforcedSlabs method tryPlace.
private boolean tryPlace(ItemStack stack, World worldIn, EntityPlayer player, BlockPos pos, Object variantInStack) {
IBlockState iblockstate = worldIn.getBlockState(pos);
Owner owner = null;
if (worldIn.getTileEntity(pos) instanceof IOwnable) {
owner = ((IOwnable) worldIn.getTileEntity(pos)).getOwner();
}
if (iblockstate.getBlock() == this.singleSlab) {
Comparable<?> comparable = iblockstate.getValue(this.singleSlab.getVariantProperty());
if (comparable == variantInStack) {
IBlockState iblockstate1 = this.makeState(this.singleSlab.getVariantProperty(), comparable);
if (worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(iblockstate1, worldIn, pos)) && worldIn.setBlockState(pos, iblockstate1, 3)) {
worldIn.playSound(player, pos, this.doubleSlab.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (this.doubleSlab.getSoundType().getVolume() + 1.0F) / 2.0F, this.doubleSlab.getSoundType().getPitch() * 0.8F);
--stack.stackSize;
if (owner != null) {
((IOwnable) worldIn.getTileEntity(pos)).getOwner().set(owner.getUUID(), owner.getName());
}
}
return true;
}
}
return false;
}
Aggregations