Ejemplo n.º 1
0
  @Override
  public void onBlockPlacedBy(
      World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) {
    TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) world.getTileEntity(x, y, z);

    int side =
        MathHelper.floor_double((double) (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    int change = 3;

    switch (side) {
      case 0:
        change = 2;
        break;
      case 1:
        change = 5;
        break;
      case 2:
        change = 3;
        break;
      case 3:
        change = 4;
        break;
    }

    tileEntity.setFacing((short) change);
    tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z);
  }
Ejemplo n.º 2
0
 public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
   TileEntity tile = world.getTileEntity(x, y, z);
   if (tile instanceof TileEntityBasicBlock) {
     TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile;
     if (basicTile.canSetFacing(axis.ordinal())) {
       basicTile.setFacing((short) axis.ordinal());
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 3
0
 public ForgeDirection[] getValidRotations(World world, int x, int y, int z) {
   TileEntity tile = world.getTileEntity(x, y, z);
   ForgeDirection[] valid = new ForgeDirection[6];
   if (tile instanceof TileEntityBasicBlock) {
     TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile;
     for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
       if (basicTile.canSetFacing(dir.ordinal())) {
         valid[dir.ordinal()] = dir;
       }
     }
   }
   return valid;
 }
Ejemplo n.º 4
0
  @Override
  public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
    if (!world.isRemote) {
      TileEntity tileEntity = world.getTileEntity(x, y, z);

      if (tileEntity instanceof TileEntityBasicBlock) {
        ((TileEntityBasicBlock) tileEntity).onNeighborChange(block);
      }
    }
  }