use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.
the class BlockIronFence method onEntityCollidedWithBlock.
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
//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 ItemReinforcedDoor 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.reinforcedDoor.canPlaceBlockAt(world, pos)) {
return false;
} else {
//TERD.getOwner().set(player.getGameProfile().getId().toString(), player.getName());
placeDoor(world, pos, EnumFacing.fromAngle(player.rotationYaw), mod_SecurityCraft.reinforcedDoor);
((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 BlockIronFence method onEntityIntersected.
@Override
public void onEntityIntersected(World world, BlockPos pos, Entity entity) {
//so dropped items don't get destroyed
if (entity instanceof EntityItem)
return;
else //owner check
if (entity instanceof EntityPlayer) {
if (((TileEntityOwnable) world.getTileEntity(pos)).getOwner().isOwner((EntityPlayer) entity))
;
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);
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 ItemReinforcedDoor 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.reinforcedDoor.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.reinforcedDoor);
((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;
}
}
}
}
use of net.geforcemods.securitycraft.tileentity.TileEntityOwnable in project SecurityCraft by Geforce132.
the class BlockUtils method setBlockProperty.
public static void setBlockProperty(World par1World, BlockPos pos, PropertyBool property, boolean value, boolean retainOldTileEntity) {
if (retainOldTileEntity) {
ItemStack[] modules = null;
ItemStack[] inventory = null;
int[] times = new int[4];
String password = "";
Owner owner = null;
int cooldown = -1;
if (par1World.getTileEntity(pos) instanceof CustomizableSCTE) {
modules = ((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks;
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
inventory = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks;
times[0] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime;
times[1] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime;
times[2] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime;
times[3] = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime;
}
if (par1World.getTileEntity(pos) instanceof TileEntityOwnable && ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner() != null) {
owner = ((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner();
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypad && ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword() != null) {
password = ((TileEntityKeypad) par1World.getTileEntity(pos)).getPassword();
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace && ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword() != null) {
password = ((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).getPassword();
}
if (par1World.getTileEntity(pos) instanceof TileEntityKeypadChest && ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword() != null) {
password = ((TileEntityKeypadChest) par1World.getTileEntity(pos)).getPassword();
}
if (par1World.getTileEntity(pos) instanceof TileEntityPortableRadar && ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown() != 0) {
cooldown = ((TileEntityPortableRadar) par1World.getTileEntity(pos)).getAttackCooldown();
}
TileEntity tileEntity = par1World.getTileEntity(pos);
par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
par1World.setTileEntity(pos, tileEntity);
if (modules != null) {
((CustomizableSCTE) par1World.getTileEntity(pos)).itemStacks = modules;
}
if (inventory != null && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceItemStacks = inventory;
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).furnaceBurnTime = times[0];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).currentItemBurnTime = times[1];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).cookTime = times[2];
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).totalCookTime = times[3];
}
if (owner != null) {
((TileEntityOwnable) par1World.getTileEntity(pos)).getOwner().set(owner);
}
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypad) {
((TileEntityKeypad) par1World.getTileEntity(pos)).setPassword(password);
}
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadFurnace) {
((TileEntityKeypadFurnace) par1World.getTileEntity(pos)).setPassword(password);
}
if (!password.isEmpty() && par1World.getTileEntity(pos) instanceof TileEntityKeypadChest) {
((TileEntityKeypadChest) par1World.getTileEntity(pos)).setPassword(password);
}
if (cooldown != -1 && par1World.getTileEntity(pos) instanceof TileEntityPortableRadar) {
((TileEntityPortableRadar) par1World.getTileEntity(pos)).setAttackCooldown(cooldown);
}
} else {
par1World.setBlockState(pos, par1World.getBlockState(pos).withProperty(property, value));
}
}
Aggregations