use of net.minecraft.util.EnumFacing in project SecurityCraft by Geforce132.
the class BlockSecurityCamera method getStateForPlacement.
@Override
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) {
IBlockState iblockstate = getDefaultState().withProperty(POWERED, Boolean.valueOf(false));
if (world.isSideSolid(pos.offset(facing.getOpposite()), facing))
return iblockstate.withProperty(FACING, facing).withProperty(POWERED, false);
else {
Iterator<?> iterator = EnumFacing.Plane.HORIZONTAL.iterator();
EnumFacing enumfacing1;
do {
if (!iterator.hasNext())
return iblockstate;
enumfacing1 = (EnumFacing) iterator.next();
} while (!world.isSideSolid(pos.offset(enumfacing1.getOpposite()), enumfacing1));
return iblockstate.withProperty(FACING, facing).withProperty(POWERED, false);
}
}
use of net.minecraft.util.EnumFacing 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 (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) && SCContent.reinforcedDoor.canPlaceBlockAt(worldIn, pos)) {
EnumFacing enumfacing = EnumFacing.fromAngle(playerIn.rotationYaw);
int i = enumfacing.getFrontOffsetX();
int j = enumfacing.getFrontOffsetZ();
boolean flag = i < 0 && hitZ < 0.5F || i > 0 && hitZ > 0.5F || j < 0 && hitX > 0.5F || j > 0 && hitX < 0.5F;
placeDoor(worldIn, pos, enumfacing, SCContent.reinforcedDoor, flag);
SoundType soundtype = worldIn.getBlockState(pos).getBlock().getSoundType(worldIn.getBlockState(pos), worldIn, pos, playerIn);
worldIn.playSound(playerIn, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F);
((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;
} else
return EnumActionResult.FAIL;
}
}
use of net.minecraft.util.EnumFacing in project SecurityCraft by Geforce132.
the class TileEntitySecurityCameraRenderer method render.
@Override
public void render(TileEntitySecurityCamera par1TileEntity, double x, double y, double z, float par5, int par6, float alpha) {
float rotation = 0F;
if (par1TileEntity.hasWorld()) {
Tessellator tessellator = Tessellator.getInstance();
float f = par1TileEntity.getWorld().getLightBrightness(par1TileEntity.getPos());
int l = par1TileEntity.getWorld().getCombinedLight(par1TileEntity.getPos(), 0);
int l1 = l % 65536;
int l2 = l / 65536;
// TODO: does this work?
tessellator.getBuffer().putColorRGBA(0, (int) (f * 255.0F), (int) (f * 255.0F), (int) (f * 255.0F), 255);
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);
}
GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
Minecraft.getMinecraft().renderEngine.bindTexture(cameraTexture);
GL11.glPushMatrix();
if (par1TileEntity.hasWorld() && BlockUtils.getBlock(par1TileEntity.getWorld(), par1TileEntity.getPos()) == SCContent.securityCamera) {
EnumFacing side = BlockUtils.getBlockPropertyAsEnum(getWorld(), par1TileEntity.getPos(), BlockSecurityCamera.FACING);
if (side == EnumFacing.EAST)
rotation = -1F;
else if (side == EnumFacing.SOUTH)
rotation = -10000F;
else if (side == EnumFacing.WEST)
rotation = 1F;
else if (side == EnumFacing.NORTH)
rotation = 0F;
} else
rotation = -10000F;
GL11.glRotatef(180F, rotation, 0.0F, 1.0F);
modelSecurityCamera.cameraRotationPoint.rotateAngleY = par1TileEntity.cameraRotation;
modelSecurityCamera.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
GL11.glPopMatrix();
}
use of net.minecraft.util.EnumFacing in project SecurityCraft by Geforce132.
the class EntitySecurityCamera method moveViewRight.
public void moveViewRight() {
if (BlockUtils.hasBlockProperty(worldObj, BlockUtils.toPos((int) Math.floor(posX), (int) (posY - 1D), (int) Math.floor(posZ)), BlockSecurityCamera.FACING)) {
EnumFacing facing = BlockUtils.getBlockPropertyAsEnum(worldObj, BlockUtils.toPos((int) Math.floor(posX), (int) (posY - 1D), (int) Math.floor(posZ)), BlockSecurityCamera.FACING);
if (facing == EnumFacing.EAST) {
if ((rotationYaw + CAMERA_SPEED) < 0F)
setRotation(rotationYaw += CAMERA_SPEED, rotationPitch);
} else if (facing == EnumFacing.WEST) {
if ((rotationYaw + CAMERA_SPEED) < 180F)
setRotation(rotationYaw += CAMERA_SPEED, rotationPitch);
} else if (facing == EnumFacing.NORTH) {
if ((((rotationYaw + CAMERA_SPEED) > 85F) && ((rotationYaw + CAMERA_SPEED) < 185F)) || ((rotationYaw + CAMERA_SPEED) < -95F) && ((rotationYaw + CAMERA_SPEED) > -180F))
setRotation(rotationYaw += CAMERA_SPEED, rotationPitch);
} else if (facing == EnumFacing.SOUTH)
if ((rotationYaw + CAMERA_SPEED) < 90F)
setRotation(rotationYaw += CAMERA_SPEED, rotationPitch);
updateServerRotation();
}
}
use of net.minecraft.util.EnumFacing in project SecurityCraft by Geforce132.
the class BlockAlarm method onNeighborBlockChange.
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor Block
*/
@Override
public void onNeighborBlockChange(World par1World, BlockPos pos, IBlockState state, Block par5Block) {
if (par1World.isRemote)
return;
else
playSoundAndUpdate(par1World, pos);
EnumFacing enumfacing = (EnumFacing) state.getValue(FACING);
if (!par1World.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true)) {
dropBlockAsItem(par1World, pos, state, 0);
par1World.setBlockToAir(pos);
}
}
Aggregations