use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.
the class BlockReinforcedFenceGate method onEntityCollidedWithBlock.
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if (world.getBlockMetadata(x, y, z) > 3)
return;
//so dropped items don't get destroyed
if (entity instanceof EntityItem)
return;
else //owner check
if (entity instanceof EntityPlayer) {
if (((TileEntityOwnable) world.getTileEntity(x, y, z)).getOwner().isOwner((EntityPlayer) entity))
return;
} else if (entity instanceof EntityCreeper) {
EntityCreeper creeper = (EntityCreeper) entity;
EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);
creeper.onStruckByLightning(lightning);
creeper.extinguish();
return;
}
//3 hearts per attack
entity.attackEntityFrom(CustomDamageSources.electricity, 6.0F);
}
use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.
the class ItemScannerDoor method onItemUse.
/**
* 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
*/
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float par8, float par9, float par10) {
if (world.isRemote)
return true;
else {
if (side != EnumFacing.UP)
return false;
else {
IBlockState iblockstate = world.getBlockState(pos);
Block block = iblockstate.getBlock();
if (!block.isReplaceable(world, pos))
pos = pos.offset(side);
if (!player.canPlayerEdit(pos, side, stack))
return false;
else if (!mod_SecurityCraft.scannerDoor.canPlaceBlockAt(world, pos))
return false;
else {
//TERD.getOwner().set(player.getGameProfile().getId().toString(), player.getName());
placeDoor(world, pos, EnumFacing.fromAngle(player.rotationYaw), mod_SecurityCraft.scannerDoor);
((TileEntityOwnable) world.getTileEntity(pos)).getOwner().set(player.getGameProfile().getId().toString(), player.getName());
((TileEntityOwnable) world.getTileEntity(pos.up())).getOwner().set(player.getGameProfile().getId().toString(), player.getName());
stack.stackSize--;
return true;
}
}
}
}
use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.
the class BlockReinforcedFenceGate method onEntityIntersected.
@Override
public void onEntityIntersected(World world, BlockPos pos, Entity entity) {
if (BlockUtils.getBlockPropertyAsBoolean(world, pos, OPEN)) {
return;
}
if (entity instanceof EntityItem)
return;
else if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (((TileEntityOwnable) world.getTileEntity(pos)).getOwner().isOwner(player))
return;
} else if (entity instanceof EntityCreeper) {
EntityCreeper creeper = (EntityCreeper) entity;
EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX(), pos.getY(), pos.getZ(), true);
creeper.onStruckByLightning(lightning);
return;
}
entity.attackEntityFrom(CustomDamageSources.electricity, 6.0F);
}
use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.
the class ItemScannerDoor method onItemUse.
/**
* 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(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (worldIn.isRemote)
return EnumActionResult.SUCCESS;
else {
if (facing != EnumFacing.UP)
return EnumActionResult.FAIL;
else {
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (!block.isReplaceable(worldIn, pos))
pos = pos.offset(facing);
if (!playerIn.canPlayerEdit(pos, facing, stack))
return EnumActionResult.FAIL;
else if (!mod_SecurityCraft.scannerDoor.canPlaceBlockAt(worldIn, pos))
return EnumActionResult.FAIL;
else {
//TERD.getOwner().set(player.getGameProfile().getId().toString(), player.getName());
placeDoor(worldIn, pos, EnumFacing.fromAngle(playerIn.rotationYaw), mod_SecurityCraft.scannerDoor);
((TileEntityOwnable) worldIn.getTileEntity(pos)).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
((TileEntityOwnable) worldIn.getTileEntity(pos.up())).getOwner().set(playerIn.getGameProfile().getId().toString(), playerIn.getName());
stack.stackSize--;
return EnumActionResult.SUCCESS;
}
}
}
}
Aggregations